diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-20 13:43:29 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-20 13:43:29 +0300 |
commit | 3b1af5cc7ed2666ff18b718ce5d30fa5a2756674 (patch) | |
tree | 3bc4a40e0ee51ec27eabf917c537033c0c5b14d4 /spec/serializers | |
parent | 9bba14be3f2c211bf79e15769cd9b77bc73a13bc (diff) |
Add latest changes from gitlab-org/gitlab@16-1-stable-eev16.1.0-rc42
Diffstat (limited to 'spec/serializers')
9 files changed, 48 insertions, 50 deletions
diff --git a/spec/serializers/access_token_entity_base_spec.rb b/spec/serializers/access_token_entity_base_spec.rb index 8a92a53d0c1..f310a3d4a99 100644 --- a/spec/serializers/access_token_entity_base_spec.rb +++ b/spec/serializers/access_token_entity_base_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' RSpec.describe AccessTokenEntityBase do let_it_be(:user) { create(:user) } - let_it_be(:token) { create(:personal_access_token, user: user, expires_at: nil) } + let_it_be(:token) { create(:personal_access_token, user: user) } subject(:json) { described_class.new(token).as_json } diff --git a/spec/serializers/admin/abuse_report_details_entity_spec.rb b/spec/serializers/admin/abuse_report_details_entity_spec.rb index 0e5e6a62ce1..08bfa57b062 100644 --- a/spec/serializers/admin/abuse_report_details_entity_spec.rb +++ b/spec/serializers/admin/abuse_report_details_entity_spec.rb @@ -21,8 +21,7 @@ RSpec.describe Admin::AbuseReportDetailsEntity, feature_category: :insider_threa expect(entity_hash.keys).to include( :user, :reporter, - :report, - :actions + :report ) end @@ -127,31 +126,15 @@ RSpec.describe Admin::AbuseReportDetailsEntity, feature_category: :insider_threa report_hash = entity_hash[:report] expect(report_hash.keys).to match_array([ + :status, :message, :reported_at, :category, :type, :content, :url, - :screenshot - ]) - end - - it 'correctly exposes `actions`', :aggregate_failures do - actions_hash = entity_hash[:actions] - - expect(actions_hash.keys).to match_array([ - :user_blocked, - :block_user_path, - :remove_user_and_report_path, - :remove_report_path, - :reported_user, - :redirect_path - ]) - - expect(actions_hash[:reported_user].keys).to match_array([ - :name, - :created_at + :screenshot, + :update_path ]) end end diff --git a/spec/serializers/admin/abuse_report_details_serializer_spec.rb b/spec/serializers/admin/abuse_report_details_serializer_spec.rb index f22d92a1763..a42c56c0921 100644 --- a/spec/serializers/admin/abuse_report_details_serializer_spec.rb +++ b/spec/serializers/admin/abuse_report_details_serializer_spec.rb @@ -12,8 +12,7 @@ RSpec.describe Admin::AbuseReportDetailsSerializer, feature_category: :insider_t is_expected.to include( :user, :reporter, - :report, - :actions + :report ) end end diff --git a/spec/serializers/deployment_cluster_entity_spec.rb b/spec/serializers/deployment_cluster_entity_spec.rb index 419ae746b74..1fb07b0e8fd 100644 --- a/spec/serializers/deployment_cluster_entity_spec.rb +++ b/spec/serializers/deployment_cluster_entity_spec.rb @@ -12,7 +12,7 @@ RSpec.describe DeploymentClusterEntity do let(:request) { double(:request, current_user: current_user) } let(:project) { create(:project) } let(:cluster) { create(:cluster, name: 'the-cluster', projects: [project]) } - let(:deployment) { create(:deployment, cluster: cluster) } + let(:deployment) { create(:deployment) } let!(:deployment_cluster) { create(:deployment_cluster, cluster: cluster, deployment: deployment) } before do diff --git a/spec/serializers/integrations/field_entity_spec.rb b/spec/serializers/integrations/field_entity_spec.rb index 4d190b9a98e..25ac0aa4911 100644 --- a/spec/serializers/integrations/field_entity_spec.rb +++ b/spec/serializers/integrations/field_entity_spec.rb @@ -25,8 +25,7 @@ RSpec.describe Integrations::FieldEntity, feature_category: :integrations do name: 'username', title: 'Email or username', placeholder: nil, - help: 'Only required for Basic authentication. ' \ - 'Email for Jira Cloud or username for Jira Data Center and Jira Server', + help: 'Email for Jira Cloud or username for Jira Data Center and Jira Server', required: false, choices: nil, value: 'jira_username', @@ -45,7 +44,7 @@ RSpec.describe Integrations::FieldEntity, feature_category: :integrations do section: 'connection', type: 'password', name: 'password', - title: 'New API token, password, or Jira personal access token', + title: 'New API token or password', placeholder: nil, help: 'Leave blank to use your current configuration', required: true, diff --git a/spec/serializers/member_serializer_spec.rb b/spec/serializers/member_serializer_spec.rb index bc256432c46..c35ecf5f636 100644 --- a/spec/serializers/member_serializer_spec.rb +++ b/spec/serializers/member_serializer_spec.rb @@ -28,7 +28,6 @@ RSpec.describe MemberSerializer do expect { representation }.to change(group_member, :last_owner) .from(nil).to(true) - .and change(group_member, :last_blocked_owner).from(nil).to(false) end end diff --git a/spec/serializers/merge_request_widget_entity_spec.rb b/spec/serializers/merge_request_widget_entity_spec.rb index 292f1c395f5..8a0a2d38187 100644 --- a/spec/serializers/merge_request_widget_entity_spec.rb +++ b/spec/serializers/merge_request_widget_entity_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe MergeRequestWidgetEntity do +RSpec.describe MergeRequestWidgetEntity, feature_category: :code_review_workflow do include ProjectForksHelper include Gitlab::Routing.url_helpers diff --git a/spec/serializers/note_entity_spec.rb b/spec/serializers/note_entity_spec.rb index bbb1d2ca164..d5c4a31a937 100644 --- a/spec/serializers/note_entity_spec.rb +++ b/spec/serializers/note_entity_spec.rb @@ -59,22 +59,11 @@ RSpec.describe NoteEntity do subject { entity.as_json[:external_author] } - context 'when external_note_author_service_desk feature flag is enabled' do + context 'with external note author' do let(:obfuscated_email) { 'em*****@e*****.c**' } let(:email) { 'email@example.com' } it_behaves_like 'external author' end - - context 'when external_note_author_service_desk feature flag is disabled' do - let(:email) { nil } - let(:obfuscated_email) { nil } - - before do - stub_feature_flags(external_note_author_service_desk: false) - end - - it_behaves_like 'external author' - end end end diff --git a/spec/serializers/profile/event_entity_spec.rb b/spec/serializers/profile/event_entity_spec.rb index 1551fc76466..dbd748d3b11 100644 --- a/spec/serializers/profile/event_entity_spec.rb +++ b/spec/serializers/profile/event_entity_spec.rb @@ -7,6 +7,7 @@ RSpec.describe Profile::EventEntity, feature_category: :user_profile do let_it_be(:project) { build(:project_empty_repo, group: group) } let_it_be(:user) { create(:user) } # rubocop:disable RSpec/FactoryBot/AvoidCreate let_it_be(:merge_request) { create(:merge_request, source_project: project, target_project: project) } # rubocop:disable RSpec/FactoryBot/AvoidCreate + let_it_be(:note) { build(:note_on_merge_request, noteable: merge_request, project: project) } let(:target_user) { user } let(:event) { build(:event, :merged, author: user, project: project, target: merge_request) } @@ -24,7 +25,7 @@ RSpec.describe Profile::EventEntity, feature_category: :user_profile do expect(subject[:action]).to eq(event.action) expect(subject[:author][:id]).to eq(target_user.id) expect(subject[:author][:name]).to eq(target_user.name) - expect(subject[:author][:path]).to eq(target_user.username) + expect(subject[:author][:username]).to eq(target_user.username) end context 'for push events' do @@ -39,6 +40,8 @@ RSpec.describe Profile::EventEntity, feature_category: :user_profile do expect(subject[:ref][:count]).to eq(event.ref_count) expect(subject[:ref][:name]).to eq(event.ref_name) expect(subject[:ref][:path]).to be_nil + expect(subject[:ref][:is_new]).to be false + expect(subject[:ref][:is_removed]).to be false end shared_examples 'returns ref path' do @@ -90,19 +93,26 @@ RSpec.describe Profile::EventEntity, feature_category: :user_profile do end end - context 'with target' do - let_it_be(:note) { build(:note_on_merge_request, :with_attachment, noteable: merge_request, project: project) } + context 'for noteable events' do + let(:event) { build(:event, :commented, project: project, target: note, author: target_user) } + + it 'exposes noteable fields' do + expect(subject[:noteable][:type]).to eq(note.noteable_type) + expect(subject[:noteable][:reference_link_text]).to eq(note.noteable.reference_link_text) + expect(subject[:noteable][:web_url]).to be_present + expect(subject[:noteable][:first_line_in_markdown]).to be_present + end + end + context 'with target' do context 'when target does not responds to :reference_link_text' do let(:event) { build(:event, :commented, project: project, target: note, author: target_user) } it 'exposes target fields' do expect(subject[:target]).not_to include(:reference_link_text) - expect(subject[:target][:target_type]).to eq(note.class.to_s) - expect(subject[:target][:target_url]).to be_present + expect(subject[:target][:type]).to eq(note.class.to_s) + expect(subject[:target][:web_url]).to be_present expect(subject[:target][:title]).to eq(note.title) - expect(subject[:target][:first_line_in_markdown]).to be_present - expect(subject[:target][:attachment][:url]).to eq(note.attachment.url) end end @@ -111,6 +121,25 @@ RSpec.describe Profile::EventEntity, feature_category: :user_profile do expect(subject[:target][:reference_link_text]).to eq(merge_request.reference_link_text) end end + + context 'when target is a wiki page' do + let(:event) { build(:wiki_page_event, :created, project: project, author: target_user) } + + it 'exposes web_url' do + expect(subject[:target][:web_url]).to be_present + end + end + + context 'when target is a work item' do + let(:incident) { create(:work_item, :incident, author: target_user, project: project) } # rubocop:disable RSpec/FactoryBot/AvoidCreate + let(:event) do + build(:event, :created, :for_work_item, author: target_user, project: project, target: incident) + end + + it 'exposes `issue_type`' do + expect(subject[:target][:issue_type]).to eq('incident') + end + end end context 'with resource parent' do @@ -134,7 +163,7 @@ RSpec.describe Profile::EventEntity, feature_category: :user_profile do expect(subject[:action]).to eq('private') expect(subject[:author][:id]).to eq(target_user.id) expect(subject[:author][:name]).to eq(target_user.name) - expect(subject[:author][:path]).to eq(target_user.username) + expect(subject[:author][:username]).to eq(target_user.username) is_expected.not_to include(:ref, :commit, :target, :resource_parent) end |