Last active
December 17, 2015 14:59
-
-
Save rianrainey/5627974 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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