Module: RSpecCandy::Helpers::Rails::StoreWithValues
- Defined in:
- lib/rspec_candy/helpers/rails/store_with_values.rb
Instance Method Summary collapse
- #create_without_callbacks(*args) ⇒ Object
- #new_and_store(*args) ⇒ Object
- #store_with_values(values = {}) ⇒ Object
Instance Method Details
#create_without_callbacks(*args) ⇒ Object
29 30 31 32 |
# File 'lib/rspec_candy/helpers/rails/store_with_values.rb', line 29 def create_without_callbacks(*args) warn 'create_without_callbacks is deprecated because the name suggested that it honors mass-assignment protection. Use store_with_values instead.' store_with_values(*args) end |
#new_and_store(*args) ⇒ Object
24 25 26 27 |
# File 'lib/rspec_candy/helpers/rails/store_with_values.rb', line 24 def new_and_store(*args) warn 'new_and_store is deprecated. Use store_with_values instead.' store_with_values(*args) end |
#store_with_values(values = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rspec_candy/helpers/rails/store_with_values.rb', line 6 def store_with_values(values = {}) record = new case Switcher.active_record_version when 2 record.send(:attributes=, values, false) record.send(:create_without_callbacks) when 3 require 'sneaky-save' record.assign_attributes(values, :without_protection => true) record.sneaky_save else require 'sneaky-save' record.assign_attributes(values) record.sneaky_save end record end |