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

abuse_reports_helper_spec.rb « admin « helpers « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 496b7361b6e82c026c3d6a89377ca612f3347ff0 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Admin::AbuseReportsHelper, feature_category: :insider_threat do
  describe '#abuse_reports_list_data' do
    let!(:report) { create(:abuse_report) } # rubocop:disable RSpec/FactoryBot/AvoidCreate
    let(:reports) { AbuseReport.all.page(1) }
    let(:data) do
      data = helper.abuse_reports_list_data(reports)[:abuse_reports_data]
      Gitlab::Json.parse(data)
    end

    it 'has expected attributes', :aggregate_failures do
      expect(data['pagination']).to include(
        "current_page" => 1,
        "per_page" => 20,
        "total_items" => 1
      )
      expect(data['reports'].first).to include("category", "updated_at", "reported_user", "reporter")
      expect(data['categories']).to match_array(AbuseReport.categories.keys)
    end
  end

  describe '#abuse_report_data' do
    let(:report) { build_stubbed(:abuse_report) }

    subject(:data) { helper.abuse_report_data(report)[:abuse_report_data] }

    it 'has the expected attributes' do
      expect(data).to include('user', 'reporter', 'report', 'actions')
    end
  end
end