diff options
Diffstat (limited to 'spec/serializers/merge_request_widget_entity_spec.rb')
-rw-r--r-- | spec/serializers/merge_request_widget_entity_spec.rb | 68 |
1 files changed, 31 insertions, 37 deletions
diff --git a/spec/serializers/merge_request_widget_entity_spec.rb b/spec/serializers/merge_request_widget_entity_spec.rb index 3f7d5542ae8..9f734c08ef4 100644 --- a/spec/serializers/merge_request_widget_entity_spec.rb +++ b/spec/serializers/merge_request_widget_entity_spec.rb @@ -285,54 +285,34 @@ RSpec.describe MergeRequestWidgetEntity do end describe 'user callouts' do - context 'when suggest pipeline feature is enabled' do - subject { described_class.new(resource, request: request, experiment_enabled: :suggest_pipeline).as_json } + subject { described_class.new(resource, request: request).as_json } - it 'provides a valid path value for user callout path' do - expect(subject[:user_callouts_path]).to eq '/-/user_callouts' - end - - it 'provides a valid value for suggest pipeline feature id' do - expect(subject[:suggest_pipeline_feature_id]).to eq described_class::SUGGEST_PIPELINE - end - - it 'provides a valid value for if it is dismissed' do - expect(subject[:is_dismissed_suggest_pipeline]).to be(false) - end - - context 'when the suggest pipeline has been dismissed' do - before do - create(:user_callout, user: user, feature_name: described_class::SUGGEST_PIPELINE) - end - - it 'indicates suggest pipeline has been dismissed' do - expect(subject[:is_dismissed_suggest_pipeline]).to be(true) - end - end + it 'provides a valid path value for user callout path' do + expect(subject[:user_callouts_path]).to eq '/-/user_callouts' + end - context 'when user is not logged in' do - let(:request) { double('request', current_user: nil, project: project) } + it 'provides a valid value for suggest pipeline feature id' do + expect(subject[:suggest_pipeline_feature_id]).to eq described_class::SUGGEST_PIPELINE + end - it 'returns a blank is dismissed value' do - expect(subject[:is_dismissed_suggest_pipeline]).to be_nil - end - end + it 'provides a valid value for if it is dismissed' do + expect(subject[:is_dismissed_suggest_pipeline]).to be(false) end - context 'when suggest pipeline feature is not enabled' do + context 'when the suggest pipeline has been dismissed' do before do - stub_feature_flags(suggest_pipeline: false) + create(:user_callout, user: user, feature_name: described_class::SUGGEST_PIPELINE) end - it 'provides no valid value for user callout path' do - expect(subject[:user_callouts_path]).to be_nil + it 'indicates suggest pipeline has been dismissed' do + expect(subject[:is_dismissed_suggest_pipeline]).to be(true) end + end - it 'provides no valid value for suggest pipeline feature id' do - expect(subject[:suggest_pipeline_feature_id]).to be_nil - end + context 'when user is not logged in' do + let(:request) { double('request', current_user: nil, project: project) } - it 'provides no valid value for if it is dismissed' do + it 'returns a blank is dismissed value' do expect(subject[:is_dismissed_suggest_pipeline]).to be_nil end end @@ -371,4 +351,18 @@ RSpec.describe MergeRequestWidgetEntity do it 'has security_reports_docs_path' do expect(subject[:security_reports_docs_path]).not_to be_nil end + + describe 'has source_project_default_url' do + it 'returns the default url to the source project' do + expect(subject[:source_project_default_url]).to eq project.http_url_to_repo + end + + context 'when source project is nil' do + it 'returns nil' do + allow(resource).to receive(:source_project).and_return(nil) + + expect(subject[:source_project_default_url]).to be_nil + end + end + end end |