safe_attributes 1.0.9 → 1.0.10

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source :rubygems
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
- group :development do
12
- # For debugging under ruby 1.9 special gems are needed
13
- #gem 'ruby-debug19', :platform => :mri
14
- #gem 'ruby-debug-base19', '>=0.11.26'
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
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010,2011 C. Brian Jones
1
+ Copyright (c) 2010,2011,2012,2013 C. Brian Jones
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/NEWS.rdoc CHANGED
@@ -1,3 +1,7 @@
1
+ = Version 1.0.10
2
+
3
+ * The attribute 'association' should work better now
4
+
1
5
  = Version 1.0.9
2
6
 
3
7
  * Can avoid the railtie that automatically includes SafeAttributes, see README
@@ -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.3
71
- * JRuby 1.6.4
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
+
@@ -63,5 +63,9 @@ module SafeAttributes
63
63
  end
64
64
  end
65
65
 
66
+ def attribute_change(attr)
67
+ [changed_attributes[attr], read_attribute_for_validation(attr)] if attribute_changed?(attr)
68
+ end
69
+
66
70
  end
67
71
  end
@@ -2,7 +2,7 @@ module SafeAttributes
2
2
  module VERSION
3
3
  MAJOR = 1
4
4
  MINOR = 0
5
- TINY = 9
5
+ TINY = 10
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
8
8
  end
@@ -23,6 +23,5 @@ Gem::Specification.new do |s|
23
23
  s.add_development_dependency(%q<rake>, [">= 0.8.7"])
24
24
  s.add_development_dependency(%q<rdoc>, [">= 0"])
25
25
  s.add_development_dependency(%q<rspec>, [">= 2.3.0"])
26
- s.add_development_dependency(%q<sqlite3>, [">= 1.3.4"])
27
26
  end
28
27
 
@@ -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
 
@@ -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.9
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: 2012-10-16 00:00:00.000000000 Z
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.24
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