my_todo 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 093228595b114cced5a32a36ad34238f403ed5dc
4
- data.tar.gz: 6f1c939f68f4f6249235f6520a42b038420431d6
3
+ metadata.gz: 70b1f135ecffdf6707b18aa7a916493221bce327
4
+ data.tar.gz: e8fcb736c11ac62879afdc96b33f2f98a23f3875
5
5
  SHA512:
6
- metadata.gz: cae431c8ee769fece3442cb705bc60871a6067306ee9aa48ffd323325995fa4dbb9c8f80556cbb6cfaaf81dcbfb27088dd4a3f31a182a96d2d3b07e0ccef3337
7
- data.tar.gz: fed9ceeb3af9c1043d389b878fa1a26b7174ecc88d2e2acc7713ee726cc6d6e23f93f48e6b7666ca3e11770f043e4e84ee45908f65eb67375f64222605e9e909
6
+ metadata.gz: 01ec4a1b26546905b02194a39d4ccd84f9b74defdb49046183ea9ef06cc129f9a7100148ab105d72744f05bc79b9256ae1a8a8fe1c320a9f030ce3cb7504ec68
7
+ data.tar.gz: a6887b4de5c89b24e7e56ce2910941f9824658f7f27939081f3f03412a72271510f2f712cd636087daee721c8fdd4332c073e1495607a27d719f14fdc2fd0055
data/README.md CHANGED
@@ -24,7 +24,7 @@ gem install my_todo
24
24
  ```
25
25
 
26
26
  ## setup
27
- Create and migrate the DB
27
+ Create and migrate the DB - This always needs to be run after every deployment to set the proper paths at the very least.
28
28
 
29
29
  `my_todo rake db:migrate`
30
30
 
@@ -43,10 +43,10 @@ will display
43
43
  ToDo CREATED!
44
44
 
45
45
 
46
- ID: 4
47
- ToDo: hello world
48
- Tags: default
49
- Complete: false
46
+ ID: 1 | Created On: 2016-10-04 | Tags: default | Status: In Progress | Complete: false | Notes: 0
47
+
48
+ hello world
49
+ ****************************************************************************************************
50
50
  ```
51
51
 
52
52
  Example of listing pending todos
@@ -58,13 +58,17 @@ my_todo list
58
58
  will display
59
59
 
60
60
  ```
61
- ToDos FOUND: 1
61
+ ToDos FOUND: 2
62
+
63
+ ID: 1 | Created On: 2016-10-04 | Tags: default | Status: In Progress | Complete: false | Notes: 0
64
+
65
+ hello world
66
+ ****************************************************************************************************
62
67
 
68
+ ID: 2 | Created On: 2016-10-05 | Tags: default | Status: In Progress | Complete: false | Notes: 0
63
69
 
64
- ID: 3
65
- ToDo: hello world
66
- Tags: default
67
- Complete: false
70
+ hello world 2
71
+ ****************************************************************************************************
68
72
  ```
69
73
 
70
74
  Use aliasing to shorten the syntax:
@@ -77,9 +81,10 @@ alias mupdate='my_todo update'
77
81
  alias mdelete='my_todo delete'
78
82
  alias mtag='my_todo tag'
79
83
  alias mrmtag='my_todo rm_tag'
80
- alias mnote='my_todo note'
84
+ alias mnotes='my_todo notes'
81
85
  alias mrmnote='my_todo rm_note'
82
86
  alias msearch='my_todo search'
