Skip to content

Commit

Permalink
make people controller test also test if nationality is saved correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomTannenbaum committed Mar 12, 2024
1 parent 44c03ad commit 5c7a8a0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions spec/controllers/people_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@

it 'should save nationality2 as nil if checkbox is unchecked and save it if it is checked' do
expect(person["nationality2"]).not_to be(nil)

put :update, params: {id: person["id"], person: person, has_nationality2: {checked: "0"}}

response.code.should == "302"
response.should redirect_to(person_path(person["id"]))

expect(people(:bob).reload.nationality2).to be(nil)

edited_person = person
edited_person["nationality2"] = "DE"
put :update, params: {id: person["id"], person: edited_person, has_nationality2: {checked: "1"}}
response.code.should == "302"
response.should redirect_to(person_path(person["id"]))
expect(people(:bob).reload.nationality2).to eql("DE")
end
end
end

0 comments on commit 5c7a8a0

Please sign in to comment.