diff --git a/ci/Gemfile-rails-7-1 b/ci/Gemfile-rails-7-1 new file mode 100644 index 0000000..679febd --- /dev/null +++ b/ci/Gemfile-rails-7-1 @@ -0,0 +1,5 @@ +source 'https://rubygems.org' + +gem 'activerecord', '~> 7.1.0' + +gemspec :path => "../" diff --git a/ci/Gemfile-rails-7-2 b/ci/Gemfile-rails-7-2 new file mode 100644 index 0000000..4529a7e --- /dev/null +++ b/ci/Gemfile-rails-7-2 @@ -0,0 +1,5 @@ +source 'https://rubygems.org' + +gem 'activerecord', '~> 7.2.0' + +gemspec :path => "../" diff --git a/lib/rails-properties/property_object.rb b/lib/rails-properties/property_object.rb index b4c221b..1580027 100644 --- a/lib/rails-properties/property_object.rb +++ b/lib/rails-properties/property_object.rb @@ -13,7 +13,11 @@ class PropertyObject < ActiveRecord::Base end end - serialize :value, Hash + if ActiveRecord.version >= Gem::Version.new('7.1') + serialize :value, coder: YAML, type: Hash + else + serialize :value, Hash + end if RailsProperties.can_protect_attributes? # attr_protected can not be used here because it touches the database which is not connected yet. diff --git a/lib/rails-properties/version.rb b/lib/rails-properties/version.rb index 52588cb..2fdae37 100644 --- a/lib/rails-properties/version.rb +++ b/lib/rails-properties/version.rb @@ -1,3 +1,3 @@ module RailsProperties - VERSION = '3.4.3' + VERSION = '3.5.0' end diff --git a/spec/properties_spec.rb b/spec/properties_spec.rb index ef613f9..2dd44d0 100644 --- a/spec/properties_spec.rb +++ b/spec/properties_spec.rb @@ -145,7 +145,7 @@ end it "should add properties" do - user.properties(:dashboard).update_attributes! :smart => true + user.properties(:dashboard).update! :smart => true user.reload expect(user.properties(:dashboard).smart).to eq(true) @@ -179,7 +179,7 @@ end it "should update properties" do - user.properties(:dashboard).update_attributes! :smart => true + user.properties(:dashboard).update! :smart => true user.reload expect(user.properties(:dashboard).smart).to eq(true) diff --git a/spec/property_object_spec.rb b/spec/property_object_spec.rb index 78020c1..c8d4c04 100644 --- a/spec/property_object_spec.rb +++ b/spec/property_object_spec.rb @@ -103,9 +103,9 @@ end end - describe "update_attributes" do + describe "update" do it 'should save' do - expect(new_property_object.update_attributes(:foo => 42, :bar => 'string')).to be_truthy + expect(new_property_object.update(:foo => 42, :bar => 'string')).to be_truthy new_property_object.reload expect(new_property_object.foo).to eq(42) @@ -115,12 +115,12 @@ end it 'should not save blank hash' do - expect(new_property_object.update_attributes({})).to be_truthy + expect(new_property_object.update({})).to be_truthy end if RailsProperties.can_protect_attributes? it 'should not allow changing protected attributes' do - new_property_object.update_attributes!(:var => 'calendar', :foo => 42) + new_property_object.update!(:var => 'calendar', :foo => 42) expect(new_property_object.var).to eq('dashboard') expect(new_property_object.foo).to eq(42) diff --git a/spec/queries_spec.rb b/spec/queries_spec.rb index 5077029..5db70ea 100644 --- a/spec/queries_spec.rb +++ b/spec/queries_spec.rb @@ -94,7 +94,7 @@ it "should update properties by one SQL query" do expect { - user.properties(:dashboard).update_attributes! :foo => 'bar' + user.properties(:dashboard).update! :foo => 'bar' }.to perform_queries(1) end end diff --git a/spec/serialize_spec.rb b/spec/serialize_spec.rb index 0a0365e..c45675a 100644 --- a/spec/serialize_spec.rb +++ b/spec/serialize_spec.rb @@ -25,7 +25,7 @@ describe 'updated properties' do it 'should be serialized' do - user.properties(:dashboard).update_attributes! :smart => true + user.properties(:dashboard).update! :smart => true dashboard_properties = user.property_objects.where(:var => 'dashboard').first calendar_properties = user.property_objects.where(:var => 'calendar').first