diff options
Diffstat (limited to 'spec/presenters/issue_email_participant_presenter_spec.rb')
-rw-r--r-- | spec/presenters/issue_email_participant_presenter_spec.rb | 43 |
1 files changed, 19 insertions, 24 deletions
diff --git a/spec/presenters/issue_email_participant_presenter_spec.rb b/spec/presenters/issue_email_participant_presenter_spec.rb index c270fae3058..993cc9c235b 100644 --- a/spec/presenters/issue_email_participant_presenter_spec.rb +++ b/spec/presenters/issue_email_participant_presenter_spec.rb @@ -3,54 +3,49 @@ require 'spec_helper' RSpec.describe IssueEmailParticipantPresenter, feature_category: :service_desk do - # See https://gitlab.com/gitlab-org/gitlab/-/issues/389247 - # for details around build_stubbed for access level - let_it_be(:non_member) { create(:user) } # rubocop:todo RSpec/FactoryBot/AvoidCreate - let_it_be(:guest) { create(:user) } # rubocop:todo RSpec/FactoryBot/AvoidCreate - let_it_be(:reporter) { create(:user) } # rubocop:todo RSpec/FactoryBot/AvoidCreate - let_it_be(:developer) { create(:user) } # rubocop:todo RSpec/FactoryBot/AvoidCreate - let_it_be(:group) { create(:group) } # rubocop:todo RSpec/FactoryBot/AvoidCreate - let_it_be(:project) { create(:project, group: group) } # rubocop:todo RSpec/FactoryBot/AvoidCreate - let_it_be(:issue) { build_stubbed(:issue, project: project) } - let_it_be(:participant) { build_stubbed(:issue_email_participant, issue: issue, email: 'any@email.com') } - - let(:user) { nil } - let(:presenter) { described_class.new(participant, current_user: user) } + let(:user) { build_stubbed(:user) } + let(:project) { build_stubbed(:project) } + let(:issue) { build_stubbed(:issue, project: project) } + let(:participant) { build_stubbed(:issue_email_participant, issue: issue, email: 'any@example.com') } let(:obfuscated_email) { 'an*****@e*****.c**' } - let(:email) { 'any@email.com' } + let(:email) { 'any@example.com' } - before_all do - group.add_guest(guest) - group.add_reporter(reporter) - group.add_developer(developer) - end + subject(:presenter) { described_class.new(participant, current_user: user) } describe '#email' do subject { presenter.email } - it { is_expected.to eq(obfuscated_email) } + context 'when anonymous' do + let(:user) { nil } + + it { is_expected.to eq(obfuscated_email) } + end context 'with signed in user' do + before do + stub_member_access_level(project, access_level => user) if access_level + end + context 'when user has no role in project' do - let(:user) { non_member } + let(:access_level) { nil } it { is_expected.to eq(obfuscated_email) } end context 'when user has guest role in project' do - let(:user) { guest } + let(:access_level) { :guest } it { is_expected.to eq(obfuscated_email) } end context 'when user has reporter role in project' do - let(:user) { reporter } + let(:access_level) { :reporter } it { is_expected.to eq(email) } end context 'when user has developer role in project' do - let(:user) { developer } + let(:access_level) { :developer } it { is_expected.to eq(email) } end |