Skip to content

Commit

Permalink
Move user admin feature tests into view+controller tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Apr 10, 2018
1 parent a850aed commit cf8cbb2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 29 deletions.
17 changes: 17 additions & 0 deletions spec/controllers/spotlight/roles_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,23 @@

expect(exhibit.roles.last.role).to eq 'curator'
expect(exhibit.roles.last.user.email).to eq user.email
expect(flash[:notice]).to eq 'User has been updated.'
end

it 'invites new users' do
expect do
patch :update_all, params: {
exhibit_id: exhibit,
'exhibit' => {
'roles_attributes' => {
'0' => { 'role' => 'curator', 'user_key' => 'something@example.com' }
}
}
}
end.to change { Devise::Mailer.deliveries.count }.by(1)

expect(exhibit.roles.last.user.email).to eq 'something@example.com'
expect(exhibit.roles.last.user.invitation_sent_at).to be_present
end

it 'updates roles' do
Expand Down
29 changes: 0 additions & 29 deletions spec/features/user_admin_spec.rb

This file was deleted.

2 changes: 2 additions & 0 deletions spec/views/spotlight/roles/index.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
assert_select "form[action='#{action}'][method='post']" do
assert_select "tr[data-show-for='#{admin_role.id}']"
assert_select "tr[data-edit-for='#{admin_role.id}']"
assert_select 'td', /jane@example.com/
assert_select 'td', 'Admin'
assert_select "input[type='submit'][data-behavior='destroy-user'][data-target='#{admin_role.id}']"
assert_select "input[type='hidden'][data-destroy-for='#{admin_role.id}']"
assert_select "a[data-behavior='cancel-edit']"
Expand Down

0 comments on commit cf8cbb2

Please sign in to comment.