diff options
Diffstat (limited to 'spec/support/shared_examples/controllers/concerns/onboarding/redirectable_shared_examples.rb')
-rw-r--r-- | spec/support/shared_examples/controllers/concerns/onboarding/redirectable_shared_examples.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/support/shared_examples/controllers/concerns/onboarding/redirectable_shared_examples.rb b/spec/support/shared_examples/controllers/concerns/onboarding/redirectable_shared_examples.rb new file mode 100644 index 00000000000..b448ea16128 --- /dev/null +++ b/spec/support/shared_examples/controllers/concerns/onboarding/redirectable_shared_examples.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +RSpec.shared_examples Onboarding::Redirectable do + it { is_expected.to redirect_to dashboard_projects_path } + + context 'when the new user already has any accepted group membership' do + let!(:single_member) { create(:group_member, invite_email: email) } + + it 'redirects to activity group path with a flash message' do + post_create + + expect(response).to redirect_to activity_group_path(single_member.source) + expect(controller).to set_flash[:notice].to(/You have been granted/) + end + + context 'when the new user already has more than 1 accepted group membership' do + let!(:last_member) { create(:group_member, invite_email: email) } + + it 'redirects to the last member activity group path without a flash message' do + post_create + + expect(response).to redirect_to activity_group_path(last_member.source) + expect(controller).not_to set_flash[:notice].to(/You have been granted/) + end + end + + context 'when the member has an orphaned source at the time of registering' do + before do + single_member.source.delete + end + + it { is_expected.to redirect_to dashboard_projects_path } + end + end +end |