debian-mirror-gitlab/spec/graphql/resolvers/achievements/achievements_resolver_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

45 lines
1.2 KiB
Ruby
Raw Normal View History

2023-05-27 22:25:52 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Resolvers::Achievements::AchievementsResolver, feature_category: :user_profile do
include GraphqlHelpers
let_it_be(:group) { create(:group, :public) }
2023-06-20 00:43:36 +05:30
let_it_be(:achievements) { create_list(:achievement, 3, namespace: group) }
let(:args) { {} }
2023-05-27 22:25:52 +05:30
specify do
expect(described_class).to have_nullable_graphql_type(Types::Achievements::AchievementType.connection_type)
end
describe '#resolve' do
2023-06-20 00:43:36 +05:30
it 'returns all achievements' do
expect(resolve_achievements.items).to match_array(achievements)
end
context 'with ids argument' do
let(:args) { { ids: [achievements[0].to_global_id, achievements[1].to_global_id] } }
it 'returns the specified achievement' do
expect(resolve_achievements.items).to contain_exactly(achievements[0], achievements[1])
end
2023-05-27 22:25:52 +05:30
end
context 'when `achievements` feature flag is diabled' do
before do
stub_feature_flags(achievements: false)
end
it 'is empty' do
expect(resolve_achievements).to be_empty
end
end
end
def resolve_achievements
2023-06-20 00:43:36 +05:30
resolve(described_class, args: args, obj: group)
2023-05-27 22:25:52 +05:30
end
end