Skip to content

Commit

Permalink
Basic tests for UserAccountsTab add user button
Browse files Browse the repository at this point in the history
  • Loading branch information
aviav committed Aug 13, 2017
1 parent 5529970 commit 6f54458
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module Admin
helper.extend(ActiveAdmin::ViewHelpers)
helper.extend(Pageflow::Admin::MembershipsHelper)
allow(helper).to receive(:new_admin_account_membership_path)
allow(helper).to receive(:new_admin_user_membership_path)
allow(helper).to receive(:url_for)
end

Expand Down Expand Up @@ -41,6 +42,38 @@ module Admin

expect(rendered).to have_selector('a', class: 'disabled')
end

it 'renders add account button when account available' do
first_account = create(:account)
user = create(:user, :member, on: first_account)
second_account = create(:account)
account_manager = create(:user, :manager, on: first_account)
create(:membership,
user: account_manager,
entity: second_account,
role: 'manager')
sign_in(account_manager)

render do
add_membership_button_if_needed(user, user, 'account')
end

expect(rendered).to have_selector('a', text: 'Add Account')
expect(rendered).to_not have_selector('a', class: 'disabled')
end

it 'renders disabled add account button when account unavailable' do
first_account = create(:account)
user = create(:user, :member, on: first_account)
account_manager = create(:user, :manager, on: first_account)
sign_in(account_manager)

render do
add_membership_button_if_needed(user, user, 'account')
end

expect(rendered).to have_selector('a', class: 'disabled')
end
end
end
end

0 comments on commit 6f54458

Please sign in to comment.