Skip to content

Instantly share code, notes, and snippets.

@rianrainey
Last active December 17, 2015 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rianrainey/5627974 to your computer and use it in GitHub Desktop.
Save rianrainey/5627974 to your computer and use it in GitHub Desktop.
context "when a valid form is submitted" do
before do
3.times do |s|
FactoryGirl.create(:specialty, urn: "urn-num-#{s}")
end
end
it "adds specialties to an organization" do
visit edit_organization_path(organization)
specialty_first = Specialty.first
specialty_last = Specialty.last
check("organization_specialty_ids_#{specialty_first.id}")
check("organization_specialty_ids_#{specialty_last.id}")
expect {
click_button "Update Organization"
}.to change{organization.reload.specialties.size}.by(2)
end
it "removes specialties from an organization" do
organization.specialty_ids = [Specialty.first.id, Specialty.last.id]
visit edit_organization_path(organization)
uncheck("organization_specialty_ids_#{Specialty.first.id}")
uncheck("organization_specialty_ids_#{Specialty.last.id}")
expect {
click_button "Update Organization"
}.to change{organization.reload.specialties.size}.by(-2)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment