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

achievement_type_spec.rb « achievements « types « graphql « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f967dc8e25e6e9f25c8d9ab96b4061cbee5f3c95 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe GitlabSchema.types['Achievement'], feature_category: :user_profile do
  include GraphqlHelpers

  let(:fields) do
    %w[
      id
      namespace
      name
      avatar_url
      description
      created_at
      updated_at
    ]
  end

  it { expect(described_class.graphql_name).to eq('Achievement') }
  it { expect(described_class).to have_graphql_fields(fields) }
  it { expect(described_class).to require_graphql_authorizations(:read_achievement) }

  describe '#avatar_url' do
    let(:object) { instance_double(Achievements::Achievement) }
    let(:current_user) { instance_double(User) }

    before do
      allow(described_class).to receive(:authorized?).and_return(true)
    end

    it 'calls Achievement#avatar_url(only_path: false)' do
      allow(object).to receive(:avatar_url).with(only_path: false)
      resolve_field(:avatar_url, object, current_user: current_user)
      expect(object).to have_received(:avatar_url).with(only_path: false).once
    end
  end
end