Sha256: 3d826411070d7d68c66b66cd6c7c01f04570bcb56955360e9c3eb4e920f81f98
Contents?: true
Size: 1.2 KB
Versions: 2
Compression:
Stored size: 1.2 KB
Contents
require 'test_helper' class ProtectedAttrsTest < ActiveSupport::TestCase subject { ProtectedWidget.new } accessible_attrs = ProtectedWidget.accessible_attributes.to_a accessible_attrs.each do |attr_name| should allow_mass_assignment_of(attr_name.to_sym) end ProtectedWidget.column_names.reject { |column_name| accessible_attrs.include?(column_name) }.each do |attr_name| should_not allow_mass_assignment_of(attr_name.to_sym) end context 'A model with `attr_accessible` created' do setup do @widget = ProtectedWidget.create! :name => 'Henry' @initial_attributes = @widget.attributes end should 'be `nil` in its previous version' do assert_nil @widget.previous_version end context 'which is then updated' do setup do @widget.assign_attributes(:name => 'Jeff', :a_text => 'Short statement') @widget.an_integer = 42 @widget.save! end should 'not be `nil` in its previous version' do assert_not_nil @widget.previous_version end should 'the previous version should contain right attributes' do assert_equal @widget.previous_version.attributes, @initial_attributes end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
paper_trail-2.7.2 | test/unit/protected_attrs_test.rb |
paper_trail-2.7.1 | test/unit/protected_attrs_test.rb |