87
+ alias mnote='my_todo note'
83
88
  ```
84
89
 
85
90
  Functions can be created around these actions to possibly shorten the syntax that much more
@@ -0,0 +1,5 @@
1
+ class AddDefaultToItemDone < ActiveRecord::Migration[5.0]
2
+ def change
3
+ change_column :items, :done, :boolean, default: false
4
+ end
5
+ end
data/lib/db/schema.rb CHANGED
@@ -10,16 +10,24 @@
10
10
  #
11
11
  # It's strongly recommended that you check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema.define(version: 20161005133023) do
13
+ ActiveRecord::Schema.define(version: 20161220143613) do
14
14
 
15
15
  create_table "items", force: :cascade do |t|
16
16
  t.string "body"
17
- t.boolean "done"
18
- t.datetime "created_at", null: false
19
- t.datetime "updated_at", null: false
17
+ t.boolean "done", default: false
18
+ t.datetime "created_at", null: false
19
+ t.datetime "updated_at", null: false
20
+ t.string "status"
20
21
  t.string "detailed_status"
21
22
  end
22
23
 
24
+ create_table "lists", force: :cascade do |t|
25
+ t.string "name"
26
+ t.string "value"
27
+ t.datetime "created_at", null: false
28
+ t.datetime "updated_at", null: false
29
+ end
30
+
23
31
  create_table "notes", force: :cascade do |t|
24
32
  t.integer "item_id"
25
33
  t.text "body"
Binary file
Binary file
@@ -1,18 +1,30 @@
1
1
  # @author Lovell McIlwain#
2
2
  # Handles business logic for todo item
3
3
  class Item < ActiveRecord::Base
4
- DETAILED_STATUSES = ['None', 'In Progress', 'Complete', 'Punted', 'Waiting Feedback']
4
+ INCOMPLETE_STATUSES = ['None', 'In Progress', 'Waiting Feedback']
5
+ COMPLETE_STATUSES = ['Complete', 'Punted']
6
+ DETAILED_STATUSES = INCOMPLETE_STATUSES + COMPLETE_STATUSES
5
7
  # ActiveRecord association to stubs
6
8
  # @note Item.first.stubs
7
9
  has_many :stubs
10
+
8
11
  # ActiveRecord association to tags
9
12
  # @note Item.first.tags
10
13
  # @note destroys associated stubs/tags when deleted
11
14
  has_many :tags, through: :stubs, dependent: :destroy
15
+
12
16
  # ActiveRecord association to notes
13
17
  # @note Item.first.notes
14
18
  # @note destroys associated notes when deleted
15
19
  has_many :notes, dependent: :destroy
20
+
16
21
  # ActiveModel validation to ensure body is present
17
22
  validates :body, presence: true
23
+
24
+ before_save :update_done
25
+
26
+ #set done attribute based on detailed_status set
27
+ def update_done
28
+ self.done = true if COMPLETE_STATUSES.include? self.detailed_status
29
+ end
18
30
  end
@@ -1,6 +1,28 @@
1
1
  # @author Lovell McIlwain#
2
2
  # Handles business logic for todo item
3
3
  class Note < ActiveRecord::Base
4
+ # ActiveModel validation to ensure body has content
4
5
  validates :body, presence: true
6
+
7
+ # ActiveRecord association to parent item
8
+ # @note Note.first.item
5
9
  belongs_to :item
10
+
11
+ # Add date to created at when record is created
12
+ # (see #tag_created_at)
13
+ before_save :tag_created_at, on: :create
14
+
15
+ # Add date to updated at when record is updated
16
+ # (see #tag_updated_at)
17
+ before_save :tag_updated_at, on: :update
18
+
19
+ # set created at to the current date
20
+ def tag_created_at
21
+ self.created_at = Date.today
22
+ end
23
+
24
+ # set updated at to the current date
25
+ def tag_updated_at
26
+ self.updated_at = Date.today if changes.size > 0
27
+ end
6
28
  end
@@ -7,7 +7,7 @@ module MyTodoActions
7
7
  def create_item(options)
8
8
  ask_status
9
9
  @item = Item.create!(options.merge({detailed_status: detailed_statuses[@status.to_i]}).except(:tags))
10
- options[:tags].split(' ').each{|tag| item.tags.create(name: tag) }
10
+ options[:tags].split(' ').each{|tag| item.tags.create(name: tag) } if options[:tags]
11
11
  end
12
12
 
13
13
  def update_item(options)
@@ -1,5 +1,4 @@
1
1
  module Templates
2
- p __dir__
3
2
  def print_list
4
3
  say ERB.new(File.read("#{__dir__}/../templates/list.erb"), nil, '-').result(binding)
5
4
  end
@@ -1,6 +1,6 @@
1
1
 
2
2
  <% @items.each do |item| -%>
3
- ID: <%= item.id %> | Created On: <%= item.created_at.strftime("%Y-%m-%d") %> | Tags: <%= item.tags.map(&:name).join(', ') %> | Status: <%= item.detailed_status %> | Complete: <%= item.done %>
3
+ ID: <%= item.id %> | Created On: <%= item.created_at.strftime("%Y-%m-%d") %> | Tags: <%= item.tags.map(&:name).join(', ') %> | Status: <%= item.detailed_status %> | Complete: <%= item.done %> | Notes: <%= item.notes.size %>
4
4
 
5
5
  <%= item.body %>
6
6
  <%= '*' * 100 %>
@@ -1,6 +1,6 @@
1
1
 
2
2
  <% @items.each do |item| -%>
3
- ID: <%= item.id %> | Created On: <%= item.created_at.strftime("%Y-%m-%d") %> | Tags: <%= item.tags.map(&:name).join(', ') %> | Status: <%= item.detailed_status %> | Complete: <%= item.done %>
3
+ ID: <%= item.id %> | Created On: <%= item.created_at.strftime("%Y-%m-%d") %> | Tags: <%= item.tags.map(&:name).join(', ') %> | Status: <%= item.detailed_status %> | Complete: <%= item.done %> | Notes: <%= item.notes.count %>
4
4
  <%= item.body %>
5
5
 
6
6
  <% if item.notes.any? -%>
@@ -1,3 +1,3 @@
1
1
  module MyTodo
2
- VERSION = "3.0.0"
2
+ VERSION = "3.1.0"
3
3
  end
data/lib/my_todo.rb CHANGED
@@ -38,9 +38,7 @@ module MyTodo
38
38
 
39
39
  desc "create --body='some text' [--done=true] [--tags='tag1 tag2']", 'Create a todo'
40
40
  option :body
41
- option :done, default: false
42
41
  option :tags, default: 'default'
43
- option :created_at, default: DateTime.now
44
42
  def create
45
43
  begin
46
44
  say 'ToDo CREATED!'
@@ -54,8 +52,6 @@ module MyTodo
54
52
  desc "update --id=TODO_ID --body='some text' [--done=true]", 'Change an existing todo'
55
53
  option :id
56
54
  option :body
57
- option :done
58
- option :updated_at, default: DateTime.now
59
55
  def update
60
56
  begin
61
57
  update_item(options)
@@ -110,10 +106,10 @@ module MyTodo
110
106
  end
111
107
  end
112
108
 
113
- desc "add_note --id=TODO_ID --body='text'", 'Adds note to existing item'
109
+ desc "note --id=TODO_ID --body='text'", 'Adds note to existing item'
114
110
  option :id
115
111
  option :body
116
- def add_note
112
+ def note
117
113
  begin
118
114
  item.notes.create(body: options[:body])
119
115
  print_notes
@@ -33,7 +33,7 @@ describe MyTodo do
33
33
  end
34
34
 
35
35
  it 'displays the created todo item' do
36
- expect{MyTodo::Todo.start(%w(create --body=wierdness_of_text))}.to output("ToDo CREATED!\n0: None\n1: In Progress\n2: Complete\n3: Punted\n4: Waiting Feedback\nID: 1 | Created On: #{Date.today} | Tags: default | Status: In Progress | Complete: false\nwierdness_of_text\n").to_stdout
36
+ expect{MyTodo::Todo.start(%w(create --body=wierdness_of_text))}.to output("ToDo CREATED!\n0: None\n1: In Progress\n2: Waiting Feedback\n3: Complete\n4: Punted\nID: 1 | Created On: #{Date.today} | Tags: default | Status: In Progress | Complete: false\nwierdness_of_text\n").to_stdout
37
37
  end
38
38
  end
39
39
 
@@ -43,27 +43,20 @@ describe MyTodo do
43
43
  end
44
44
 
45
45
  it 'displays the created todo item with tag' do
46
- expect{MyTodo::Todo.start(%w(create --body=wierdness_of_text --tags=tag1))}.to output("ToDo CREATED!\n0: None\n1: In Progress\n2: Complete\n3: Punted\n4: Waiting Feedback\nID: 1 | Created On: #{Date.today} | Tags: tag1 | Status: In Progress | Complete: false\nwierdness_of_text\n").to_stdout
46
+ expect{MyTodo::Todo.start(%w(create --body=wierdness_of_text --tags=tag1))}.to output("ToDo CREATED!\n0: None\n1: In Progress\n2: Waiting Feedback\n3: Complete\n4: Punted\nID: 1 | Created On: #{Date.today} | Tags: tag1 | Status: In Progress | Complete: false\nwierdness_of_text\n").to_stdout
47
47
  end
48
48
  end
49
49
 
50
- describe 'create with tags and setting done attribute' do
51
-
52
- it 'creates todo item with flag set to done' do
53
- MyTodo::Todo.start(%w[create --body=wierdness_of_text --done=true])
54
- todo = Item.last
55
- expect(todo.done).to eq true
56
- end
57
-
50
+ describe 'create with tags' do
58
51
  it 'displays the created to item with complete set to true' do
59
- expect{MyTodo::Todo.start(%w[create --body=wierdness_of_text --done=true])}.to output("ToDo CREATED!\n0: None\n1: In Progress\n2: Complete\n3: Punted\n4: Waiting Feedback\nID: 1 | Created On: #{Date.today} | Tags: default | Status: In Progress | Complete: true\nwierdness_of_text\n").to_stdout
52
+ expect{MyTodo::Todo.start(%w[create --body=wierdness_of_text])}.to output("ToDo CREATED!\n0: None\n1: In Progress\n2: Waiting Feedback\n3: Complete\n4: Punted\nID: 1 | Created On: #{Date.today} | Tags: default | Status: In Progress | Complete: false\nwierdness_of_text\n").to_stdout
60
53
  end
61
54
  end
62
55
  end
63
56
 
64
57
  context 'unsuccessful creation' do
65
58
  it 'returns error message when body is missing' do
66
- expect{MyTodo::Todo.start(%w(create))}.to output("ToDo CREATED!\n0: None\n1: In Progress\n2: Complete\n3: Punted\n4: Waiting Feedback\nValidation failed: Body can't be blank\n").to_stdout
59
+ expect{MyTodo::Todo.start(%w(create))}.to output("ToDo CREATED!\n0: None\n1: In Progress\n2: Waiting Feedback\n3: Complete\n4: Punted\nValidation failed: Body can't be blank\n").to_stdout
67
60
  end
68
61
  end
69
62
  end
@@ -4,19 +4,19 @@ describe MyTodo do
4
4
  describe 'list' do
5
5
  before do
6
6
  @todo1 = FactoryGirl.create :item, done: true
7
- @todo2 = FactoryGirl.create :item, done: false
7
+ @todo2 = FactoryGirl.create :item
8
8
  end
9
9
 
10
10
  it 'displays items with done set to true' do
11
- expect{MyTodo::Todo.start(%w[list --status=done])}.to output("ToDos FOUND: 1\n\nID: 1 | Created On: #{Date.today} | Tags: | Status: | Complete: true\n\nSome Body\n****************************************************************************************************\n").to_stdout
11
+ expect{MyTodo::Todo.start(%w[list --status=done])}.to output("ToDos FOUND: 1\n\nID: 1 | Created On: #{Date.today} | Tags: | Status: | Complete: true | Notes: 0\n\nSome Body\n****************************************************************************************************\n").to_stdout
12
12
  end
13
13
 
14
14
  it 'displays items with done set to false by default' do
15
- expect{MyTodo::Todo.start(%w[list])}.to output("ToDos FOUND: 1\n\nID: 2 | Created On: #{Date.today} | Tags: | Status: | Complete: false\n\nSome Body\n****************************************************************************************************\n").to_stdout
15
+ expect{MyTodo::Todo.start(%w[list])}.to output("ToDos FOUND: 1\n\nID: 2 | Created On: #{Date.today} | Tags: | Status: | Complete: false | Notes: 0\n\nSome Body\n****************************************************************************************************\n").to_stdout
16
16
  end
17
17
 
18
18
  it 'displays all items' do
19
- expect{MyTodo::Todo.start(%w[list --status=all])}.to output("ToDos FOUND: 2\n\nID: 1 | Created On: #{Date.today} | Tags: | Status: | Complete: true\n\nSome Body\n****************************************************************************************************\nID: 2 | Created On: #{Date.today} | Tags: | Status: | Complete: false\n\nSome Body\n****************************************************************************************************\n").to_stdout
19
+ expect{MyTodo::Todo.start(%w[list --status=all])}.to output("ToDos FOUND: 2\n\nID: 1 | Created On: #{Date.today} | Tags: | Status: | Complete: true | Notes: 0\n\nSome Body\n****************************************************************************************************\nID: 2 | Created On: #{Date.today} | Tags: | Status: | Complete: false | Notes: 0\n\nSome Body\n****************************************************************************************************\n").to_stdout
20
20
  end
21
21
  end
22
22
  end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe MyTodo do
4
+ describe 'add_note' do
5
+ before {@todo = FactoryGirl.create(:item)}
6
+ context 'successful creation' do
7
+ it 'creates a note' do
8
+ expect{MyTodo::Todo.start(%W[note --id=#{@todo.id} --body=note_text])}.to change{Note.count}.by(1)
9
+ end
10
+
11
+ it 'associates note to item' do
12
+ MyTodo::Todo.start(%W[note --id=#{@todo.id} --body=note_text])
13
+ expect(@todo.notes.size).to eq 1
14
+ end
15
+
16
+ it 'displays item with notes' do
17
+ expect{MyTodo::Todo.start(%W[note --id=#{@todo.id} --body=note_text])}.to output("Notes for 1: Some Body\nID: 1 | Created On: #{Date.today}\nnote_text\n\n\n").to_stdout
18
+ end
19
+ end
20
+
21
+ context 'unsuccessful creation' do
22
+ it 'returns exception if partent item is not found' do
23
+ expect{MyTodo::Todo.start(%W[note --id=#{@todo.id + 1}])}.to output("undefined method `notes' for nil:NilClass\n").to_stdout
24
+ end
25
+ end
26
+ end
27
+ end
@@ -8,7 +8,7 @@ describe MyTodo do
8
8
  before {@todo.notes.create(body: 'What a world!')}
