flyboy 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. data/app/assets/stylesheets/flyboy/all.sass +5 -1
  2. data/app/controllers/flyboy/goals_controller.rb +6 -2
  3. data/app/controllers/flyboy/tasks_controller.rb +6 -1
  4. data/app/models/flyboy/goal.rb +24 -5
  5. data/app/models/flyboy/task.rb +13 -2
  6. data/app/models/flyboy/task_comment.rb +9 -3
  7. data/app/views/flyboy/_searchbar.html.slim +6 -0
  8. data/app/views/flyboy/goals/_actions.html.slim +10 -10
  9. data/app/views/flyboy/goals/_context.html.slim +4 -2
  10. data/app/views/flyboy/goals/_list.html.slim +26 -0
  11. data/app/views/flyboy/goals/index.html.slim +6 -29
  12. data/app/views/flyboy/task_comments/_list.html.slim +1 -1
  13. data/app/views/flyboy/tasks/_actions.html.slim +6 -6
  14. data/app/views/flyboy/tasks/_context.html.slim +1 -1
  15. data/app/views/flyboy/tasks/_list.html.slim +4 -7
  16. data/app/views/flyboy/tasks/index.html.slim +5 -4
  17. data/config/locales/fr.yml +1 -0
  18. data/db/migrate/20150415130939_add_progress_to_goals.rb +6 -0
  19. data/lib/flyboy/version.rb +1 -1
  20. data/spec/controllers/flyboy/goals_controller_spec.rb +39 -0
  21. data/spec/controllers/flyboy/tasks_controller_spec.rb +55 -1
  22. data/spec/dummy/db/development.sqlite3 +0 -0
  23. data/spec/dummy/db/schema.rb +2 -1
  24. data/spec/dummy/db/test.sqlite3 +0 -0
  25. data/spec/dummy/log/development.log +9558 -0
  26. data/spec/dummy/log/test.log +111829 -0
  27. data/spec/dummy/tmp/cache/assets/development/sass/2c0db231f5525ae4045d3b5f760e4616fb8e65dd/all.sassc +0 -0
  28. data/spec/dummy/tmp/cache/assets/development/sass/2c0db231f5525ae4045d3b5f760e4616fb8e65dd/comments.sassc +0 -0
  29. data/spec/dummy/tmp/cache/assets/development/sass/2c0db231f5525ae4045d3b5f760e4616fb8e65dd/contexts.sassc +0 -0
  30. data/spec/dummy/tmp/cache/assets/development/sass/2c0db231f5525ae4045d3b5f760e4616fb8e65dd/filters.sassc +0 -0
  31. data/spec/dummy/tmp/cache/assets/development/sass/2c0db231f5525ae4045d3b5f760e4616fb8e65dd/flash.sassc +0 -0
  32. data/spec/dummy/tmp/cache/assets/development/sass/2c0db231f5525ae4045d3b5f760e4616fb8e65dd/forms.sassc +0 -0
  33. data/spec/dummy/tmp/cache/assets/development/sass/2c0db231f5525ae4045d3b5f760e4616fb8e65dd/styles.sassc +0 -0
  34. data/spec/dummy/tmp/cache/assets/development/sass/2c0db231f5525ae4045d3b5f760e4616fb8e65dd/tables.sassc +0 -0
  35. data/spec/dummy/tmp/cache/assets/development/sass/4cd3136ea73cf27a824cea21f80648c87f40dfa2/all.sassc +0 -0
  36. data/spec/dummy/tmp/cache/assets/development/sprockets/a88d9c609d05fcc4670c8742b41816c0 +0 -0
  37. data/spec/dummy/tmp/cache/assets/development/sprockets/d87810c66e05721ba749c5901c1af296 +0 -0
  38. data/spec/dummy/tmp/cache/assets/development/sprockets/ebe08f689f659c024f467b77f32a1c49 +0 -0
  39. data/spec/dummy/tmp/cache/assets/test/sass/2c0db231f5525ae4045d3b5f760e4616fb8e65dd/all.sassc +0 -0
  40. data/spec/dummy/tmp/cache/assets/test/sass/2c0db231f5525ae4045d3b5f760e4616fb8e65dd/comments.sassc +0 -0
  41. data/spec/dummy/tmp/cache/assets/test/sass/2c0db231f5525ae4045d3b5f760e4616fb8e65dd/contexts.sassc +0 -0
  42. data/spec/dummy/tmp/cache/assets/test/sass/2c0db231f5525ae4045d3b5f760e4616fb8e65dd/filters.sassc +0 -0
  43. data/spec/dummy/tmp/cache/assets/test/sass/2c0db231f5525ae4045d3b5f760e4616fb8e65dd/flash.sassc +0 -0
  44. data/spec/dummy/tmp/cache/assets/test/sass/2c0db231f5525ae4045d3b5f760e4616fb8e65dd/forms.sassc +0 -0
  45. data/spec/dummy/tmp/cache/assets/test/sass/2c0db231f5525ae4045d3b5f760e4616fb8e65dd/styles.sassc +0 -0
  46. data/spec/dummy/tmp/cache/assets/test/sass/2c0db231f5525ae4045d3b5f760e4616fb8e65dd/tables.sassc +0 -0
  47. data/spec/dummy/tmp/cache/assets/test/sass/4cd3136ea73cf27a824cea21f80648c87f40dfa2/all.sassc +0 -0
  48. data/spec/dummy/tmp/cache/assets/test/sprockets/a88d9c609d05fcc4670c8742b41816c0 +0 -0
  49. data/spec/dummy/tmp/cache/assets/test/sprockets/d87810c66e05721ba749c5901c1af296 +0 -0
  50. data/spec/dummy/tmp/cache/assets/test/sprockets/ebe08f689f659c024f467b77f32a1c49 +0 -0
  51. data/spec/dummy/tmp/pids/server.pid +1 -1
  52. data/spec/models/flyboy/goal_spec.rb +15 -4
  53. data/spec/models/flyboy/task_comment_spec.rb +22 -0
  54. data/spec/models/flyboy/task_spec.rb +4 -0
  55. metadata +38 -3
