diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-24 18:08:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-24 18:08:50 +0300 |
commit | 4c5468b40825debc2b7bbe08b975dedd2f7f1523 (patch) | |
tree | ee64e91b6d014f452e9c9dce6ad9f747a5929108 /spec/requests | |
parent | d081e00aa79079792b040af3323883f1f43830c5 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/api/graphql/group/milestones_spec.rb | 102 | ||||
-rw-r--r-- | spec/requests/api/runner_spec.rb | 2 |
2 files changed, 95 insertions, 9 deletions
diff --git a/spec/requests/api/graphql/group/milestones_spec.rb b/spec/requests/api/graphql/group/milestones_spec.rb index e85adeb4690..1c884335da1 100644 --- a/spec/requests/api/graphql/group/milestones_spec.rb +++ b/spec/requests/api/graphql/group/milestones_spec.rb @@ -7,16 +7,17 @@ RSpec.describe 'Milestones through GroupQuery' do let_it_be(:user) { create(:user) } let_it_be(:now) { Time.now } - let_it_be(:group) { create(:group) } - let_it_be(:milestone_1) { create(:milestone, group: group) } - let_it_be(:milestone_2) { create(:milestone, group: group, state: :closed, start_date: now, due_date: now + 1.day) } - let_it_be(:milestone_3) { create(:milestone, group: group, start_date: now, due_date: now + 2.days) } - let_it_be(:milestone_4) { create(:milestone, group: group, state: :closed, start_date: now - 2.days, due_date: now - 1.day) } - let_it_be(:milestone_from_other_group) { create(:milestone, group: create(:group)) } - - let(:milestone_data) { graphql_data['group']['milestones']['edges'] } describe 'Get list of milestones from a group' do + let_it_be(:group) { create(:group) } + let_it_be(:milestone_1) { create(:milestone, group: group) } + let_it_be(:milestone_2) { create(:milestone, group: group, state: :closed, start_date: now, due_date: now + 1.day) } + let_it_be(:milestone_3) { create(:milestone, group: group, start_date: now, due_date: now + 2.days) } + let_it_be(:milestone_4) { create(:milestone, group: group, state: :closed, start_date: now - 2.days, due_date: now - 1.day) } + let_it_be(:milestone_from_other_group) { create(:milestone, group: create(:group)) } + + let(:milestone_data) { graphql_data['group']['milestones']['edges'] } + context 'when the request is correct' do before do fetch_milestones(user) @@ -120,4 +121,89 @@ RSpec.describe 'Milestones through GroupQuery' do node_array(milestone_data, extract_attribute) end end + + describe 'ensures each field returns the correct value' do + let_it_be(:group) { create(:group) } + let_it_be(:project) { create(:project, group: group) } + let_it_be(:milestone) { create(:milestone, group: group, start_date: now, due_date: now + 1.day) } + let_it_be(:open_issue) { create(:issue, project: project, milestone: milestone) } + let_it_be(:closed_issue) { create(:issue, :closed, project: project, milestone: milestone) } + + let(:milestone_query) do + %{ + id + title + description + state + webPath + dueDate + startDate + createdAt + updatedAt + projectMilestone + groupMilestone + subgroupMilestone + } + end + + def post_query + full_query = graphql_query_for("group", + { full_path: group.full_path }, + [query_graphql_field("milestones", nil, "nodes { #{milestone_query} }")] + ) + + post_graphql(full_query, current_user: user) + + graphql_data.dig('group', 'milestones', 'nodes', 0) + end + + it 'returns correct values for scalar fields' do + expect(post_query).to eq({ + 'id' => global_id_of(milestone), + 'title' => milestone.title, + 'description' => milestone.description, + 'state' => 'active', + 'webPath' => milestone_path(milestone), + 'dueDate' => milestone.due_date.iso8601, + 'startDate' => milestone.start_date.iso8601, + 'createdAt' => milestone.created_at.iso8601, + 'updatedAt' => milestone.updated_at.iso8601, + 'projectMilestone' => false, + 'groupMilestone' => true, + 'subgroupMilestone' => false + }) + end + + context 'milestone statistics' do + let(:milestone_query) do + %{ + stats { + totalIssuesCount + closedIssuesCount + } + } + end + + it 'returns the correct milestone statistics' do + expect(post_query).to eq({ + 'stats' => { + 'totalIssuesCount' => 2, + 'closedIssuesCount' => 1 + } + }) + end + + context 'when the graphql_milestone_stats feature flag is disabled' do + before do + stub_feature_flags(graphql_milestone_stats: false) + end + + it 'returns nil for the stats field' do + expect(post_query).to eq({ + 'stats' => nil + }) + end + end + end + end end diff --git a/spec/requests/api/runner_spec.rb b/spec/requests/api/runner_spec.rb index c7d068a1a78..c977908149c 100644 --- a/spec/requests/api/runner_spec.rb +++ b/spec/requests/api/runner_spec.rb @@ -668,7 +668,7 @@ RSpec.describe API::Runner, :clean_gitlab_redis_shared_state do { "name" => "release", "script" => - ["release-cli create --ref \"$CI_COMMIT_SHA\" --name \"Release $CI_COMMIT_SHA\" --tag-name \"release-$CI_COMMIT_SHA\" --description \"Created using the release-cli $EXTRA_DESCRIPTION\""], + ["release-cli create --name \"Release $CI_COMMIT_SHA\" --description \"Created using the release-cli $EXTRA_DESCRIPTION\" --tag-name \"release-$CI_COMMIT_SHA\" --ref \"$CI_COMMIT_SHA\""], "timeout" => 3600, "when" => "on_success", "allow_failure" => false |