mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-08 23:18:18 -07:00
user and recipient and tests
This commit is contained in:
parent
d70e30ec93
commit
df2ea95ceb
50 changed files with 1412 additions and 37 deletions
42
spec/views/recipients/edit.html.erb_spec.rb
Normal file
42
spec/views/recipients/edit.html.erb_spec.rb
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "recipients/edit", type: :view do
|
||||
before(:each) do
|
||||
@recipient = assign(:recipient, Recipient.create!(
|
||||
:name => "MyString",
|
||||
:phone => "MyString",
|
||||
:gender => "MyString",
|
||||
:race => "MyString",
|
||||
:ethnicity => "MyString",
|
||||
:home_language_id => 1,
|
||||
:income => "MyString",
|
||||
:opted_out => false,
|
||||
:school_id => 1
|
||||
))
|
||||
end
|
||||
|
||||
it "renders the edit recipient form" do
|
||||
render
|
||||
|
||||
assert_select "form[action=?][method=?]", recipient_path(@recipient), "post" do
|
||||
|
||||
assert_select "input#recipient_name[name=?]", "recipient[name]"
|
||||
|
||||
assert_select "input#recipient_phone[name=?]", "recipient[phone]"
|
||||
|
||||
assert_select "input#recipient_gender[name=?]", "recipient[gender]"
|
||||
|
||||
assert_select "input#recipient_race[name=?]", "recipient[race]"
|
||||
|
||||
assert_select "input#recipient_ethnicity[name=?]", "recipient[ethnicity]"
|
||||
|
||||
assert_select "input#recipient_home_language_id[name=?]", "recipient[home_language_id]"
|
||||
|
||||
assert_select "input#recipient_income[name=?]", "recipient[income]"
|
||||
|
||||
assert_select "input#recipient_opted_out[name=?]", "recipient[opted_out]"
|
||||
|
||||
assert_select "input#recipient_school_id[name=?]", "recipient[school_id]"
|
||||
end
|
||||
end
|
||||
end
|
||||
43
spec/views/recipients/index.html.erb_spec.rb
Normal file
43
spec/views/recipients/index.html.erb_spec.rb
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "recipients/index", type: :view do
|
||||
before(:each) do
|
||||
assign(:recipients, [
|
||||
Recipient.create!(
|
||||
:name => "Name",
|
||||
:phone => "Phone",
|
||||
:gender => "Gender",
|
||||
:race => "Race",
|
||||
:ethnicity => "Ethnicity",
|
||||
:home_language_id => 2,
|
||||
:income => "Income",
|
||||
:opted_out => false,
|
||||
:school_id => 3
|
||||
),
|
||||
Recipient.create!(
|
||||
:name => "Name",
|
||||
:phone => "Phone",
|
||||
:gender => "Gender",
|
||||
:race => "Race",
|
||||
:ethnicity => "Ethnicity",
|
||||
:home_language_id => 2,
|
||||
:income => "Income",
|
||||
:opted_out => false,
|
||||
:school_id => 3
|
||||
)
|
||||
])
|
||||
end
|
||||
|
||||
it "renders a list of recipients" do
|
||||
render
|
||||
assert_select "tr>td", :text => "Name".to_s, :count => 2
|
||||
assert_select "tr>td", :text => "Phone".to_s, :count => 2
|
||||
assert_select "tr>td", :text => "Gender".to_s, :count => 2
|
||||
assert_select "tr>td", :text => "Race".to_s, :count => 2
|
||||
assert_select "tr>td", :text => "Ethnicity".to_s, :count => 2
|
||||
assert_select "tr>td", :text => 2.to_s, :count => 2
|
||||
assert_select "tr>td", :text => "Income".to_s, :count => 2
|
||||
assert_select "tr>td", :text => false.to_s, :count => 2
|
||||
assert_select "tr>td", :text => 3.to_s, :count => 2
|
||||
end
|
||||
end
|
||||
42
spec/views/recipients/new.html.erb_spec.rb
Normal file
42
spec/views/recipients/new.html.erb_spec.rb
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "recipients/new", type: :view do
|
||||
before(:each) do
|
||||
assign(:recipient, Recipient.new(
|
||||
:name => "MyString",
|
||||
:phone => "MyString",
|
||||
:gender => "MyString",
|
||||
:race => "MyString",
|
||||
:ethnicity => "MyString",
|
||||
:home_language_id => 1,
|
||||
:income => "MyString",
|
||||
:opted_out => false,
|
||||
:school_id => 1
|
||||
))
|
||||
end
|
||||
|
||||
it "renders new recipient form" do
|
||||
render
|
||||
|
||||
assert_select "form[action=?][method=?]", recipients_path, "post" do
|
||||
|
||||
assert_select "input#recipient_name[name=?]", "recipient[name]"
|
||||
|
||||
assert_select "input#recipient_phone[name=?]", "recipient[phone]"
|
||||
|
||||
assert_select "input#recipient_gender[name=?]", "recipient[gender]"
|
||||
|
||||
assert_select "input#recipient_race[name=?]", "recipient[race]"
|
||||
|
||||
assert_select "input#recipient_ethnicity[name=?]", "recipient[ethnicity]"
|
||||
|
||||
assert_select "input#recipient_home_language_id[name=?]", "recipient[home_language_id]"
|
||||
|
||||
assert_select "input#recipient_income[name=?]", "recipient[income]"
|
||||
|
||||
assert_select "input#recipient_opted_out[name=?]", "recipient[opted_out]"
|
||||
|
||||
assert_select "input#recipient_school_id[name=?]", "recipient[school_id]"
|
||||
end
|
||||
end
|
||||
end
|
||||
30
spec/views/recipients/show.html.erb_spec.rb
Normal file
30
spec/views/recipients/show.html.erb_spec.rb
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "recipients/show", type: :view do
|
||||
before(:each) do
|
||||
@recipient = assign(:recipient, Recipient.create!(
|
||||
:name => "Name",
|
||||
:phone => "Phone",
|
||||
:gender => "Gender",
|
||||
:race => "Race",
|
||||
:ethnicity => "Ethnicity",
|
||||
:home_language_id => 2,
|
||||
:income => "Income",
|
||||
:opted_out => false,
|
||||
:school_id => 3
|
||||
))
|
||||
end
|
||||
|
||||
it "renders attributes in <p>" do
|
||||
render
|
||||
expect(rendered).to match(/Name/)
|
||||
expect(rendered).to match(/Phone/)
|
||||
expect(rendered).to match(/Gender/)
|
||||
expect(rendered).to match(/Race/)
|
||||
expect(rendered).to match(/Ethnicity/)
|
||||
expect(rendered).to match(/2/)
|
||||
expect(rendered).to match(/Income/)
|
||||
expect(rendered).to match(/false/)
|
||||
expect(rendered).to match(/3/)
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue