Skip to content

Instantly share code, notes, and snippets.

@pixeltrix
Last active October 7, 2015 15:08
Show Gist options
  • Save pixeltrix/3184003 to your computer and use it in GitHub Desktop.
Save pixeltrix/3184003 to your computer and use it in GitHub Desktop.
How to override mass-assignment protection globally in specs
class TestSanitizer < ActiveModel::MassAssignmentSecurity::Sanitizer
def sanitize(klass, attributes, authorizer)
attributes
end
end
ActiveRecord::Base.mass_assignment_sanitizer = TestSanitizer.new
it "creates a model" do
Model.should_receive(:create).with(:name => "Foo Bar")
Model.create(:name => "Foo Bar")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment