diff options
author | Jacopo <beschi.jacopo@gmail.com> | 2018-05-08 18:00:51 +0300 |
---|---|---|
committer | Jacopo <beschi.jacopo@gmail.com> | 2018-05-09 19:08:37 +0300 |
commit | 890dc39ee0c92adb10a3221c2a564533e038a72c (patch) | |
tree | c4f2e00d6c6786f0369597e6a586dd6f295edc37 /spec/support/api | |
parent | 533593e95cd3a922a2ec2ea43b345862361dfd67 (diff) |
Updates updated_at on issue when using /spend quick action
Diffstat (limited to 'spec/support/api')
-rw-r--r-- | spec/support/api/time_tracking_shared_examples.rb | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/spec/support/api/time_tracking_shared_examples.rb b/spec/support/api/time_tracking_shared_examples.rb index dd3089d22e5..52e1bc55191 100644 --- a/spec/support/api/time_tracking_shared_examples.rb +++ b/spec/support/api/time_tracking_shared_examples.rb @@ -70,8 +70,12 @@ shared_examples 'time tracking endpoints' do |issuable_name| end it "add spent time for #{issuable_name}" do - post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/add_spent_time", user), - duration: '2h' + Timecop.travel(1.minute.from_now) do + expect do + post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/add_spent_time", user), + duration: '2h' + end.to change { issuable.reload.updated_at } + end expect(response).to have_gitlab_http_status(201) expect(json_response['human_total_time_spent']).to eq('2h') @@ -79,7 +83,11 @@ shared_examples 'time tracking endpoints' do |issuable_name| context 'when subtracting time' do it 'subtracts time of the total spent time' do - issuable.update_attributes!(spend_time: { duration: 7200, user_id: user.id }) + Timecop.travel(1.minute.from_now) do + expect do + issuable.update_attributes!(spend_time: { duration: 7200, user_id: user.id }) + end.to change { issuable.reload.updated_at } + end post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/add_spent_time", user), duration: '-1h' @@ -93,8 +101,12 @@ shared_examples 'time tracking endpoints' do |issuable_name| it 'does not modify the total time spent' do issuable.update_attributes!(spend_time: { duration: 7200, user_id: user.id }) - post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/add_spent_time", user), - duration: '-1w' + Timecop.travel(1.minute.from_now) do + expect do + post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/add_spent_time", user), + duration: '-1w' + end.not_to change { issuable.reload.updated_at } + end expect(response).to have_gitlab_http_status(400) expect(json_response['message']['time_spent'].first).to match(/exceeds the total time spent/) @@ -110,7 +122,11 @@ shared_examples 'time tracking endpoints' do |issuable_name| end it "resets spent time for #{issuable_name}" do - post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/reset_spent_time", user) + Timecop.travel(1.minute.from_now) do + expect do + post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/reset_spent_time", user) + end.to change { issuable.reload.updated_at } + end expect(response).to have_gitlab_http_status(200) expect(json_response['total_time_spent']).to eq(0) |