@@ -1,4 +1,8 @@
1
1
  .flyboy
2
+ table
3
+ @extend .table
4
+ @extend .table-bordered
5
+
2
6
  .onwarning
3
7
  background: $state-warning-bg !important
4
8
 
@@ -8,7 +12,7 @@
8
12
  .onalert
9
13
  background: $state-danger-bg !important
10
14
 
11
- .btn
15
+ .btn, form.search
12
16
  margin: 5px
13
17
 
14
18
  .context div.infos
@@ -14,8 +14,10 @@ module Flyboy
14
14
 
15
15
  @order ||= sortable_column_order do |column, direction|
16
16
  case column
17
- when "title"
17
+ when "title", "status"
18
18
  %(LOWER(flyboy_goals.#{column}) #{direction})
19
+ when "progress"
20
+ %(flyboy_goals.#{column} #{direction})
19
21
  else
20
22
  params["sort"] = "status"
21
23
  "status ASC"
@@ -25,7 +27,9 @@ module Flyboy
25
27
  @filters ||= SmallData::FilterForGoals.new(cookies)
26
28
 
27
29
  @goals = @goals.order(@order)
28
- @goals = @filters.apply @goals
30
+ @goals = @filters.apply(@goals)
31
+ @goals = @goals.search(params[:q])
32
+ @goals = @goals.page(params[:page])
29
33
  end
30
34
 
31
35
  def show
@@ -14,7 +14,10 @@ module Flyboy
14
14
  case column
15
15
  when "title", "status"
16
16
  %(LOWER(flyboy_tasks.#{column}) #{direction})
17
+ when "progress", "term"
18
+ %(flyboy_tasks.#{column} #{direction})
17
19
  when "goal"
20
+ @tasks = @tasks.joins(:goal)
18
21
  %(LOWER(flyboy_goals.title) #{direction})
19
22
  else
20
23
  params["sort"] = "term"
@@ -25,7 +28,9 @@ module Flyboy
25
28
  @filters ||= SmallData::FilterForTasks.new(cookies)
26
29
 
27
30
  @tasks = @tasks.order(@order)
28
- @tasks = @filters.apply @tasks
31
+ @tasks = @filters.apply(@tasks)
32
+ @tasks = @tasks.search(params[:q])
33
+ @tasks = @tasks.page(params[:page])
29
34
 
30
35
  respond_to do |format|
31
36
  format.html
@@ -1,6 +1,11 @@
1
+ require "dorsale/search"
2
+
1
3
  module Flyboy
2
4
  class Goal < ActiveRecord::Base
3
5
  include AASM
6
+ include Dorsale::Search
7
+
8
+ paginates_per 50
4
9
 
5
10
  aasm(column: "status", whiny_transitions: false) do
6
11
  state :open, initial: true
@@ -22,13 +27,13 @@ module Flyboy
22
27
  in: proc { Flyboy::Goal.aasm.states.map(&:to_s) }
23
28
  }
24
29
 
25
- def no_undone_tasks?
26
- tasks.where(done: false).count == 0
30
+ def initialize(*args)
31
+ super
32
+ self.progress = 0 if progress.nil?
27
33
  end
28
34
 
29
- def progress
30
- return 0 if tasks.count.zero?
31
- tasks.sum(:progress) / tasks.count
35
+ def no_undone_tasks?
36
+ tasks.where(done: false).count == 0
32
37
  end
33
38
 
34
39
  def revision
@@ -48,5 +53,19 @@ module Flyboy
48
53
  self.version = 0 if self.version.nil?
49
54
  self.version = self.version + 1
50
55
  end
56
+
57
+ def update_progress
58
+ if tasks.count.zero?
59
+ self.progress = 0
60
+ else
61
+ self.progress = tasks.sum(:progress) / tasks.count
62
+ end
63
+ end
64
+
65
+ def update_progress!
66
+ update_progress
67
+ save
68
+ end
69
+
51
70
  end
52
71
  end
@@ -1,7 +1,12 @@
1
1
  #encoding: utf-8
2
+ require "dorsale/search"
2
3
 
3
4
  module Flyboy
4
5
  class Task < ActiveRecord::Base
6
+ include Dorsale::Search
7
+
8
+ paginates_per 50
9
+
5
10
  belongs_to :goal
6
11
  has_many :comments, class_name: Flyboy::TaskComment, inverse_of: :task, dependent: :destroy
7
12
 
@@ -19,13 +24,19 @@ module Flyboy
19
24
  end
20
25
  end
21
26
 
22
- default_scope -> { order("term ASC") }
23
-
24
27
  def initialize(*args)
25
28
  super
26
29
  self.done = false if done.nil?
27
30
  self.reminder = Date.today + snooze_default_reminder if reminder.nil?
28
31
  self.term = Date.today + snooze_default_term if term.nil?
32
+ self.progress = 0 if progress.nil?
33
+ end
34
+
35
+ after_save :update_goal_progress!
36
+ after_destroy :update_goal_progress!
37
+
38
+ def update_goal_progress!
39
+ goal.update_progress!
29
40
  end
30
41
 
31
42
  def snooze
@@ -2,15 +2,21 @@ module Flyboy
2
2
  class TaskComment < ActiveRecord::Base
3
3
  belongs_to :task
4
4
 
5
- validates :task, presence: true
6
- validates :date, presence: true
5
+ validates :task, presence: true
6
+ validates :date, presence: true
7
+ validates :description, presence: true
7
8
  validates :progress, inclusion: {in: 0..100}
8
9
 
9
10
  default_scope -> { order("created_at DESC") }
10
11
 
11
12
  def initialize(*args)
12
13
  super
13
- self.date = Time.now if date.nil?
14
+
15
+ self.date = Time.now if date.nil?
16
+
17
+ if progress.nil?
18
+ self.progress = task ? task.progress : 0
19
+ end
14
20
  end
15
21
 
16
22
  after_create :update_task_progress
@@ -0,0 +1,6 @@
1
+ form.search
2
+ p.input-group
3
+ input.form-control name="q" placeholder=t("actions.search") size=25 value=params[:q]
4
+ span.input-group-addon
5
+ button.nostyle type="submit"
6
+ = icon :search
@@ -1,15 +1,15 @@
1
1
  .actions
2
- - if flyboy.goal_path(@goal) != request.path
3
- = read_button goal_path(@goal)
2
+ - if flyboy.goal_path(goal) != request.path
3
+ = read_button goal_path(goal)
4
4
 
5
- - if can?(:create, @goal.tasks.new)
6
- = create_button new_goal_task_path(@goal), text: t("actions.goals.new_task")
5
+ - if can?(:create, goal.tasks.new)
6
+ = create_button new_goal_task_path(goal), text: t("actions.goals.new_task")
7
7
 
8
- - if can?(:update, @goal)
9
- = update_button edit_goal_path(@goal)
8
+ - if can?(:update, goal)
9
+ = update_button edit_goal_path(goal)
10
10
 
11
- - if can?(:close, @goal)
12
- = lock_button close_goal_path(@goal), text: t("actions.close")
11
+ - if can?(:close, goal)
12
+ = lock_button close_goal_path(goal), text: t("actions.close")
13
13
 
14
- - if can?(:open, @goal)
15
- = unlock_button open_goal_path(@goal), text: t("actions.open")
14
+ - if can?(:open, goal)
15
+ = unlock_button open_goal_path(goal), text: t("actions.open")
@@ -1,7 +1,7 @@
1
1
  .goal-context: .context
2
2
  = context_icon :tasks
3
3
  = context_title goal.title
4
- = render "flyboy/goals/actions"
4
+ = render "flyboy/goals/actions", goal: goal
5
5
 
6
6
  .infos
7
7
  strong
@@ -11,4 +11,6 @@
11
11
 
12
12
  = context_info Flyboy::Goal.human_attribute_name(:revision), goal.revision
13
13
  = context_info Flyboy::Goal.human_attribute_name(:status), t("messages.goals.status.#{goal.status}")
14
- = context_info Flyboy::Goal.human_attribute_name(:description), goal.description
14
+
15
+ - if params[:controller] == "flyboy/goals" && params[:action] == "show"
16
+ = context_info Flyboy::Goal.human_attribute_name(:description), text2html("\n" +goal.description)
@@ -0,0 +1,26 @@
1
+ table
2
+ thead
3
+ tr
4
+ th = sortable_column Flyboy::Goal.model_name.human, column: "title"
5
+ th = sortable_column Flyboy::Goal.human_attribute_name(:progress), column: "progress"
6
+ th = sortable_column Flyboy::Goal.human_attribute_name(:status), column: "status"
7
+ th = t ".actions", default: t("helpers.actions")
8
+
9
+ tbody
10
+ - goals.each do |goal|
11
+ tr.goal class=goal_color(goal)
12
+ td.title
13
+ - if can? :read, goal
14
+ = link_to goal.title, goal_path(goal)
15
+ - else
16
+ = goal.title
17
+
18
+ td.goal_progress
19
+ = progress_bar percentage: goal.progress, label: true
20
+
21
+ td.status
22
+ = t("messages.goals.status.#{goal.status}")
23
+
24
+ td.actions
25
+ - if can? :create, Flyboy::Task.new(goal: goal)
26
+ = create_button flyboy.new_goal_task_path(goal), text: t("actions.goals.new_task")
@@ -1,37 +1,14 @@
1
1
  .flyboy
2
2
  .row
3
- .col-md-6
3
+ .col-md-4
4
4
  h1 Dossiers en cours
5
5
 
6
- .col-md-6.right
6
+ .col-md-4.right
7
7
  .actions
8
8
  = create_button new_goal_path, class: "btn btn-success"
9
+ .col-md-4
10
+ = render "flyboy/searchbar"
9
11
 
10
12
  = render "flyboy/filters"
11
-
12
- table.default
13
- thead
14
- tr
15
- th = sortable_column Flyboy::Goal.model_name.human, column: "title"
16
- th = Flyboy::Goal.human_attribute_name(:progress)
17
- th = sortable_column Flyboy::Goal.human_attribute_name(:status), column: "status"
18
- th = t ".actions", default: t("helpers.actions")
19
-
20
- tbody
21
- - @goals.each do |goal|
22
- tr.goal class=goal_color(goal)
23
- td.title
24
- - if can? :read, goal
25
- = link_to goal.title, goal_path(goal)
26
- - else
27
- = goal.title
28
-
29
- td.goal_progress
30
- = progress_bar percentage: goal.progress, label: true
31
-
32
- td.status
33
- = t("messages.goals.status.#{goal.status}")
34
-
35
- td.actions
36
- - if can? :create, Flyboy::Task.new(goal: goal)
37
- = create_button flyboy.new_goal_task_path(goal), text: t("actions.goals.new_task")
13
+ = render "flyboy/goals/list", goals: @goals
14
+ = paginate @goals, theme: "twitter-bootstrap-3"
@@ -1,5 +1,5 @@
1
1
  = simple_form_for [@task, (@task_comment || @task.comments.new)] do |f|
2
- table.default
2
+ table
3
3
  thead
4
4
  tr
5
5
  th = Flyboy::TaskComment.human_attribute_name(:progress)
@@ -1,9 +1,9 @@
1
1
  .actions
2
- - if can?(:update, @task)
3
- = update_button edit_task_path(@task)
2
+ - if can?(:update, task)
3
+ = update_button edit_task_path(task)
4
4
 
5
- - if can?(:snooze, @task)
6
- = snooze_button snooze_task_path(@task)
5
+ - if can?(:snooze, task)
6
+ = snooze_button snooze_task_path(task)
7
7
 
8
- - if can?(:complete, @task)
9
- = complete_button complete_task_path(@task)
8
+ - if can?(:complete, task)
9
+ = complete_button complete_task_path(task)
@@ -1,7 +1,7 @@
1
1
  .task-context: .context
2
2
  = context_icon :check_square_o
3
3
  = context_title task.title
4
- = render "flyboy/tasks/actions"
4
+ = render "flyboy/tasks/actions", task: task
5
5
 
6
6
  .infos
7
7
  strong
@@ -1,4 +1,4 @@
1
- table.default
1
+ table
2
2
  thead
3
3
  tr
4
4
  - if nested
@@ -8,7 +8,7 @@ table.default
8
8
  - else
9
9
  th = sortable_column Flyboy::Goal.model_name.human, column: "goal"
10
10
  th = sortable_column Flyboy::Task.model_name.human, column: "title"
11
- th = Flyboy::Task.human_attribute_name(:progress)
11
+ th = sortable_column Flyboy::Task.human_attribute_name(:progress), column: "progress"
12
12
  th = sortable_column Flyboy::Task.human_attribute_name(:term), column: "term"
13
13
 
14
14
  th = t("actions.label")
@@ -36,11 +36,8 @@ table.default
36
36
  = l task.term
37
37
 
38
38
  td.actions
39
- - if can?(:update, task)
40
- = update_button edit_task_path(task)
41
-
42
- - if can?(:snooze, task)
43
- = snooze_button snooze_task_path(task)
39
+ - if can?(:snooze, task)
40
+ = snooze_button snooze_task_path(task)
44
41
 
45
42
  - if can?(:complete, task)
46
43
  = complete_button complete_task_path(task)
@@ -1,15 +1,16 @@
1
1
  .flyboy
2
2
  .row
3
- .col-md-6
3
+ .col-md-4
4
4
  h1 Feuille de route
5
5
 
6
- .col-md-6.right
6
+ .col-md-4.right
7
7
  .actions
8
8
  = link_to "Export csv", url_for(format: :csv), class: "btn"
9
9
  = link_to "Export excel", url_for(format: :xls), class: "btn"
10
10
  = link_to "Export pdf", url_for(format: :pdf), class: "btn"
11
+ .col-md-4
12
+ = render "flyboy/searchbar"
11
13
 
12
14
  = render "flyboy/filters"
13
-
14
15
  = render "flyboy/tasks/list", tasks: @tasks, nested: false
15
-
16
+ = paginate @tasks, theme: "twitter-bootstrap-3"
@@ -27,6 +27,7 @@ fr:
27
27
  actions:
28
28
  complete: "Fait"
29
29
  label: "Actions"
30
+ search: "Rechercher"
30
31
 
31
32
  goals:
32
33
  new_task: "Nouvelle Tâche"
@@ -0,0 +1,6 @@
1
+ class AddProgressToGoals < ActiveRecord::Migration
2
+ def change
3
+ add_column :flyboy_goals, :progress, :integer
4
+ Flyboy::Goal.all.map(&:update_progress!)
5
+ end
6
+ end
@@ -1,3 +1,3 @@
1
1
  module Flyboy
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  end
@@ -34,6 +34,45 @@ describe Flyboy::GoalsController, type: :controller do
34
34
  assigns(:goals).should eq [@goal1]
35
35
  end
36
36
  end
37
+
38
+ context "when sorting" do
39
+ before do
40
+ Flyboy::Goal.destroy_all
41
+ @goal1 = FactoryGirl.create(:flyboy_goal, title: "Abc", progress: 100, status: "open")
42
+ @goal2 = FactoryGirl.create(:flyboy_goal, title: "dEF", progress: 0, status: "closed")
43
+ @goal3 = FactoryGirl.create(:flyboy_goal, title: "xyz", progress: 35, status: "closed")
44
+ end
45
+
46
+ it "sorting by title asc" do
47
+ get :index, sort: "title"
48
+ expect(assigns(:goals).to_a).to eq [@goal1, @goal2, @goal3]
49
+ end
50
+
51
+ it "sorting by title desc" do
52
+ get :index, sort: "-title"
53
+ expect(assigns(:goals).to_a).to eq [@goal3, @goal2, @goal1]
54
+ end
55
+
56
+ it "sorting by progress asc" do
57
+ get :index, sort: "progress"
58
+ expect(assigns(:goals).to_a).to eq [@goal2, @goal3, @goal1]
59
+ end
60
+
61
+ it "sorting by progress desc" do
62
+ get :index, sort: "-progress"
63
+ expect(assigns(:goals).to_a).to eq [@goal1, @goal3, @goal2]
64
+ end
65
+
66
+ it "sorting by status asc" do
67
+ get :index, sort: "status"
68
+ expect(assigns(:goals).to_a).to eq [@goal2, @goal3, @goal1]
69
+ end
70
+
71
+ it "sorting by status desc" do
72
+ get :index, sort: "-status"
73
+ expect(assigns(:goals).to_a).to eq [@goal1, @goal2, @goal3]
74
+ end
75
+ end
37
76
  end
38
77
 
39
78
  describe "#close" do
@@ -46,7 +46,7 @@ describe Flyboy::TasksController, type: :controller do
46
46
  describe "GET index" do
47
47
  it "assigns all tasks as @tasks" do
48
48
  get :index, {}
49
- expect(assigns(:tasks)).to eq Flyboy::Task.all
49
+ expect(assigns(:tasks).to_a).to eq Flyboy::Task.all.to_a
50
50
  end
51
51
 
52
52
  context "when applying filter" do
@@ -73,6 +73,60 @@ describe Flyboy::TasksController, type: :controller do
73
73
  assigns(:tasks).should eq [@task2]
74
74
  end
75
75
  end
76
+
77
+ context "when sorting" do
78
+ before do
79
+ Flyboy::Goal.destroy_all
80
+ Flyboy::Task.destroy_all
81
+ @goal1 = FactoryGirl.create(:flyboy_goal, title: "Abc")
82
+ @goal2 = FactoryGirl.create(:flyboy_goal, title: "dEF")
83
+ @goal3 = FactoryGirl.create(:flyboy_goal, title: "xyz")
84
+
85
+ @task1 = FactoryGirl.create(:flyboy_task, goal: @goal1, title: "Abc", progress: 100, term: "21/12/2012", reminder: "21/12/2012")
86
+ @task2 = FactoryGirl.create(:flyboy_task, goal: @goal2, title: "dEF", progress: 0, term: "23/12/2012", reminder: "23/12/2012")
87
+ @task3 = FactoryGirl.create(:flyboy_task, goal: @goal3, title: "xyz", progress: 35, term: "22/12/2012", reminder: "22/12/2012")
88
+ end
89
+
90
+ it "sorting by goal asc" do
91
+ get :index, sort: "goal"
92
+ expect(assigns(:tasks).to_a).to eq [@task1, @task2, @task3]
93
+ end
94
+
95
+ it "sorting by goal desc" do
96
+ get :index, sort: "-goal"
97
+ expect(assigns(:tasks).to_a).to eq [@task3, @task2, @task1]
98
+ end
99
+
100
+ it "sorting by title asc" do
101
+ get :index, sort: "title"
102
+ expect(assigns(:tasks).to_a).to eq [@task1, @task2, @task3]
103
+ end
104
+
105
+ it "sorting by title desc" do
106
+ get :index, sort: "-title"
107
+ expect(assigns(:tasks).to_a).to eq [@task3, @task2, @task1]
108
+ end
109
+
110
+ it "sorting by progress asc" do
111
+ get :index, sort: "progress"
112
+ expect(assigns(:tasks).to_a).to eq [@task2, @task3, @task1]
113
+ end
114
+
115
+ it "sorting by progress desc" do
116
+ get :index, sort: "-progress"
117
+ expect(assigns(:tasks).to_a).to eq [@task1, @task3, @task2]
118
+ end
119
+
120
+ it "sorting by term asc" do
121
+ get :index, sort: "term"
122
+ expect(assigns(:tasks).to_a).to eq [@task1, @task3, @task2]
123
+ end
124
+
125
+ it "sorting by term desc" do
126
+ get :index, sort: "-term"
127
+ expect(assigns(:tasks).to_a).to eq [@task2, @task3, @task1]
128
+ end
129
+ end
76
130
  end
77
131
 
78
132
  describe "GET show" do
Binary file
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(version: 20150409081956) do
14
+ ActiveRecord::Schema.define(version: 20150415130939) do
15
15
 
16
16
  create_table "flyboy_goals", force: :cascade do |t|
17
17
  t.string "title"
@@ -21,6 +21,7 @@ ActiveRecord::Schema.define(version: 20150409081956) do
21
21
  t.integer "version"
22
22
  t.datetime "created_at", null: false
23
23
  t.datetime "updated_at", null: false
24
+ t.integer "progress"
24
25
  end
25
26
 
26
27
  create_table "flyboy_task_comments", force: :cascade do |t|
Binary file