9
9
 
10
10
  it 'displays note' do
11
- expect{MyTodo::Todo.start(%W[notes --id=#{@todo.id}])}.to output("Notes for 1: Some Body\nID: 1 | Created On: 2016-12-12\nWhat a world!\n\n\n").to_stdout
11
+ expect{MyTodo::Todo.start(%W[notes --id=#{@todo.id}])}.to output("Notes for 1: Some Body\nID: 1 | Created On: #{Date.today}\nWhat a world!\n\n\n").to_stdout
12
12
  end
13
13
  end
14
14
 
@@ -19,8 +19,8 @@ describe MyTodo do
19
19
  end
20
20
 
21
21
  context 'unsuccessful creation' do
22
- it 'returns exception if partent item is not found' do
23
- expect{MyTodo::Todo.start(%W[add_note --id=#{@todo.id + 1}])}.to output("undefined method `notes' for nil:NilClass\n").to_stdout
22
+ it 'returns exception if parent item is not found' do
23
+ expect{MyTodo::Todo.start(%W[note --id=#{@todo.id + 1}])}.to output("undefined method `notes' for nil:NilClass\n").to_stdout
24
24
  end
25
25
  end
26
26
  end
@@ -12,20 +12,20 @@ describe MyTodo do
12
12
  end
13
13
 
14
14
  it 'finds todo item by body' do
15
- expect{MyTodo::Todo.start( %w[search --text=nfl])}.to output("ToDos FOUND: 1\nSearch based on ransack search: body_or_detailed_status_or_tags_name_or_notes_body_cont\n\nID: 1 | Created On: #{Date.today} | Tags: tag1 | Status: | Complete: \nnfl\n\n****************************************************************************************************\n").to_stdout
15
+ expect{MyTodo::Todo.start( %w[search --text=nfl])}.to output("ToDos FOUND: 1\nSearch based on ransack search: body_or_detailed_status_or_tags_name_or_notes_body_cont\n\nID: 1 | Created On: #{Date.today} | Tags: tag1 | Status: | Complete: false | Notes: 0\nnfl\n\n****************************************************************************************************\n").to_stdout
16
16
  end
17
17
 
18
18
  it 'finds todo items by associated tag' do
19
- expect{MyTodo::Todo.start( %w[search --text=tag1])}.to output("ToDos FOUND: 1\nSearch based on ransack search: body_or_detailed_status_or_tags_name_or_notes_body_cont\n\nID: 1 | Created On: #{Date.today} | Tags: tag1 | Status: | Complete: \nnfl\n\n****************************************************************************************************\n").to_stdout
19
+ expect{MyTodo::Todo.start( %w[search --text=tag1])}.to output("ToDos FOUND: 1\nSearch based on ransack search: body_or_detailed_status_or_tags_name_or_notes_body_cont\n\nID: 1 | Created On: #{Date.today} | Tags: tag1 | Status: | Complete: false | Notes: 0\nnfl\n\n****************************************************************************************************\n").to_stdout
20
20
  end
21
21
 
22
22
  it 'finds todo items by detailed status' do
23
23
  @todo2.update!(detailed_status: 'None')
24
- expect{MyTodo::Todo.start( %w[search --text=None])}.to output("ToDos FOUND: 1\nSearch based on ransack search: body_or_detailed_status_or_tags_name_or_notes_body_cont\n\nID: 2 | Created On: #{Date.today} | Tags: | Status: None | Complete: \nrocks\n\n****************************************************************************************************\n").to_stdout
24
+ expect{MyTodo::Todo.start( %w[search --text=None])}.to output("ToDos FOUND: 1\nSearch based on ransack search: body_or_detailed_status_or_tags_name_or_notes_body_cont\n\nID: 2 | Created On: #{Date.today} | Tags: | Status: None | Complete: false | Notes: 0\nrocks\n\n****************************************************************************************************\n").to_stdout
25
25
  end
26
26
 
27
27
  it 'finds todo items by notes' do
28
- expect{MyTodo::Todo.start( %w[search --text=note1])}.to output("ToDos FOUND: 1\nSearch based on ransack search: body_or_detailed_status_or_tags_name_or_notes_body_cont\n\nID: 3 | Created On: 2016-12-12 | Tags: | Status: | Complete: \nalways\n\n [1] note1\n ----------------------------------------------------------------------------------------------------\n****************************************************************************************************\n").to_stdout
28
+ expect{MyTodo::Todo.start( %w[search --text=note1])}.to output("ToDos FOUND: 1\nSearch based on ransack search: body_or_detailed_status_or_tags_name_or_notes_body_cont\n\nID: 3 | Created On: #{Date.today} | Tags: | Status: | Complete: false | Notes: 1\nalways\n\n [1] note1\n ----------------------------------------------------------------------------------------------------\n****************************************************************************************************\n").to_stdout
29
29
  end
30
30
  end
31
31
 
@@ -9,13 +9,13 @@ describe MyTodo do
9
9
 
10
10
  context 'successful update' do
11
11
  it 'displays the update' do
12
- expect{MyTodo::Todo.start(%W[update --id=#{@todo.id} --body=hello])}.to output("0: None\n1: In Progress\n2: Complete\n3: Punted\n4: Waiting Feedback\nToDo UPDATED!\nID: 1 | Created On: #{Date.today} | Tags: | Status: None | Complete: \nhello\n").to_stdout
12
+ expect{MyTodo::Todo.start(%W[update --id=#{@todo.id} --body=hello])}.to output("0: None\n1: In Progress\n2: Waiting Feedback\n3: Complete\n4: Punted\nToDo UPDATED!\nID: 1 | Created On: #{Date.today} | Tags: | Status: None | Complete: false\nhello\n").to_stdout
13
13
  end
14
14
  end
15
15
 
16
16
  context 'unsuccessful update' do
17
17
  it 'returns validation error when body is missing' do
18
- expect{MyTodo::Todo.start(%W(update --id=#{@todo.id} --body=))}.to output("0: None\n1: In Progress\n2: Complete\n3: Punted\n4: Waiting Feedback\nValidation failed: Body can't be blank\n").to_stdout
18
+ expect{MyTodo::Todo.start(%W(update --id=#{@todo.id} --body=))}.to output("0: None\n1: In Progress\n2: Waiting Feedback\n3: Complete\n4: Punted\nValidation failed: Body can't be blank\n").to_stdout
19
19
  end
20
20
  end
21
21
  end
@@ -1,8 +1,20 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Item, type: :model do
4
+ let(:item) {FactoryGirl.create :item}
5
+
4
6
  it {should have_many :stubs}
5
7
  it {should have_many :tags}
6
8
  it {should have_many :notes}
7
9
  it {should validate_presence_of :body}
10
+
11
+ describe 'update_done' do
12
+ it 'sets to true when detailed status is of a complete status' do
13
+ item.update(detailed_status: 'Complete')
14
+ expect(item.reload.done).to eq true
15
+ end
16
+ it 'sets to false when detailed status is of an incomplete status' do
17
+ expect(item.done).to eq false
18
+ end
19
+ end
8
20
  end
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # code climent must be loaded and started before RAILS_ENV is declared
2
2
  require "codeclimate-test-reporter"
3
+ ENV['CODECLIMATE_REPO_TOKEN'] = ENV['MYTODO_CC']
3
4
  CodeClimate::TestReporter.start
4
- ENV['CODECLIMATE_REPO_TOKEN'] = ENV['MYTOD_CC']
5
5
  ENV["RAILS_ENV"] = 'test'
6
6
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
7
7
  require 'database_cleaner'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: my_todo
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-12 00:00:00.000000000 Z
11
+ date: 2016-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -258,6 +258,7 @@ files:
258
258
  - lib/db/migrate/20160913134610_create_stubs.rb
259
259
  - lib/db/migrate/20161003121448_create_notes.rb
260
260
  - lib/db/migrate/20161005133023_add_detailed_status_to_items.rb
261
+ - lib/db/migrate/20161220143613_add_default_to_item_done.rb
261
262
  - lib/db/schema.rb
262
263
  - lib/db/todos_development.sqlite3
263
264
  - lib/db/todos_test.sqlite3
@@ -281,10 +282,10 @@ files:
281
282
  - lib/my_todo/version.rb
282
283
  - lib/setup.rb
283
284
  - my_todo.gemspec
284
- - spec/actions/add_note_spec.rb
285
285
  - spec/actions/create_spec.rb
286
286
  - spec/actions/delete_spec.rb
287
287
  - spec/actions/list_spec.rb
288
+ - spec/actions/note_spec.rb
288
289
  - spec/actions/notes_spec.rb
289
290
  - spec/actions/rm_note_spec.rb
290
291
  - spec/actions/rm_tag_spec.rb
@@ -323,10 +324,10 @@ signing_key:
323
324
  specification_version: 4
324
325
  summary: A basic todo application with tags.
325
326
  test_files:
326
- - spec/actions/add_note_spec.rb
327
327
  - spec/actions/create_spec.rb
328
328
  - spec/actions/delete_spec.rb
329
329
  - spec/actions/list_spec.rb
330
+ - spec/actions/note_spec.rb
330
331
  - spec/actions/notes_spec.rb
331
332
  - spec/actions/rm_note_spec.rb
332
333
  - spec/actions/rm_tag_spec.rb
@@ -1,27 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe MyTodo do
4
- describe 'add_note' do
5
- before {@todo = FactoryGirl.create(:item)}
6
- context 'successful creation' do
7
- it 'creates a note' do
8
- expect{MyTodo::Todo.start(%W[add_note --id=#{@todo.id} --body=note_text])}.to change{Note.count}.by(1)
9
- end
10
-
11
- it 'associates note to item' do
12
- MyTodo::Todo.start(%W[add_note --id=#{@todo.id} --body=note_text])
13
- expect(@todo.notes.size).to eq 1
14
- end
15
-
16
- it 'displays item with notes' do
17
- expect{MyTodo::Todo.start(%W[add_note --id=#{@todo.id} --body=note_text])}.to output("Notes for 1: Some Body\nID: 1 | Created On: 2016-12-12\nnote_text\n\n\n").to_stdout
18
- end
19
- end
20
-
21
- context 'unsuccessful creation' do
22
- it 'returns exception if partent item is not found' do
23
- expect{MyTodo::Todo.start(%W[add_note --id=#{@todo.id + 1}])}.to output("undefined method `notes' for nil:NilClass\n").to_stdout
24
- end
25
- end
26
- end
27
- end