Commit 69d6ac52 authored by Igor Drozdov's avatar Igor Drozdov

Merge branch 'tidy_put_projects_issues_spec' into 'master'

Tidy `spec/requests/api/issues/put_projects_issues_spec.rb`

Closes #218597

See merge request gitlab-org/gitlab!32759
parents 1998e450 4138f42b
---
title: Tidy
merge_request: 32759
author: Lee Tickett
type: other
...@@ -5,10 +5,6 @@ require 'spec_helper' ...@@ -5,10 +5,6 @@ require 'spec_helper'
describe API::Issues do describe API::Issues do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:owner) { create(:owner) } let_it_be(:owner) { create(:owner) }
let_it_be(:project, reload: true) do
create(:project, :public, creator_id: owner.id, namespace: owner.namespace)
end
let(:user2) { create(:user) } let(:user2) { create(:user) }
let(:non_member) { create(:user) } let(:non_member) { create(:user) }
let_it_be(:guest) { create(:user) } let_it_be(:guest) { create(:user) }
...@@ -17,6 +13,11 @@ describe API::Issues do ...@@ -17,6 +13,11 @@ describe API::Issues do
let(:admin) { create(:user, :admin) } let(:admin) { create(:user, :admin) }
let(:issue_title) { 'foo' } let(:issue_title) { 'foo' }
let(:issue_description) { 'closed' } let(:issue_description) { 'closed' }
let_it_be(:project, reload: true) do
create(:project, :public, creator_id: owner.id, namespace: owner.namespace)
end
let!(:closed_issue) do let!(:closed_issue) do
create :closed_issue, create :closed_issue,
author: user, author: user,
...@@ -28,6 +29,7 @@ describe API::Issues do ...@@ -28,6 +29,7 @@ describe API::Issues do
updated_at: 3.hours.ago, updated_at: 3.hours.ago,
closed_at: 1.hour.ago closed_at: 1.hour.ago
end end
let!(:confidential_issue) do let!(:confidential_issue) do
create :issue, create :issue,
:confidential, :confidential,
...@@ -37,6 +39,7 @@ describe API::Issues do ...@@ -37,6 +39,7 @@ describe API::Issues do
created_at: generate(:past_time), created_at: generate(:past_time),
updated_at: 2.hours.ago updated_at: 2.hours.ago
end end
let!(:issue) do let!(:issue) do
create :issue, create :issue,
author: user, author: user,
...@@ -48,18 +51,24 @@ describe API::Issues do ...@@ -48,18 +51,24 @@ describe API::Issues do
title: issue_title, title: issue_title,
description: issue_description description: issue_description
end end
let_it_be(:label) do let_it_be(:label) do
create(:label, title: 'label', color: '#FFAABB', project: project) create(:label, title: 'label', color: '#FFAABB', project: project)
end end
let!(:label_link) { create(:label_link, label: label, target: issue) } let!(:label_link) { create(:label_link, label: label, target: issue) }
let(:milestone) { create(:milestone, title: '1.0.0', project: project) } let(:milestone) { create(:milestone, title: '1.0.0', project: project) }
let_it_be(:empty_milestone) do let_it_be(:empty_milestone) do
create(:milestone, title: '2.0.0', project: project) create(:milestone, title: '2.0.0', project: project)
end end
let!(:note) { create(:note_on_issue, author: user, project: project, noteable: issue) }
let!(:note) { create(:note_on_issue, author: user, project: project, noteable: issue) }
let(:no_milestone_title) { 'None' } let(:no_milestone_title) { 'None' }
let(:any_milestone_title) { 'Any' } let(:any_milestone_title) { 'Any' }
let(:updated_title) { 'updated title' }
let(:issue_path) { "/projects/#{project.id}/issues/#{issue.iid}" }
let(:api_for_user) { api(issue_path, user) }
before_all do before_all do
project.add_reporter(user) project.add_reporter(user)
...@@ -72,108 +81,97 @@ describe API::Issues do ...@@ -72,108 +81,97 @@ describe API::Issues do
describe 'PUT /projects/:id/issues/:issue_iid to update only title' do describe 'PUT /projects/:id/issues/:issue_iid to update only title' do
it 'updates a project issue' do it 'updates a project issue' do
put api("/projects/#{project.id}/issues/#{issue.iid}", user), put api_for_user, params: { title: updated_title }
params: { title: 'updated title' }
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['title']).to eq('updated title') expect(response).to have_gitlab_http_status(:ok)
expect(json_response['title']).to eq(updated_title)
end end
it 'returns 404 error if issue iid not found' do it 'returns 404 error if issue iid not found' do
put api("/projects/#{project.id}/issues/44444", user), put api("/projects/#{project.id}/issues/44444", user), params: { title: updated_title }
params: { title: 'updated title' }
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns 404 error if issue id is used instead of the iid' do it 'returns 404 error if issue id is used instead of the iid' do
put api("/projects/#{project.id}/issues/#{issue.id}", user), put api("/projects/#{project.id}/issues/#{issue.id}", user), params: { title: updated_title }
params: { title: 'updated title' }
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'allows special label names' do it 'allows special label names' do
put api("/projects/#{project.id}/issues/#{issue.iid}", user), put api_for_user,
params: { params: {
title: 'updated title', title: updated_title,
labels: 'label, label?, label&foo, ?, &' labels: 'label, label?, label&foo, ?, &'
} }
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['labels']).to include 'label'
expect(json_response['labels']).to include 'label?'
expect(json_response['labels']).to include 'label&foo'
expect(json_response['labels']).to include '?'
expect(json_response['labels']).to include '&'
end end
it 'allows special label names with labels param as array' do it 'allows special label names with labels param as array' do
put api("/projects/#{project.id}/issues/#{issue.iid}", user), put api_for_user,
params: { params: {
title: 'updated title', title: updated_title,
labels: ['label', 'label?', 'label&foo, ?, &'] labels: ['label', 'label?', 'label&foo, ?, &']
} }
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['labels']).to include 'label' expect(json_response['labels']).to contain_exactly('label', 'label?', 'label&foo', '?', '&')
expect(json_response['labels']).to include 'label?'
expect(json_response['labels']).to include 'label&foo'
expect(json_response['labels']).to include '?'
expect(json_response['labels']).to include '&'
end end
context 'confidential issues' do context 'confidential issues' do
let(:confidential_issue_path) { "/projects/#{project.id}/issues/#{confidential_issue.iid}" }
it 'returns 403 for non project members' do it 'returns 403 for non project members' do
put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", non_member), put api(confidential_issue_path, non_member), params: { title: updated_title }
params: { title: 'updated title' }
expect(response).to have_gitlab_http_status(:forbidden) expect(response).to have_gitlab_http_status(:forbidden)
end end
it 'returns 403 for project members with guest role' do it 'returns 403 for project members with guest role' do
put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", guest), put api(confidential_issue_path, guest), params: { title: updated_title }
params: { title: 'updated title' }
expect(response).to have_gitlab_http_status(:forbidden) expect(response).to have_gitlab_http_status(:forbidden)
end end
it 'updates a confidential issue for project members' do it 'updates a confidential issue for project members' do
put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", user), put api(confidential_issue_path, user), params: { title: updated_title }
params: { title: 'updated title' }
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['title']).to eq('updated title') expect(json_response['title']).to eq(updated_title)
end end
it 'updates a confidential issue for author' do it 'updates a confidential issue for author' do
put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", author), put api(confidential_issue_path, author), params: { title: updated_title }
params: { title: 'updated title' }
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['title']).to eq('updated title') expect(json_response['title']).to eq(updated_title)
end end
it 'updates a confidential issue for admin' do it 'updates a confidential issue for admin' do
put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", admin), put api(confidential_issue_path, admin), params: { title: updated_title }
params: { title: 'updated title' }
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['title']).to eq('updated title') expect(json_response['title']).to eq(updated_title)
end end
it 'sets an issue to confidential' do it 'sets an issue to confidential' do
put api("/projects/#{project.id}/issues/#{issue.iid}", user), put api_for_user, params: { confidential: true }
params: { confidential: true }
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['confidential']).to be_truthy expect(json_response['confidential']).to be_truthy
end end
it 'makes a confidential issue public' do it 'makes a confidential issue public' do
put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", user), put api(confidential_issue_path, user), params: { confidential: false }
params: { confidential: false }
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['confidential']).to be_falsy expect(json_response['confidential']).to be_falsy
end end
it 'does not update a confidential issue with wrong confidential flag' do it 'does not update a confidential issue with wrong confidential flag' do
put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", user), put api(confidential_issue_path, user), params: { confidential: 'foo' }
params: { confidential: 'foo' }
expect(response).to have_gitlab_http_status(:bad_request) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq('confidential is invalid') expect(json_response['error']).to eq('confidential is invalid')
...@@ -185,12 +183,12 @@ describe API::Issues do ...@@ -185,12 +183,12 @@ describe API::Issues do
include_context 'includes Spam constants' include_context 'includes Spam constants'
def update_issue def update_issue
put api("/projects/#{project.id}/issues/#{issue.iid}", user), params: params put api_for_user, params: params
end end
let(:params) do let(:params) do
{ {
title: 'updated title', title: updated_title,
description: 'content here', description: 'content here',
labels: 'label, label2' labels: 'label, label2'
} }
...@@ -224,7 +222,7 @@ describe API::Issues do ...@@ -224,7 +222,7 @@ describe API::Issues do
it 'creates a new spam log entry' do it 'creates a new spam log entry' do
expect { update_issue } expect { update_issue }
.to log_spam(title: 'updated title', description: 'content here', user_id: user.id, noteable_type: 'Issue') .to log_spam(title: updated_title, description: 'content here', user_id: user.id, noteable_type: 'Issue')
end end
end end
...@@ -241,7 +239,7 @@ describe API::Issues do ...@@ -241,7 +239,7 @@ describe API::Issues do
it 'creates a new spam log entry' do it 'creates a new spam log entry' do
expect { update_issue } expect { update_issue }
.to log_spam(title: 'updated title', description: 'content here', user_id: user.id, noteable_type: 'Issue') .to log_spam(title: updated_title, description: 'content here', user_id: user.id, noteable_type: 'Issue')
end end
end end
end end
...@@ -249,49 +247,39 @@ describe API::Issues do ...@@ -249,49 +247,39 @@ describe API::Issues do
describe 'PUT /projects/:id/issues/:issue_iid to update assignee' do describe 'PUT /projects/:id/issues/:issue_iid to update assignee' do
context 'support for deprecated assignee_id' do context 'support for deprecated assignee_id' do
it 'removes assignee' do it 'removes assignee' do
put api("/projects/#{project.id}/issues/#{issue.iid}", user), put api_for_user, params: { assignee_id: 0 }
params: { assignee_id: 0 }
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['assignee']).to be_nil expect(json_response['assignee']).to be_nil
end end
it 'updates an issue with new assignee' do it 'updates an issue with new assignee' do
put api("/projects/#{project.id}/issues/#{issue.iid}", user), put api_for_user, params: { assignee_id: user2.id }
params: { assignee_id: user2.id }
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['assignee']['name']).to eq(user2.name) expect(json_response['assignee']['name']).to eq(user2.name)
end end
end end
it 'removes assignee' do it 'removes assignee' do
put api("/projects/#{project.id}/issues/#{issue.iid}", user), put api_for_user, params: { assignee_ids: [0] }
params: { assignee_ids: [0] }
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['assignees']).to be_empty expect(json_response['assignees']).to be_empty
end end
it 'updates an issue with new assignee' do it 'updates an issue with new assignee' do
put api("/projects/#{project.id}/issues/#{issue.iid}", user), put api_for_user, params: { assignee_ids: [user2.id] }
params: { assignee_ids: [user2.id] }
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['assignees'].first['name']).to eq(user2.name) expect(json_response['assignees'].first['name']).to eq(user2.name)
end end
context 'single assignee restrictions' do context 'single assignee restrictions' do
it 'updates an issue with several assignees but only one has been applied' do it 'updates an issue with several assignees but only one has been applied' do
put api("/projects/#{project.id}/issues/#{issue.iid}", user), put api_for_user, params: { assignee_ids: [user2.id, guest.id] }
params: { assignee_ids: [user2.id, guest.id] }
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['assignees'].size).to eq(1) expect(json_response['assignees'].size).to eq(1)
end end
end end
...@@ -302,8 +290,7 @@ describe API::Issues do ...@@ -302,8 +290,7 @@ describe API::Issues do
let!(:label_link) { create(:label_link, label: label, target: issue) } let!(:label_link) { create(:label_link, label: label, target: issue) }
it 'adds relevant labels' do it 'adds relevant labels' do
put api("/projects/#{project.id}/issues/#{issue.iid}", user), put api_for_user, params: { add_labels: '1, 2' }
params: { add_labels: '1, 2' }
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['labels']).to contain_exactly(label.title, '1', '2') expect(json_response['labels']).to contain_exactly(label.title, '1', '2')
...@@ -314,16 +301,14 @@ describe API::Issues do ...@@ -314,16 +301,14 @@ describe API::Issues do
let!(:label_link2) { create(:label_link, label: label2, target: issue) } let!(:label_link2) { create(:label_link, label: label2, target: issue) }
it 'removes relevant labels' do it 'removes relevant labels' do
put api("/projects/#{project.id}/issues/#{issue.iid}", user), put api_for_user, params: { remove_labels: label2.title }
params: { remove_labels: label2.title }
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['labels']).to eq([label.title]) expect(json_response['labels']).to eq([label.title])
end end
it 'removes all labels' do it 'removes all labels' do
put api("/projects/#{project.id}/issues/#{issue.iid}", user), put api_for_user, params: { remove_labels: "#{label.title}, #{label2.title}" }
params: { remove_labels: "#{label.title}, #{label2.title}" }
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['labels']).to be_empty expect(json_response['labels']).to be_empty
...@@ -331,15 +316,15 @@ describe API::Issues do ...@@ -331,15 +316,15 @@ describe API::Issues do
end end
it 'does not update labels if not present' do it 'does not update labels if not present' do
put api("/projects/#{project.id}/issues/#{issue.iid}", user), put api_for_user, params: { title: updated_title }
params: { title: 'updated title' }
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['labels']).to eq([label.title]) expect(json_response['labels']).to eq([label.title])
end end
it 'removes all labels and touches the record' do it 'removes all labels and touches the record' do
Timecop.travel(1.minute.from_now) do Timecop.travel(1.minute.from_now) do
put api("/projects/#{project.id}/issues/#{issue.iid}", user), params: { labels: '' } put api_for_user, params: { labels: '' }
end end
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
...@@ -349,7 +334,7 @@ describe API::Issues do ...@@ -349,7 +334,7 @@ describe API::Issues do
it 'removes all labels and touches the record with labels param as array' do it 'removes all labels and touches the record with labels param as array' do
Timecop.travel(1.minute.from_now) do Timecop.travel(1.minute.from_now) do
put api("/projects/#{project.id}/issues/#{issue.iid}", user), params: { labels: [''] } put api_for_user, params: { labels: [''] }
end end
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
...@@ -359,20 +344,19 @@ describe API::Issues do ...@@ -359,20 +344,19 @@ describe API::Issues do
it 'updates labels and touches the record' do it 'updates labels and touches the record' do
Timecop.travel(1.minute.from_now) do Timecop.travel(1.minute.from_now) do
put api("/projects/#{project.id}/issues/#{issue.iid}", user), put api_for_user, params: { labels: 'foo,bar' }
params: { labels: 'foo,bar' }
end end
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['labels']).to include 'foo' expect(json_response['labels']).to contain_exactly('foo', 'bar')
expect(json_response['labels']).to include 'bar'
expect(json_response['updated_at']).to be > Time.now expect(json_response['updated_at']).to be > Time.now
end end
it 'updates labels and touches the record with labels param as array' do it 'updates labels and touches the record with labels param as array' do
Timecop.travel(1.minute.from_now) do Timecop.travel(1.minute.from_now) do
put api("/projects/#{project.id}/issues/#{issue.iid}", user), put api_for_user, params: { labels: %w(foo bar) }
params: { labels: %w(foo bar) }
end end
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['labels']).to include 'foo' expect(json_response['labels']).to include 'foo'
expect(json_response['labels']).to include 'bar' expect(json_response['labels']).to include 'bar'
...@@ -380,36 +364,22 @@ describe API::Issues do ...@@ -380,36 +364,22 @@ describe API::Issues do
end end
it 'allows special label names' do it 'allows special label names' do
put api("/projects/#{project.id}/issues/#{issue.iid}", user), put api_for_user, params: { labels: 'label:foo, label-bar,label_bar,label/bar,label?bar,label&bar,?,&' }
params: { labels: 'label:foo, label-bar,label_bar,label/bar,label?bar,label&bar,?,&' }
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['labels']).to include 'label:foo' expect(json_response['labels']).to contain_exactly('label:foo', 'label-bar', 'label_bar', 'label/bar', 'label?bar', 'label&bar', '?', '&')
expect(json_response['labels']).to include 'label-bar'
expect(json_response['labels']).to include 'label_bar'
expect(json_response['labels']).to include 'label/bar'
expect(json_response['labels']).to include 'label?bar'
expect(json_response['labels']).to include 'label&bar'
expect(json_response['labels']).to include '?'
expect(json_response['labels']).to include '&'
end end
it 'allows special label names with labels param as array' do it 'allows special label names with labels param as array' do
put api("/projects/#{project.id}/issues/#{issue.iid}", user), put api_for_user, params: { labels: ['label:foo', 'label-bar', 'label_bar', 'label/bar,label?bar,label&bar,?,&'] }
params: { labels: ['label:foo', 'label-bar', 'label_bar', 'label/bar,label?bar,label&bar,?,&'] }
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['labels']).to include 'label:foo' expect(json_response['labels']).to contain_exactly('label:foo', 'label-bar', 'label_bar', 'label/bar', 'label?bar', 'label&bar', '?', '&')
expect(json_response['labels']).to include 'label-bar'
expect(json_response['labels']).to include 'label_bar'
expect(json_response['labels']).to include 'label/bar'
expect(json_response['labels']).to include 'label?bar'
expect(json_response['labels']).to include 'label&bar'
expect(json_response['labels']).to include '?'
expect(json_response['labels']).to include '&'
end end
it 'returns 400 if title is too long' do it 'returns 400 if title is too long' do
put api("/projects/#{project.id}/issues/#{issue.iid}", user), put api_for_user, params: { title: 'g' * 256 }
params: { title: 'g' * 256 }
expect(response).to have_gitlab_http_status(:bad_request) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']['title']).to eq([ expect(json_response['message']['title']).to eq([
'is too long (maximum is 255 characters)' 'is too long (maximum is 255 characters)'
...@@ -419,16 +389,15 @@ describe API::Issues do ...@@ -419,16 +389,15 @@ describe API::Issues do
describe 'PUT /projects/:id/issues/:issue_iid to update state and label' do describe 'PUT /projects/:id/issues/:issue_iid to update state and label' do
it 'updates a project issue' do it 'updates a project issue' do
put api("/projects/#{project.id}/issues/#{issue.iid}", user), put api_for_user, params: { labels: 'label2', state_event: 'close' }
params: { labels: 'label2', state_event: 'close' }
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['labels']).to include 'label2' expect(response).to have_gitlab_http_status(:ok)
expect(json_response['labels']).to contain_exactly('label2')
expect(json_response['state']).to eq 'closed' expect(json_response['state']).to eq 'closed'
end end
it 'reopens a project isssue' do it 'reopens a project isssue' do
put api("/projects/#{project.id}/issues/#{closed_issue.iid}", user), params: { state_event: 'reopen' } put api(issue_path, user), params: { state_event: 'reopen' }
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['state']).to eq 'opened' expect(json_response['state']).to eq 'opened'
...@@ -440,42 +409,41 @@ describe API::Issues do ...@@ -440,42 +409,41 @@ describe API::Issues do
it 'accepts the update date to be set' do it 'accepts the update date to be set' do
update_time = 2.weeks.ago update_time = 2.weeks.ago
put api("/projects/#{project.id}/issues/#{issue.iid}", user), put api_for_user, params: { title: 'some new title', updated_at: update_time }
params: { title: 'some new title', updated_at: update_time }
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['title']).to include 'some new title' expect(json_response['title']).to eq('some new title')
expect(Time.parse(json_response['updated_at'])).not_to be_like_time(update_time) expect(Time.parse(json_response['updated_at'])).not_to be_like_time(update_time)
end end
end end
context 'when admin or owner makes the request' do context 'when admin or owner makes the request' do
let(:api_for_owner) { api(issue_path, owner) }
it 'not allow to set null for updated_at' do it 'not allow to set null for updated_at' do
put api("/projects/#{project.id}/issues/#{issue.iid}", owner), params: { updated_at: nil } put api_for_owner, params: { updated_at: nil }
expect(response).to have_gitlab_http_status(:bad_request) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'not allow to set blank for updated_at' do it 'not allow to set blank for updated_at' do
put api("/projects/#{project.id}/issues/#{issue.iid}", owner), params: { updated_at: '' } put api_for_owner, params: { updated_at: '' }
expect(response).to have_gitlab_http_status(:bad_request) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'not allow to set invalid format for updated_at' do it 'not allow to set invalid format for updated_at' do
put api("/projects/#{project.id}/issues/#{issue.iid}", owner), params: { updated_at: 'invalid-format' } put api_for_owner, params: { updated_at: 'invalid-format' }
expect(response).to have_gitlab_http_status(:bad_request) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'accepts the update date to be set' do it 'accepts the update date to be set' do
update_time = 2.weeks.ago update_time = 2.weeks.ago
put api("/projects/#{project.id}/issues/#{issue.iid}", owner), put api_for_owner, params: { title: 'some new title', updated_at: update_time }
params: { title: 'some new title', updated_at: update_time }
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['title']).to include 'some new title' expect(json_response['title']).to eq('some new title')
expect(Time.parse(json_response['updated_at'])).to be_like_time(update_time) expect(Time.parse(json_response['updated_at'])).to be_like_time(update_time)
end end
end end
...@@ -485,7 +453,7 @@ describe API::Issues do ...@@ -485,7 +453,7 @@ describe API::Issues do
it 'creates a new project issue' do it 'creates a new project issue' do
due_date = 2.weeks.from_now.strftime('%Y-%m-%d') due_date = 2.weeks.from_now.strftime('%Y-%m-%d')
put api("/projects/#{project.id}/issues/#{issue.iid}", user), params: { due_date: due_date } put api_for_user, params: { due_date: due_date }
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['due_date']).to eq(due_date) expect(json_response['due_date']).to eq(due_date)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment