2019-12-21 20:55:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe Projects::IssuesController, '(JavaScript fixtures)', type: :controller do
|
2017-08-17 22:00:37 +05:30
|
|
|
include JavaScriptFixturesHelpers
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
let(:user) { create(:user, feed_token: 'feedtoken:coldfeed') }
|
2022-10-11 01:57:18 +05:30
|
|
|
let(:namespace) { create(:namespace, name: 'frontend-fixtures' ) }
|
2017-08-17 22:00:37 +05:30
|
|
|
let(:project) { create(:project_empty_repo, namespace: namespace, path: 'issues-project') }
|
|
|
|
|
|
|
|
render_views
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
before do
|
2021-02-22 17:27:13 +05:30
|
|
|
project.add_maintainer(user)
|
|
|
|
sign_in(user)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
after do
|
|
|
|
remove_repository(project)
|
|
|
|
end
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
it 'issues/new-issue.html' do
|
|
|
|
get :new, params: {
|
|
|
|
namespace_id: project.namespace.to_param,
|
|
|
|
project_id: project
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(response).to be_successful
|
|
|
|
end
|
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
it 'issues/open-issue.html' do
|
|
|
|
render_issue(create(:issue, project: project))
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
it 'issues/closed-issue.html' do
|
|
|
|
render_issue(create(:closed_issue, project: project))
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
def render_issue(issue)
|
2019-02-15 15:39:39 +05:30
|
|
|
get :show, params: {
|
2017-08-17 22:00:37 +05:30
|
|
|
namespace_id: project.namespace.to_param,
|
|
|
|
project_id: project,
|
|
|
|
id: issue.to_param
|
2019-02-15 15:39:39 +05:30
|
|
|
}
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2019-10-12 21:52:04 +05:30
|
|
|
expect(response).to be_successful
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
2019-07-07 11:18:12 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe API::Issues, '(JavaScript fixtures)', type: :request do
|
2019-07-07 11:18:12 +05:30
|
|
|
include ApiHelpers
|
|
|
|
include JavaScriptFixturesHelpers
|
|
|
|
|
|
|
|
def get_related_merge_requests(project_id, issue_iid, user = nil)
|
|
|
|
get api("/projects/#{project_id}/issues/#{issue_iid}/related_merge_requests", user)
|
|
|
|
end
|
|
|
|
|
|
|
|
def create_referencing_mr(user, project, issue)
|
|
|
|
attributes = {
|
|
|
|
author: user,
|
|
|
|
source_project: project,
|
|
|
|
target_project: project,
|
|
|
|
source_branch: "master",
|
|
|
|
target_branch: "test",
|
|
|
|
assignee: user,
|
|
|
|
description: "See #{issue.to_reference}"
|
|
|
|
}
|
|
|
|
create(:merge_request, attributes).tap do |merge_request|
|
|
|
|
create(:note, :system, project: issue.project, noteable: issue, author: user, note: merge_request.to_reference(full: true))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
it 'issues/related_merge_requests.json' do
|
2019-07-07 11:18:12 +05:30
|
|
|
user = create(:user)
|
|
|
|
project = create(:project, :public, creator_id: user.id, namespace: user.namespace)
|
|
|
|
issue_title = 'foo'
|
|
|
|
issue_description = 'closed'
|
|
|
|
milestone = create(:milestone, title: '1.0.0', project: project)
|
|
|
|
issue = create :issue,
|
|
|
|
author: user,
|
|
|
|
assignees: [user],
|
|
|
|
project: project,
|
|
|
|
milestone: milestone,
|
|
|
|
created_at: generate(:past_time),
|
|
|
|
updated_at: 1.hour.ago,
|
|
|
|
title: issue_title,
|
|
|
|
description: issue_description
|
|
|
|
|
|
|
|
project.add_reporter(user)
|
|
|
|
create_referencing_mr(user, project, issue)
|
|
|
|
|
|
|
|
create(:merge_request,
|
|
|
|
:simple,
|
|
|
|
author: user,
|
|
|
|
source_project: project,
|
|
|
|
target_project: project,
|
|
|
|
description: "Some description")
|
|
|
|
project2 = create(:project, :public, creator_id: user.id, namespace: user.namespace)
|
|
|
|
create_referencing_mr(user, project2, issue).update!(head_pipeline: create(:ci_pipeline))
|
|
|
|
|
|
|
|
get_related_merge_requests(project.id, issue.iid, user)
|
|
|
|
|
2019-10-12 21:52:04 +05:30
|
|
|
expect(response).to be_successful
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|
|
|
|
end
|
2022-08-27 11:52:29 +05:30
|
|
|
|
|
|
|
RSpec.describe GraphQL::Query, type: :request do
|
|
|
|
include ApiHelpers
|
|
|
|
include GraphqlHelpers
|
|
|
|
include JavaScriptFixturesHelpers
|
|
|
|
|
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
let_it_be(:project) { create(:project) }
|
|
|
|
let_it_be(:issue_type) { 'issue' }
|
|
|
|
|
|
|
|
before_all do
|
|
|
|
project.add_reporter(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
issue_popover_query_path = 'issuable/popover/queries/issue.query.graphql'
|
|
|
|
|
|
|
|
it "graphql/#{issue_popover_query_path}.json" do
|
|
|
|
query = get_graphql_query_as_string(issue_popover_query_path, ee: Gitlab.ee?)
|
|
|
|
|
|
|
|
issue = create(
|
|
|
|
:issue,
|
|
|
|
project: project,
|
|
|
|
confidential: true,
|
|
|
|
created_at: Time.parse('2020-07-01T04:08:01Z'),
|
|
|
|
due_date: Date.new(2020, 7, 5),
|
|
|
|
milestone: create(
|
|
|
|
:milestone,
|
|
|
|
project: project,
|
|
|
|
title: '15.2',
|
|
|
|
start_date: Date.new(2020, 7, 1),
|
|
|
|
due_date: Date.new(2020, 7, 30)
|
|
|
|
),
|
|
|
|
issue_type: issue_type
|
|
|
|
)
|
|
|
|
|
|
|
|
post_graphql(query, current_user: user, variables: { projectPath: project.full_path, iid: issue.iid.to_s })
|
|
|
|
|
|
|
|
expect_graphql_errors_to_be_empty
|
|
|
|
end
|
|
|
|
end
|