-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic tests for UsersTab add user button
- Loading branch information
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
spec/views/components/pageflow/admin/add_membership_button_if_needed_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
require 'spec_helper' | ||
|
||
module Pageflow | ||
module Admin | ||
describe AddMembershipButtonIfNeeded, type: :view_component do | ||
before do | ||
helper.extend(ActiveAdmin::ViewHelpers) | ||
helper.extend(Pageflow::Admin::MembershipsHelper) | ||
allow(helper).to receive(:new_admin_account_membership_path) | ||
allow(helper).to receive(:membership_possible_for) | ||
allow(helper).to receive(:url_for) | ||
end | ||
|
||
it 'renders add user button when account available' do | ||
account = create(:account) | ||
user_account = create(:account) | ||
create(:user, :member, on: user_account) | ||
account_manager = create(:user, :manager, on: account) | ||
create(:membership, | ||
user: account_manager, | ||
entity: user_account, | ||
role: :manager) | ||
sign_in(account_manager) | ||
|
||
render do | ||
add_membership_button_if_needed(account_manager, account, 'account') | ||
end | ||
|
||
expect(rendered).to have_selector('a', text: 'Add user') | ||
expect(rendered).to_not have_selector('a', class: 'disabled') | ||
end | ||
|
||
it 'renders disabled add user button when account unavailable' do | ||
account = create(:account) | ||
create(:user, :member, on: account) | ||
account_manager = create(:user, :manager, on: account) | ||
sign_in(account_manager) | ||
|
||
render do | ||
add_membership_button_if_needed(account_manager, account, 'account') | ||
end | ||
|
||
expect(rendered).to have_selector('a', class: 'disabled') | ||
end | ||
end | ||
end | ||
end |