2019-10-17 02:07:30 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-29 12:18:59 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe Projects::IssuesController, '(JavaScript fixtures)', type: :controller do
|
2016-08-29 12:18:59 -04:00
|
|
|
include JavaScriptFixturesHelpers
|
|
|
|
|
2020-12-07 07:10:00 -05:00
|
|
|
let(:user) { create(:user, feed_token: 'feedtoken:coldfeed') }
|
2016-11-19 18:40:37 -05:00
|
|
|
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
|
|
|
|
let(:project) { create(:project_empty_repo, namespace: namespace, path: 'issues-project') }
|
2016-08-29 12:18:59 -04:00
|
|
|
|
|
|
|
render_views
|
|
|
|
|
|
|
|
before(:all) do
|
|
|
|
clean_frontend_fixtures('issues/')
|
|
|
|
end
|
|
|
|
|
2017-08-10 18:31:42 -04:00
|
|
|
before do
|
2020-12-07 07:10:00 -05:00
|
|
|
project.add_maintainer(user)
|
|
|
|
sign_in(user)
|
2016-08-29 12:18:59 -04:00
|
|
|
end
|
|
|
|
|
2017-08-22 19:19:35 -04:00
|
|
|
after do
|
|
|
|
remove_repository(project)
|
|
|
|
end
|
|
|
|
|
2019-12-31 13:09:10 -05:00
|
|
|
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-04-21 06:58:07 -04:00
|
|
|
it 'issues/open-issue.html' do
|
2019-04-23 06:21:36 -04:00
|
|
|
render_issue(create(:issue, project: project))
|
2016-08-29 12:18:59 -04:00
|
|
|
end
|
|
|
|
|
2019-04-21 06:58:07 -04:00
|
|
|
it 'issues/closed-issue.html' do
|
2019-04-23 06:21:36 -04:00
|
|
|
render_issue(create(:closed_issue, project: project))
|
2016-08-29 12:18:59 -04:00
|
|
|
end
|
|
|
|
|
2019-04-21 06:58:07 -04:00
|
|
|
it 'issues/issue_list.html' do
|
2017-05-22 07:27:08 -04:00
|
|
|
create(:issue, project: project)
|
|
|
|
|
2018-12-19 14:50:20 -05:00
|
|
|
get :index, params: {
|
2017-05-22 07:27:08 -04:00
|
|
|
namespace_id: project.namespace.to_param,
|
|
|
|
project_id: project
|
2018-12-19 14:50:20 -05:00
|
|
|
}
|
2017-05-22 07:27:08 -04:00
|
|
|
|
2019-07-17 18:15:53 -04:00
|
|
|
expect(response).to be_successful
|
2017-05-22 07:27:08 -04:00
|
|
|
end
|
|
|
|
|
2016-08-29 12:18:59 -04:00
|
|
|
private
|
|
|
|
|
2019-04-23 06:21:36 -04:00
|
|
|
def render_issue(issue)
|
2018-12-19 14:50:20 -05:00
|
|
|
get :show, params: {
|
2016-08-29 12:18:59 -04:00
|
|
|
namespace_id: project.namespace.to_param,
|
2017-02-23 18:55:01 -05:00
|
|
|
project_id: project,
|
2016-08-29 12:18:59 -04:00
|
|
|
id: issue.to_param
|
2018-12-19 14:50:20 -05:00
|
|
|
}
|
2016-08-29 12:18:59 -04:00
|
|
|
|
2019-07-17 18:15:53 -04:00
|
|
|
expect(response).to be_successful
|
2016-08-29 12:18:59 -04:00
|
|
|
end
|
|
|
|
end
|
2019-04-04 20:15:56 -04:00
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe API::Issues, '(JavaScript fixtures)', type: :request do
|
2019-04-04 20:15:56 -04:00
|
|
|
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-04-21 06:58:07 -04:00
|
|
|
it 'issues/related_merge_requests.json' do
|
2019-04-04 20:15:56 -04:00
|
|
|
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-07-17 18:15:53 -04:00
|
|
|
expect(response).to be_successful
|
2019-04-04 20:15:56 -04:00
|
|
|
end
|
|
|
|
end
|