Skip to content

Commit

Permalink
test for invalid tokens error
Browse files Browse the repository at this point in the history
This test follows the steps to reproduce the error in issue #2873.  But I can’t reproduce the error when I remove the original PR fix that adds turbolinks_events.js.  So I cannot confirm that this test can serve as a regression test.
  • Loading branch information
elrayle committed Mar 31, 2018
1 parent 054d410 commit 2165a87
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions spec/features/dashboard/collection_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
RSpec.describe 'collection', type: :feature, clean_repo: true do
include Selectors::Dashboard

let(:user) { create(:user) }
let(:admin_user) { create(:admin) }
let(:collection_type) { create(:collection_type, creator_user: user) }
Expand Down Expand Up @@ -865,11 +867,16 @@ def get_url_fragment(type)
end

context "to true, limits available users", js: true do
let(:user2) { create(:user) }
it "to system users filted by select2" do
visit "/dashboard/collections/#{sharable_collection_id}/edit"
expect(page).to have_link('Sharing', href: '#sharing')
click_link('Sharing')
expect(page).to have_selector(".form-inline.add-users .select2-container")
select_user(user2, 'Depositor')
click_button('Save')
click_link('Sharing')
expect(page).to have_selector('td', text: user2.user_key)
end
end

Expand Down
15 changes: 15 additions & 0 deletions spec/support/selectors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ def db_item_actions_toggle(item)
find '.dropdown-toggle'
end
end

# For use with javascript user selector that allows for searching for an existing user
# and granting them permission to an object.
# @param [User] user to select
# @param [String] role granting the user permission (e.g. 'Manager' | 'Depositor' | 'Viewer')
def select_user(user, role='Depositor')
first('a.select2-choice').click
find('.select2-input').set(user.user_key)
sleep 1
first('div.select2-result-label').click
within('div.add-users') do
select(role)
find('input.edit-collection-add-sharing-button').click
end
end
end

module NewTransfers
Expand Down

0 comments on commit 2165a87

Please sign in to comment.