summaryrefslogtreecommitdiff
path: root/spec/support/taskable_shared_examples.rb
diff options
context:
space:
mode:
authorMarin Jankovski <maxlazio@gmail.com>2014-10-06 17:29:06 +0200
committerMarin Jankovski <maxlazio@gmail.com>2014-10-06 17:29:06 +0200
commit0fed1b587630ff98808c61881511ee7c077c3db6 (patch)
tree8b164d6ac47fb33157952094184eb2f529a41a0c /spec/support/taskable_shared_examples.rb
parent0c291f35f5324d159155d16aa632fad412a2d3a3 (diff)
parent31bc42de57b3cfd7bf068df06d15372307b8661b (diff)
downloadgitlab-ce-0fed1b587630ff98808c61881511ee7c077c3db6.tar.gz
Merge pull request #7964 from mr-vinn/task-lists
Add task lists to issues and merge requests
Diffstat (limited to 'spec/support/taskable_shared_examples.rb')
-rw-r--r--spec/support/taskable_shared_examples.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/support/taskable_shared_examples.rb b/spec/support/taskable_shared_examples.rb
new file mode 100644
index 00000000000..42252675683
--- /dev/null
+++ b/spec/support/taskable_shared_examples.rb
@@ -0,0 +1,42 @@
+# Specs for task state functionality for issues and merge requests.
+#
+# Requires a context containing:
+# let(:subject) { Issue or MergeRequest }
+shared_examples 'a Taskable' do
+ before do
+ subject.description = <<EOT.gsub(/ {6}/, '')
+ * [ ] Task 1
+ * [x] Task 2
+ * [x] Task 3
+ * [ ] Task 4
+ * [ ] Task 5
+EOT
+ end
+
+ it 'updates the Nth task correctly' do
+ subject.update_nth_task(1, true)
+ expect(subject.description).to match(/\[x\] Task 1/)
+
+ subject.update_nth_task(2, true)
+ expect(subject.description).to match('\[x\] Task 2')
+
+ subject.update_nth_task(3, false)
+ expect(subject.description).to match('\[ \] Task 3')
+
+ subject.update_nth_task(4, false)
+ expect(subject.description).to match('\[ \] Task 4')
+ end
+
+ it 'returns the correct task status' do
+ expect(subject.task_status).to match('5 tasks')
+ expect(subject.task_status).to match('2 done')
+ expect(subject.task_status).to match('3 unfinished')
+ end
+
+ it 'knows if it has tasks' do
+ expect(subject.tasks?).to be_true
+
+ subject.description = 'Now I have no tasks'
+ expect(subject.tasks?).to be_false
+ end
+end