diff --git a/app/controllers/recurring_todos_controller.rb b/app/controllers/recurring_todos_controller.rb index 841f807f..048df3b0 100644 --- a/app/controllers/recurring_todos_controller.rb +++ b/app/controllers/recurring_todos_controller.rb @@ -145,7 +145,7 @@ class RecurringTodosController < ApplicationController params.require(:recurring_todo).permit( # model attributes :context_id, :project_id, :description, :notes, :state, :start_from, - :ends_on, :end_date, :number_of_occurences, :occurences_count, :target, + :ends_on, :end_date, :number_of_occurrences, :occurrences_count, :target, :show_from_delta, :recurring_period, :recurrence_selector, :every_other1, :every_other2, :every_other3, :every_day, :only_work_days, :every_count, :weekday, :show_always, :context_name, :project_name, :tag_list, diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c50fed06..ecc31679 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -96,7 +96,7 @@ module ApplicationHelper when "no_end_date" return time_span_text(rt.start_from, I18n.t("todos.recurrence.pattern.from")) when "ends_on_number_of_times" - return I18n.t("todos.recurrence.pattern.times", :number => rt.number_of_occurences) + return I18n.t("todos.recurrence.pattern.times", :number => rt.number_of_occurrences) when "ends_on_end_date" starts = time_span_text(rt.start_from, I18n.t("todos.recurrence.pattern.from")) ends = time_span_text(rt.end_date, I18n.t("todos.recurrence.pattern.until")) diff --git a/app/models/recurring_todo.rb b/app/models/recurring_todo.rb index cedf6327..e64db9eb 100644 --- a/app/models/recurring_todo.rb +++ b/app/models/recurring_todo.rb @@ -12,7 +12,7 @@ class RecurringTodo < ActiveRecord::Base include AASM aasm :column => :state do - state :active, :initial => true, :before_enter => Proc.new { |t| t.occurences_count = 0 } + state :active, :initial => true, :before_enter => Proc.new { |t| t.occurrences_count = 0 } state :completed, :before_enter => Proc.new { |t| t.completed_at = Time.zone.now }, :before_exit => Proc.new { |t| t.completed_at = nil } event :complete do @@ -131,7 +131,7 @@ class RecurringTodo < ActiveRecord::Base end def increment_occurrences - self.occurences_count += 1 + self.occurrences_count += 1 self.save end diff --git a/app/models/recurring_todos/abstract_recurring_todos_builder.rb b/app/models/recurring_todos/abstract_recurring_todos_builder.rb index 4b4f78aa..5c367d14 100644 --- a/app/models/recurring_todos/abstract_recurring_todos_builder.rb +++ b/app/models/recurring_todos/abstract_recurring_todos_builder.rb @@ -76,7 +76,7 @@ module RecurringTodos start_from: attributes[:start_from], end_date: attributes[:end_date], ends_on: attributes[:ends_on], - number_of_occurences: attributes[:number_of_occurences], + number_of_occurrences: attributes[:number_of_occurrences], project: attributes[:project], context: attributes[:context], project_id: attributes[:project_id], diff --git a/app/models/recurring_todos/abstract_repeat_pattern.rb b/app/models/recurring_todos/abstract_repeat_pattern.rb index b0a8734c..7fb14564 100644 --- a/app/models/recurring_todos/abstract_repeat_pattern.rb +++ b/app/models/recurring_todos/abstract_repeat_pattern.rb @@ -32,8 +32,8 @@ module RecurringTodos get :show_from_delta end - def number_of_occurences - get :number_of_occurences + def number_of_occurrences + get :number_of_occurrences end def recurring_target_as_text @@ -94,7 +94,7 @@ module RecurringTodos validate_not_blank(start_from, "The start date needs to be filled in") case ends_on when 'ends_on_number_of_times' - validate_not_blank(number_of_occurences, "The number of recurrences needs to be filled in for 'Ends on'") + validate_not_blank(number_of_occurrences, "The number of recurrences needs to be filled in for 'Ends on'") when "ends_on_end_date" validate_not_blank(end_date, "The end date needs to be filled in for 'Ends on'") else @@ -155,7 +155,7 @@ module RecurringTodos end def continues_recurring?(previous) - return @recurring_todo.occurences_count < @recurring_todo.number_of_occurences unless @recurring_todo.number_of_occurences.nil? + return @recurring_todo.occurrences_count < @recurring_todo.number_of_occurrences unless @recurring_todo.number_of_occurrences.nil? return true if self.end_date.nil? || self.ends_on == 'no_end_date' case self.target diff --git a/app/views/recurring_todos/_edit_form.html.erb b/app/views/recurring_todos/_edit_form.html.erb index 21c4ab24..d9ed06c7 100644 --- a/app/views/recurring_todos/_edit_form.html.erb +++ b/app/views/recurring_todos/_edit_form.html.erb @@ -38,7 +38,7 @@
<%= radio_button_tag('recurring_todo[ends_on]', 'no_end_date', @form_helper.ends_on == 'no_end_date')%> <%= t('todos.recurrence.no_end_date') %>
<%= radio_button_tag('recurring_todo[ends_on]', 'ends_on_number_of_times', @form_helper.ends_on == 'ends_on_number_of_times')%> - <%= raw t('todos.recurrence.ends_on_number_times', :number => text_field( :recurring_todo, :number_of_occurences, "size" => 3)) %>
+ <%= raw t('todos.recurrence.ends_on_number_times', :number => text_field( :recurring_todo, :number_of_occurrences, "size" => 3)) %>
<%= radio_button_tag('recurring_todo[ends_on]', 'ends_on_end_date', @form_helper.ends_on == 'ends_on_end_date')%> <%= raw t('todos.recurrence.ends_on_date', :date => text_field_tag('recurring_todo_edit_end_date', format_date(@form_helper.end_date), "size" => 12, "class" => "Date", "autocomplete" => "off")) %>
diff --git a/app/views/recurring_todos/_recurring_todo_form.html.erb b/app/views/recurring_todos/_recurring_todo_form.html.erb index 124caf96..a00eec7a 100644 --- a/app/views/recurring_todos/_recurring_todo_form.html.erb +++ b/app/views/recurring_todos/_recurring_todo_form.html.erb @@ -34,7 +34,7 @@

<%= radio_button_tag('recurring_todo[ends_on]', 'no_end_date', true)%> <%= t('todos.recurrence.no_end_date') %>
- <%= radio_button_tag('recurring_todo[ends_on]', 'ends_on_number_of_times', false)%> <%= raw t('todos.recurrence.ends_on_number_times', :number => text_field( :recurring_todo, :number_of_occurences, "size" => 3)) %>
+ <%= radio_button_tag('recurring_todo[ends_on]', 'ends_on_number_of_times', false)%> <%= raw t('todos.recurrence.ends_on_number_times', :number => text_field( :recurring_todo, :number_of_occurrences, "size" => 3)) %>
<%= radio_button_tag('recurring_todo[ends_on]', 'ends_on_end_date', false)%> <%= raw t('todos.recurrence.ends_on_date', :date => text_field(:recurring_todo, :end_date, "size" => 12, "class" => "Date", "autocomplete" => "off", "value" => "")) %>
diff --git a/db/migrate/20150209233951_rename_occurences_to_occurrences.rb b/db/migrate/20150209233951_rename_occurences_to_occurrences.rb new file mode 100644 index 00000000..7b348402 --- /dev/null +++ b/db/migrate/20150209233951_rename_occurences_to_occurrences.rb @@ -0,0 +1,6 @@ +class RenameOccurencesToOccurrences < ActiveRecord::Migration + def change + rename_column :recurring_todos, :number_of_occurences, :number_of_occurrences + rename_column :recurring_todos, :occurences_count, :occurrences_count + end +end diff --git a/db/schema.rb b/db/schema.rb index 96516f59..37555542 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20130227205845) do +ActiveRecord::Schema.define(version: 20150209233951) do create_table "contexts", force: true do |t| t.string "name", null: false @@ -104,17 +104,17 @@ ActiveRecord::Schema.define(version: 20130227205845) do add_index "projects", ["user_id"], name: "index_projects_on_user_id", using: :btree create_table "recurring_todos", force: true do |t| - t.integer "user_id", default: 1 - t.integer "context_id", null: false + t.integer "user_id", default: 1 + t.integer "context_id", null: false t.integer "project_id" - t.string "description", null: false + t.string "description", null: false t.text "notes" - t.string "state", limit: 20, null: false + t.string "state", limit: 20, null: false t.datetime "start_from" t.string "ends_on" t.datetime "end_date" - t.integer "number_of_occurences" - t.integer "occurences_count", default: 0 + t.integer "number_of_occurrences" + t.integer "occurrences_count", default: 0 t.string "target" t.integer "show_from_delta" t.string "recurring_period" @@ -123,7 +123,7 @@ ActiveRecord::Schema.define(version: 20130227205845) do t.integer "every_other2" t.integer "every_other3" t.string "every_day" - t.boolean "only_work_days", default: false + t.boolean "only_work_days", default: false t.integer "every_count" t.integer "weekday" t.datetime "completed_at" diff --git a/lib/tracks/attribute_handler.rb b/lib/tracks/attribute_handler.rb index 43f36be8..7f784e2f 100644 --- a/lib/tracks/attribute_handler.rb +++ b/lib/tracks/attribute_handler.rb @@ -117,7 +117,7 @@ module Tracks :context, :project, # model attributes :context_id, :project_id, :description, :notes, :state, :start_from, - :ends_on, :end_date, :number_of_occurences, :occurences_count, :target, + :ends_on, :end_date, :number_of_occurrences, :occurrences_count, :target, :show_from_delta, :recurring_period, :recurrence_selector, :every_other1, :every_other2, :every_other3, :every_day, :only_work_days, :every_count, :weekday, :show_always, :context_name, :project_name, :tag_list, diff --git a/test/controllers/recurring_todos_controller_test.rb b/test/controllers/recurring_todos_controller_test.rb index c9c2bce7..5e37c263 100644 --- a/test/controllers/recurring_todos_controller_test.rb +++ b/test/controllers/recurring_todos_controller_test.rb @@ -47,7 +47,7 @@ class RecurringTodosControllerTest < ActionController::TestCase "monthly_every_xth_day"=>"1", "monthly_selector"=>"monthly_every_x_day", "notes"=>"with some notes", - "number_of_occurences" => "", + "number_of_occurrences" => "", "recurring_period"=>"yearly", "recurring_show_days_before"=>"10", "recurring_target"=>"due_date", @@ -91,7 +91,7 @@ class RecurringTodosControllerTest < ActionController::TestCase "monthly_every_xth_day"=>"1", "monthly_selector"=>"monthly_every_x_day", "notes"=>"with some notes", - "number_of_occurences" => "", + "number_of_occurrences" => "", "recurring_period"=>"yearly", "recurring_show_days_before"=>"10", "recurring_target"=>"due_date", @@ -141,7 +141,7 @@ class RecurringTodosControllerTest < ActionController::TestCase "monthly_every_xth_day"=>"1", "monthly_selector"=>"monthly_every_x_day", "notes"=>"with some notes", - "number_of_occurences" => "", + "number_of_occurrences" => "", "recurring_period"=>"yearly", "recurring_show_days_before"=>"10", "recurring_target"=>"due_date", @@ -255,7 +255,7 @@ class RecurringTodosControllerTest < ActionController::TestCase "monthly_every_xth_day"=>"1", "monthly_selector"=>"monthly_every_x_day", "notes"=>"with some notes", - "number_of_occurences" => "", + "number_of_occurrences" => "", "recurring_period"=>"yearly", "recurring_show_days_before"=>"0", "recurring_target"=>"due_date", @@ -309,7 +309,7 @@ class RecurringTodosControllerTest < ActionController::TestCase "monthly_every_xth_day"=>"1", "monthly_selector"=>"monthly_every_x_day", "notes"=>"with some notes", - "number_of_occurences" => "", + "number_of_occurrences" => "", "recurring_period"=>"yearly", "recurring_show_always"=>"1", "recurring_show_days_before"=>"0", @@ -361,7 +361,7 @@ class RecurringTodosControllerTest < ActionController::TestCase "monthly_every_xth_day"=>"1", "monthly_selector"=>"monthly_every_x_day", "notes"=>"with some notes", - "number_of_occurences" => nil, + "number_of_occurrences" => nil, "recurring_period"=>"monthly", "recurring_show_days_before"=>"0", "recurring_target"=>"show_from_date", diff --git a/test/fixtures/recurring_todos.yml b/test/fixtures/recurring_todos.yml index b1c4cf70..b5630c6b 100644 --- a/test/fixtures/recurring_todos.yml +++ b/test/fixtures/recurring_todos.yml @@ -36,7 +36,7 @@ call_bill_gates_every_day: start_from: <%= way_back %> ends_on: no_end_date end_date: ~ - number_of_occurences: ~ + number_of_occurrences: ~ target: due_date show_from_delta: ~ recurring_period: daily @@ -63,7 +63,7 @@ call_bill_gates_every_workday: start_from: ~ ends_on: no_end_date end_date: ~ - number_of_occurences: ~ + number_of_occurrences: ~ target: due_date show_from_delta: ~ show_always: false @@ -90,7 +90,7 @@ call_bill_gates_every_week: start_from: <%= way_back %> ends_on: no_end_date end_date: ~ - number_of_occurences: ~ + number_of_occurrences: ~ target: due_date show_from_delta: 5 recurring_period: weekly @@ -117,7 +117,7 @@ check_with_bill_every_last_friday_of_month: start_from: <%= way_back %> ends_on: no_end_date end_date: ~ - number_of_occurences: ~ + number_of_occurrences: ~ target: due_date show_from_delta: 5 recurring_period: monthly @@ -144,7 +144,7 @@ birthday_reinier: start_from: <%= way_back %> ends_on: no_end_date end_date: ~ - number_of_occurences: ~ + number_of_occurrences: ~ target: due_date show_from_delta: 5 show_always: false diff --git a/test/models/recurring_todo_test.rb b/test/models/recurring_todo_test.rb index 88be28a4..df93ef7e 100644 --- a/test/models/recurring_todo_test.rb +++ b/test/models/recurring_todo_test.rb @@ -151,21 +151,21 @@ class RecurringTodoTest < ActiveSupport::TestCase assert @yearly.starred? end - def test_occurence_count - @every_day.number_of_occurences = 2 + def test_occurrence_count + @every_day.number_of_occurrences = 2 assert_equal true, @every_day.continues_recurring?(@in_three_days) @every_day.increment_occurrences assert_equal true, @every_day.continues_recurring?(@in_three_days) @every_day.increment_occurrences assert_equal false, @every_day.continues_recurring?(@in_three_days) - # after completion, when you reactivate the recurring todo, the occurences + # after completion, when you reactivate the recurring todo, the occurrences # count should be reset - assert_equal 2, @every_day.occurences_count + assert_equal 2, @every_day.occurrences_count assert @every_day.toggle_completion! assert @every_day.toggle_completion! assert_equal true, @every_day.continues_recurring?(@in_three_days) - assert_equal 0, @every_day.occurences_count + assert_equal 0, @every_day.occurrences_count end end \ No newline at end of file diff --git a/test/models/recurring_todos/abstract_repeat_pattern_test.rb b/test/models/recurring_todos/abstract_repeat_pattern_test.rb index fcb3e025..b12594bb 100644 --- a/test/models/recurring_todos/abstract_repeat_pattern_test.rb +++ b/test/models/recurring_todos/abstract_repeat_pattern_test.rb @@ -73,7 +73,7 @@ module RecurringTodos assert pattern.valid?, "should be valid" end - def test_validation_on_number_of_occurences + def test_validation_on_number_of_occurrences attributes = { 'weekly_return_monday' => 'm', # weekly specific 'weekly_every_x_week' => 1, @@ -83,9 +83,9 @@ module RecurringTodos } # pattern = create_recurring_todo(attributes) -# assert !pattern.valid?, "number_of_occurences should be filled" +# assert !pattern.valid?, "number_of_occurrences should be filled" - attributes['number_of_occurences']=5 + attributes['number_of_occurrences']=5 pattern = create_recurring_todo(attributes) assert pattern.valid?, "should be valid" end @@ -110,12 +110,12 @@ module RecurringTodos assert !rt.continues_recurring?(Time.zone.now), "should end because end_date is in the past" rt.reload # reset - rt.number_of_occurences = 2 - rt.occurences_count = 1 - assert rt.continues_recurring?(Time.zone.now), "should continue since there still may come occurences" + rt.number_of_occurrences = 2 + rt.occurrences_count = 1 + assert rt.continues_recurring?(Time.zone.now), "should continue since there still may come occurrences" - rt.occurences_count = 2 - assert !rt.continues_recurring?(Time.zone.now), "should end since all occurences are there" + rt.occurrences_count = 2 + assert !rt.continues_recurring?(Time.zone.now), "should end since all occurrences are there" end def test_determine_start