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

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

RSpec.shared_examples 'create todo mutation' do
  let_it_be(:current_user) { create(:user) }

  let(:mutation) { described_class.new(object: nil, context: { current_user: current_user }, field: nil) }

  context 'when user does not have permission to create todo' do
    it 'raises error' do
      expect { mutation.resolve(target_id: global_id_of(target)) }
        .to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable)
    end
  end

  context 'when user has permission to create todo' do
    it 'creates a todo' do
      target.resource_parent.add_reporter(current_user)

      result = mutation.resolve(target_id: global_id_of(target))

      expect(result[:todo]).to be_valid
      expect(result[:todo].target).to eq(target)
      expect(result[:todo].state).to eq('pending')
    end
  end
end