safe_attributes 1.0.9 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +5 -7
- data/LICENSE +1 -1
- data/NEWS.rdoc +4 -0
- data/README.rdoc +6 -8
- data/lib/safe_attributes/base.rb +4 -0
- data/lib/safe_attributes/version.rb +1 -1
- data/safe_attributes.gemspec +0 -1
- data/spec/safe_attributes/safe_attributes_spec.rb +31 -0
- data/spec/spec_helper.rb +1 -1
- metadata +3 -22
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
@@ -8,9 +8,7 @@ group :test do
|
|
8
8
|
gem 'simplecov', :require => false, :platform => :mri
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
#gem 'linecache19', '>=0.5.13'
|
16
|
-
end
|
11
|
+
gem 'debugger', :platform => :mri_19
|
12
|
+
gem 'sqlite3', :platform => :ruby
|
13
|
+
gem 'jruby-openssl', :platform => :jruby
|
14
|
+
gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
|
data/LICENSE
CHANGED
data/NEWS.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -66,13 +66,9 @@ without issue using the recommended approach above.
|
|
66
66
|
|
67
67
|
This gem has been tested with:
|
68
68
|
|
69
|
-
* Ruby 1.8.7
|
70
|
-
* Ruby 1.9.
|
71
|
-
* JRuby 1.
|
72
|
-
|
73
|
-
Note that as of Sept. 25, 2011, jruby 1.6.4 failed some tests when using
|
74
|
-
ActiveRecord 3.1. Google indicates others have seen these issues so I
|
75
|
-
expect it will be addressed in the near future by a new jruby release.
|
69
|
+
* Ruby Enterprise Edition 1.8.7 2012-02-08
|
70
|
+
* Ruby 1.9.3p374
|
71
|
+
* JRuby 1.7.2
|
76
72
|
|
77
73
|
=== Rails
|
78
74
|
Add safe_attributes to your Gemfile.
|
@@ -123,10 +119,12 @@ get the developers of ActiveRecord to agree to a patch.
|
|
123
119
|
|
124
120
|
== Copyright
|
125
121
|
|
126
|
-
Copyright (c) 2010,2011,2012 C. Brian Jones. See LICENSE for details.
|
122
|
+
Copyright (c) 2010,2011,2012,2013 C. Brian Jones. See LICENSE for details.
|
127
123
|
|
128
124
|
== Thanks
|
129
125
|
|
130
126
|
* Jaime Bellmyer - http://kconrails.com
|
131
127
|
* James Brennan
|
132
128
|
* Billy Watson
|
129
|
+
* Jean Boussier
|
130
|
+
|
data/lib/safe_attributes/base.rb
CHANGED
data/safe_attributes.gemspec
CHANGED
@@ -12,6 +12,8 @@ ActiveRecord::Base.connection.create_table(:my_models) do |t|
|
|
12
12
|
t.string :errors
|
13
13
|
# support hyphenated column names
|
14
14
|
t.string :"comment-frequency"
|
15
|
+
# Issue #8
|
16
|
+
t.string :association
|
15
17
|
end
|
16
18
|
|
17
19
|
class MyModel < ActiveRecord::Base
|
@@ -115,6 +117,14 @@ describe "models" do
|
|
115
117
|
m[:"comment-frequency"].should == 'often'
|
116
118
|
end
|
117
119
|
|
120
|
+
it "can create instance in database with attribute 'association'" do
|
121
|
+
m = MyModel.new(:class => 'Foo')
|
122
|
+
m[:association] = 'worker'
|
123
|
+
m.save!
|
124
|
+
m = MyModel.find(m.id)
|
125
|
+
m[:association].should == 'worker'
|
126
|
+
end
|
127
|
+
|
118
128
|
it "has class attribute" do
|
119
129
|
MyModel.new().has_attribute?('class').should be_true
|
120
130
|
end
|
@@ -155,5 +165,26 @@ describe "models" do
|
|
155
165
|
m.valid?.should be_true
|
156
166
|
end
|
157
167
|
|
168
|
+
describe "dirty" do
|
169
|
+
it "new record - no changes" do
|
170
|
+
@model.class_changed?.should be_false
|
171
|
+
@model.class_change.should be_nil
|
172
|
+
end
|
173
|
+
|
174
|
+
it "changed record - has changes" do
|
175
|
+
@model[:class] = 'arrr'
|
176
|
+
@model.class_changed?.should be_true
|
177
|
+
@model.class_was.should be_nil
|
178
|
+
@model.class_change.should == [nil, 'arrr']
|
179
|
+
end
|
180
|
+
|
181
|
+
it "saved record - no changes" do
|
182
|
+
@model[:class] = 'arrr'
|
183
|
+
@model.save!
|
184
|
+
@model.class_changed?.should be_false
|
185
|
+
@model.class_change.should be_nil
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
158
189
|
end
|
159
190
|
|
data/spec/spec_helper.rb
CHANGED
@@ -13,7 +13,7 @@ require 'rspec/autorun'
|
|
13
13
|
|
14
14
|
root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
15
15
|
ActiveRecord::Base.establish_connection(
|
16
|
-
:adapter => "sqlite3",
|
16
|
+
:adapter => (RUBY_PLATFORM == 'java') ? "jdbcsqlite3" : "sqlite3",
|
17
17
|
:database => "#{root}/db/safeattributes.db"
|
18
18
|
)
|
19
19
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: safe_attributes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-03-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -75,22 +75,6 @@ dependencies:
|
|
75
75
|
- - ! '>='
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: 2.3.0
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: sqlite3
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
|
-
requirements:
|
83
|
-
- - ! '>='
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: 1.3.4
|
86
|
-
type: :development
|
87
|
-
prerelease: false
|
88
|
-
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
|
-
requirements:
|
91
|
-
- - ! '>='
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: 1.3.4
|
94
78
|
description: Better support for legacy database schemas for ActiveRecord, such as
|
95
79
|
columns named class, or any other name that conflicts with an instance method of
|
96
80
|
ActiveRecord.
|
@@ -125,9 +109,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
125
109
|
- - ! '>='
|
126
110
|
- !ruby/object:Gem::Version
|
127
111
|
version: '0'
|
128
|
-
segments:
|
129
|
-
- 0
|
130
|
-
hash: -522687641704913606
|
131
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
113
|
none: false
|
133
114
|
requirements:
|
@@ -136,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
117
|
version: 1.8.10
|
137
118
|
requirements: []
|
138
119
|
rubyforge_project:
|
139
|
-
rubygems_version: 1.8.
|
120
|
+
rubygems_version: 1.8.25
|
140
121
|
signing_key:
|
141
122
|
specification_version: 3
|
142
123
|
summary: Useful for legacy database support, adds support for reserved word column
|