Skip to content

Commit

Permalink
Add Rails 4 to CI (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
balvig authored Dec 26, 2021
1 parent dc1e369 commit e9274c2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ jobs:
workflows:
tests:
jobs:
- build:
matrix:
parameters:
rails_version: ["~> 4.0"]
ruby_version: ["2.6.6"]
- build:
matrix:
parameters:
Expand Down
6 changes: 3 additions & 3 deletions lib/spyke/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ def add_errors_to_model(errors_hash)
field_errors.each do |error_attributes|
error = NormalizedValidationError.new(error_attributes)

if errors.method(:add).arity == -2
errors.add(field.to_sym, error.message, **error.options)
else
if ActiveSupport::VERSION::MAJOR < 5
errors.add(field.to_sym, error.message, error.options)
else
errors.add(field.to_sym, error.message, **error.options)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/activemodel_dirty_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def test_attributes_instance_var_compatibility
recipe = RecipeWithDirty.new(title: 'Cheeseburger')

# If @attributes is set on recipe ActiveModel::Dirty will crash
assert_equal false, recipe.attribute_changed_in_place?(:title)
assert_equal({}, recipe.changes)
end
end
end
9 changes: 7 additions & 2 deletions test/attributes_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ def test_initializing_using_permitted_strong_params
end

def test_initializing_using_unpermitted_strong_params
assert_raises ActionController::UnfilteredParameters do
Ingredient.new(strong_params(name: 'Flour'))
if ActiveSupport::VERSION::MAJOR < 5
ingredient = Ingredient.new(strong_params(name: 'Flour'))
assert_equal({}, ingredient.attributes)
else
assert_raises ActionController::UnfilteredParameters do
Ingredient.new(strong_params(name: 'Flour'))
end
end
end

Expand Down

0 comments on commit e9274c2

Please sign in to comment.