Skip to content

Commit 449d442

Browse files
committed
Write a failing test
1 parent 51c4e72 commit 449d442

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

features/admin-limit-access-editions.feature

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,11 @@ Feature: Viewing most recent editions in admin
2323
And I check the "Limit access to publishers from organisations associated with this document before you publish" box
2424
When I click "Save"
2525
Then I should see the validation error "Access can only be limited by users belonging to an organisation tagged to the document"
26+
27+
Scenario: Attempting to change organisation when document is access limited
28+
Given I am an editor in the organisation "Foo"
29+
And I create an access limited document
30+
When I set the Lead organisation to an org I am not in
31+
When I click "Save"
32+
Then I should see the validation error "Access can only be limited by users belonging to an organisation tagged to the document"
33+
And I should still be able to access the document

features/step_definitions/admin_limit_access_steps.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,16 @@
4141
Then(/^I should see the validation error "(.+)"$/) do |string|
4242
expect(page).to have_content string
4343
end
44+
45+
Given(/^I create an access limited document$/) do
46+
step "I begin drafting a new document"
47+
step "I check the \"Limit access to publishers from organisations associated with this document before you publish\" box"
48+
step "I click \"Save\""
49+
end
50+
51+
Then(/^I should still be able to access the document$/) do
52+
visit current_url # refresh
53+
expect(page).not_to have_content "You do not have permission to access this page."
54+
expect(page).to have_content "Test publication"
55+
expect(Edition.last.organisations).to eq([@user.organisation])
56+
end

0 commit comments

Comments
 (0)