Skip to content

Commit

Permalink
Fix syntax errors for upgrade of Rails version
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeiP committed Jan 4, 2022
1 parent 28bdaa2 commit e7dd7f3
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions app/controllers/todos_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ def update
rescue ActiveRecord::RecordInvalid => exception
record = exception.record
if record.is_a?(Dependency)
record.errors.each { |key, value| @todo.errors[key] << value }
record.errors.each { |key, value| @todo.errors.add(key, value) }
end
@saved = false
end
Expand Down Expand Up @@ -1192,7 +1192,7 @@ def parse_date_for_update(date, error_msg)
begin
parse_date_per_user_prefs(date)
rescue
@todo.errors[:base] << error_msg
@todo.errors.add(:base, error_msg)
end
end

Expand Down
8 changes: 4 additions & 4 deletions app/models/recurring_todos/abstract_recurrence_pattern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ def valid?
end

def validate_not_blank(object, msg)
errors[:base] << msg if object.blank?
errors.add(:base, msg) if object.blank?
end

def validate_not_nil(object, msg)
errors[:base] << msg if object.nil?
errors.add(:base, msg) if object.nil?
end

def validate
Expand All @@ -100,7 +100,7 @@ def starts_and_ends_on_validations
when "ends_on_end_date"
validate_not_blank(end_date, "The end date needs to be filled in for 'Ends on'")
else
errors[:base] << "The end of the recurrence is not selected" unless ends_on == "no_end_date"
errors.add(:base, "The end of the recurrence is not selected") unless ends_on == "no_end_date"
end
end

Expand All @@ -113,7 +113,7 @@ def set_recurrence_on_validations
validate_not_nil(show_always?, "Please select when to show the action")
validate_not_blank(show_from_delta, "Please fill in the number of days to show the todo before the due date") unless show_always?
else
errors[:base] << "Unexpected value of recurrence target selector '#{target}'"
errors.add(:base, "Unexpected value of recurrence target selector '#{target}'")
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/recurring_todos/daily_recurrence_pattern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def recurrence_pattern

def validate
super
errors[:base] << "Every other nth day may not be empty for this daily recurrence setting" if (!only_work_days?) && every_x_days.blank?
errors.add(:base, "Every other nth day may not be empty for this daily recurrence setting") if (!only_work_days?) && every_x_days.blank?
end

def get_next_date(previous)
Expand Down
2 changes: 1 addition & 1 deletion app/models/recurring_todos/weekly_recurrence_pattern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def validate
super
validate_not_blank(every_x_week, "Every other nth week may not be empty for weekly recurrence setting")
something_set = %w{ sunday monday tuesday wednesday thursday friday saturday }.inject(false) { |set, day| set || send("on_#{day}") }
errors[:base] << "You must specify at least one day on which the todo recurs" unless something_set
errors.add(:base, "You must specify at least one day on which the todo recurs") unless something_set
end

def get_next_date(previous)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class ProjectsContextsRemoveNotNullFromPosition < ActiveRecord::Migration[5.2]
def self.up
change_column :projects, :position, :integer, {:null => true, :default => nil}
change_column :contexts, :position, :integer, {:null => true, :default => nil}
change_column :projects, :position, :integer, :null => true, :default => nil
change_column :contexts, :position, :integer, :null => true, :default => nil
end

def self.down
Expand All @@ -10,13 +10,13 @@ def self.down
project.position = 0 if !project.position?
project.save
end
change_column :projects, :position, :integer, {:null => false, :default => nil}
change_column :projects, :position, :integer, :null => false, :default => nil

@contexts = Context.find(:all)
@contexts.each do |context|
context.position = 0 if !context.position?
context.save
end
change_column :contexts, :position, :integer, {:null => false, :default => nil}
change_column :contexts, :position, :integer, :null => false, :default => nil
end
end
4 changes: 2 additions & 2 deletions test/models/todo_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -551,15 +551,15 @@ def test_attachments_are_removed_after_delete
new_path = attachment.file.path

# then the attachment should be there
assert File.exists?(new_path), "attachment should be on file system"
assert File.exist?(new_path), "attachment should be on file system"
assert_equal 1, todo.attachments.reload.count, "should have one attachment"

# When I destroy the todo
todo.destroy!

# Then the attachement and file should nogt be there anymore
assert_equal 0, todo.user.attachments.reload.count
assert !File.exists?(new_path), "attachment should not be on file system"
assert !File.exist?(new_path), "attachment should not be on file system"
end

def test_destroying_action_activates_successors
Expand Down

0 comments on commit e7dd7f3

Please sign in to comment.