Welcome to mirror list, hosted at ThFree Co, Russian Federation.

abuse_report_entity_spec.rb « admin « serializers « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e84cfe73b96b7dcdacbe1bc95ba0126e31d3139b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# frozen_string_literal: true

require "spec_helper"

RSpec.describe Admin::AbuseReportEntity, feature_category: :insider_threat do
  include Gitlab::Routing

  let(:abuse_report) { build_stubbed(:abuse_report) }

  let(:entity) do
    described_class.new(abuse_report)
  end

  describe '#as_json' do
    subject(:entity_hash) { entity.as_json }

    it 'exposes correct attributes' do
      expect(entity_hash.keys).to match_array([
        :category,
        :created_at,
        :updated_at,
        :count,
        :labels,
        :reported_user,
        :reporter,
        :report_path
      ])
    end

    it 'correctly exposes `reported user`' do
      expect(entity_hash[:reported_user].keys).to match_array([:name])
    end

    it 'correctly exposes `reporter`' do
      expect(entity_hash[:reporter].keys).to match_array([:name])
    end

    it 'correctly exposes :report_path' do
      expect(entity_hash[:report_path]).to eq admin_abuse_report_path(abuse_report)
    end

    context 'when abuse_report_labels feature flag is disabled' do
      before do
        stub_feature_flags(abuse_report_labels: false)
      end

      it 'does not expose labels' do
        expect(entity_hash.keys).not_to include(:labels)
      end
    end
  end
end