Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-08-20 21:42:06 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-20 21:42:06 +0300
commit6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch)
tree78be5963ec075d80116a932011d695dd33910b4e /spec/services/notes/quick_actions_service_spec.rb
parent1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff)
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/services/notes/quick_actions_service_spec.rb')
-rw-r--r--spec/services/notes/quick_actions_service_spec.rb27
1 files changed, 21 insertions, 6 deletions
diff --git a/spec/services/notes/quick_actions_service_spec.rb b/spec/services/notes/quick_actions_service_spec.rb
index d20824efaaa..e9decd44730 100644
--- a/spec/services/notes/quick_actions_service_spec.rb
+++ b/spec/services/notes/quick_actions_service_spec.rb
@@ -58,14 +58,29 @@ RSpec.describe Notes::QuickActionsService do
end
describe '/spend' do
- let(:note_text) { '/spend 1h' }
+ context 'when note is not persisted' do
+ let(:note_text) { '/spend 1h' }
- it 'updates the spent time on the noteable' do
- content, update_params = service.execute(note)
- service.apply_updates(update_params, note)
+ it 'adds time to noteable, adds timelog with nil note_id and has no content' do
+ content, update_params = service.execute(note)
+ service.apply_updates(update_params, note)
- expect(content).to eq ''
- expect(note.noteable.time_spent).to eq(3600)
+ expect(content).to eq ''
+ expect(note.noteable.time_spent).to eq(3600)
+ expect(Timelog.last.note_id).to be_nil
+ end
+ end
+
+ context 'when note is persisted' do
+ let(:note_text) { "a note \n/spend 1h" }
+
+ it 'updates the spent time and populates timelog with note_id' do
+ new_content, update_params = service.execute(note)
+ note.update!(note: new_content)
+ service.apply_updates(update_params, note)
+
+ expect(Timelog.last.note_id).to eq(note.id)
+ end
end
end
end