Skip to content

Commit

Permalink
Add sad path test for non-unique canonical_id
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobyarborough committed Jan 19, 2024
1 parent 1cfc199 commit 9d563ee
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion spec/features/resource_adding_and_changing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@
end

context "when invalid resource attributes are submitted" do
let!(:resource) { create(:resource, organization_id: user_organization.id) }
let!(:resource) { create(:resource, organization_id: user_organization.id, canonical_id: '4') }
let(:resource_uri) { resource.source_uri }
let(:resource_canonical_id) { resource.canonical_id }

describe 'source URI is invalid' do
it "should display an error message and re-render the form" do
Expand All @@ -69,5 +70,18 @@
expect(page).to have_content("The Source URI is already in use for this organization.")
end
end

describe 'canonical uri is not unique' do
it "should display an error message and re-render the form" do
fill_in "Caption", with: resource_attributes[:name]
fill_in "Canonical ID", with: resource_canonical_id
fill_in "Source URI", with: resource_attributes[:source_uri]
fill_in "Host URIs", with: "http://example.com/abc\nhttp://example.com/xyz"
click_button("Create Resource")

expect(page).to have_current_path(resources_path(organization_id: user_organization))
expect(page).to have_content("The Canonical ID is already in use for this organization.")
end
end
end
end

0 comments on commit 9d563ee

Please sign in to comment.