hydra_attribute 0.4.2 → 0.5.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/.travis.yml +6 -5
- data/CHANGELOG.md +6 -0
- data/Gemfile +1 -1
- data/README.md +3 -3
- data/Rakefile +2 -7
- data/gemfiles/activerecord-3.2.gemfile +5 -0
- data/hydra_attribute.gemspec +6 -7
- data/lib/hydra_attribute.rb +17 -18
- data/lib/hydra_attribute/active_record.rb +34 -13
- data/lib/hydra_attribute/active_record/association_preloader.rb +47 -28
- data/lib/hydra_attribute/active_record/attribute_methods.rb +29 -140
- data/lib/hydra_attribute/active_record/mass_assignment_security.rb +39 -0
- data/lib/hydra_attribute/active_record/migration.rb +4 -4
- data/lib/hydra_attribute/active_record/relation.rb +6 -7
- data/lib/hydra_attribute/active_record/relation/query_methods.rb +28 -18
- data/lib/hydra_attribute/hydra_attribute.rb +12 -49
- data/lib/hydra_attribute/hydra_attribute_set.rb +67 -0
- data/lib/hydra_attribute/hydra_entity.rb +110 -0
- data/lib/hydra_attribute/hydra_entity_attribute_association.rb +155 -0
- data/lib/hydra_attribute/hydra_set.rb +24 -26
- data/lib/hydra_attribute/hydra_value.rb +210 -0
- data/lib/hydra_attribute/identity_map.rb +18 -0
- data/lib/hydra_attribute/middleware/identity_map.rb +15 -0
- data/lib/hydra_attribute/migrator.rb +24 -21
- data/lib/hydra_attribute/model.rb +47 -0
- data/lib/hydra_attribute/model/cacheable.rb +207 -0
- data/lib/hydra_attribute/model/dirty.rb +39 -0
- data/lib/hydra_attribute/model/has_many_through.rb +168 -0
- data/lib/hydra_attribute/model/identity_map.rb +59 -0
- data/lib/hydra_attribute/model/mediator.rb +89 -0
- data/lib/hydra_attribute/model/notifiable.rb +23 -0
- data/lib/hydra_attribute/model/persistence.rb +424 -0
- data/lib/hydra_attribute/model/validations.rb +40 -0
- data/lib/hydra_attribute/version.rb +1 -1
- data/spec/environments/mysql.rb +23 -0
- data/spec/environments/postgresql.rb +23 -0
- data/spec/environments/sqlite.rb +12 -0
- data/spec/fixtures/category.rb +8 -0
- data/spec/fixtures/product.rb +8 -0
- data/spec/fixtures/product_black_list.rb +13 -0
- data/spec/fixtures/product_white_list.rb +13 -0
- data/spec/hydra_attribute/active_record/attribute_methods_spec.rb +23 -28
- data/spec/hydra_attribute/active_record/mass_assignment_security_spec.rb +41 -0
- data/spec/hydra_attribute/active_record_spec.rb +577 -0
- data/spec/hydra_attribute/hydra_attribute_set_spec.rb +651 -0
- data/spec/hydra_attribute/hydra_attribute_spec.rb +208 -10
- data/spec/hydra_attribute/hydra_entity_attribute_association_spec.rb +216 -0
- data/spec/hydra_attribute/hydra_entity_spec.rb +71 -0
- data/spec/hydra_attribute/hydra_set_spec.rb +51 -10
- data/spec/hydra_attribute/hydra_value_spec.rb +286 -0
- data/spec/hydra_attribute/identity_map_spec.rb +47 -0
- data/spec/hydra_attribute/migrator_spec.rb +411 -0
- data/spec/hydra_attribute/model/cacheable_spec.rb +106 -0
- data/spec/hydra_attribute/model/has_many_through_spec.rb +132 -0
- data/spec/hydra_attribute/model/identity_map_spec.rb +39 -0
- data/spec/hydra_attribute/model/mediator_spec.rb +62 -0
- data/spec/hydra_attribute/model/persistence_spec.rb +550 -0
- data/spec/hydra_attribute/model_spec.rb +39 -0
- data/spec/hydra_attribute_spec.rb +36 -0
- data/spec/spec_helper.rb +10 -42
- metadata +76 -100
- data/Appraisals +0 -7
- data/cucumber.yml +0 -1
- data/features/entity/create.feature +0 -145
- data/features/entity/destroy.feature +0 -111
- data/features/entity/new.feature +0 -121
- data/features/entity/update.feature +0 -147
- data/features/hydra_attribute/create.feature +0 -30
- data/features/hydra_attribute/destroy.feature +0 -26
- data/features/hydra_attribute/update.feature +0 -36
- data/features/hydra_set/destroy.feature +0 -31
- data/features/migrations/create_and_drop.feature +0 -165
- data/features/migrations/migrate_and_rollback.feature +0 -211
- data/features/relation/query_methods/group.feature +0 -42
- data/features/relation/query_methods/order.feature +0 -67
- data/features/relation/query_methods/reorder.feature +0 -29
- data/features/relation/query_methods/reverse_order.feature +0 -29
- data/features/relation/query_methods/select.feature +0 -50
- data/features/relation/query_methods/where.feature +0 -115
- data/features/step_definitions/connections.rb +0 -65
- data/features/step_definitions/model_steps.rb +0 -136
- data/features/step_definitions/query_methods.rb +0 -48
- data/features/step_definitions/record_steps.rb +0 -93
- data/features/support/env.rb +0 -38
- data/features/support/world.rb +0 -61
- data/lib/hydra_attribute/active_record/association.rb +0 -113
- data/lib/hydra_attribute/active_record/reflection.rb +0 -16
- data/lib/hydra_attribute/association_builder.rb +0 -69
- data/lib/hydra_attribute/builder.rb +0 -37
- data/lib/hydra_attribute/entity_callbacks.rb +0 -26
- data/lib/hydra_attribute/hydra_attribute_methods.rb +0 -226
- data/lib/hydra_attribute/hydra_methods.rb +0 -528
- data/lib/hydra_attribute/hydra_set_methods.rb +0 -95
- data/lib/hydra_attribute/hydra_value_methods.rb +0 -21
- data/lib/hydra_attribute/memoizable.rb +0 -37
- data/spec/hydra_attribute/active_record/relation/query_methods_spec.rb +0 -31
- data/spec/hydra_attribute/hydra_attribute_methods_spec.rb +0 -458
- data/spec/hydra_attribute/hydra_methods_spec.rb +0 -456
- data/spec/hydra_attribute/hydra_set_methods_spec.rb +0 -203
- data/spec/hydra_attribute/memoizable_spec.rb +0 -95
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HydraAttribute::Model do
|
4
|
+
describe '.first' do
|
5
|
+
before do
|
6
|
+
Product.hydra_attributes.create(name: 'yyy', backend_type: 'string')
|
7
|
+
Product.hydra_attributes.create(name: 'aaa', backend_type: 'string')
|
8
|
+
Product.hydra_attributes.create(name: 'zzz', backend_type: 'string')
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should return first created model' do
|
12
|
+
HydraAttribute::HydraAttribute.first.name.should == 'yyy'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '.last' do
|
17
|
+
before do
|
18
|
+
Product.hydra_attributes.create(name: 'yyy', backend_type: 'string')
|
19
|
+
Product.hydra_attributes.create(name: 'aaa', backend_type: 'string')
|
20
|
+
Product.hydra_attributes.create(name: 'bbb', backend_type: 'string')
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should return last created model' do
|
24
|
+
HydraAttribute::HydraAttribute.last.name.should == 'bbb'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '.count' do
|
29
|
+
before do
|
30
|
+
Product.hydra_attributes.create(name: 'yyy', backend_type: 'string')
|
31
|
+
Product.hydra_attributes.create(name: 'aaa', backend_type: 'string')
|
32
|
+
Product.hydra_attributes.create(name: 'bbb', backend_type: 'string')
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should return number of created models' do
|
36
|
+
HydraAttribute::HydraAttribute.count.should be(3)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HydraAttribute do
|
4
|
+
describe '#identity_map' do
|
5
|
+
it 'should return IdentityMap object' do
|
6
|
+
HydraAttribute.identity_map.should be_a_kind_of(HydraAttribute::IdentityMap)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should cache identity map object' do
|
10
|
+
im1 = HydraAttribute.identity_map
|
11
|
+
im2 = HydraAttribute.identity_map
|
12
|
+
im1.should be(im2)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should store identity map into current thread' do
|
16
|
+
im = HydraAttribute.identity_map
|
17
|
+
Thread.current[:hydra_attribute].should be(im)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#cache' do
|
22
|
+
it 'should proxy method to identity map' do
|
23
|
+
HydraAttribute.cache(:a, 1)
|
24
|
+
HydraAttribute.identity_map.cache(:a, 2).should be(1)
|
25
|
+
|
26
|
+
HydraAttribute.cache(:b) { 1 }
|
27
|
+
HydraAttribute.identity_map.cache(:b) { 2 }.should be(1)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'SUPPORTED_BACKEND_TYPES' do
|
32
|
+
it 'should include "string", "text", "integer", "float", "decimal", "boolean" and "datetime"' do
|
33
|
+
HydraAttribute::SUPPORTED_BACKEND_TYPES.should == %w[string text integer float decimal boolean datetime]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,56 +1,24 @@
|
|
1
|
-
require 'active_record'
|
2
1
|
require 'hydra_attribute'
|
3
|
-
require 'database_cleaner'
|
4
2
|
|
5
3
|
ActiveSupport.on_load(:active_record) do
|
6
|
-
self.default_timezone
|
7
|
-
|
8
|
-
self.mass_assignment_sanitizer = :strict
|
9
|
-
end
|
10
|
-
|
11
|
-
ActiveRecord::Migration.send(:include, HydraAttribute::ActiveRecord::Migration)
|
4
|
+
self.default_timezone = :utc
|
5
|
+
self.mass_assignment_sanitizer = :strict
|
12
6
|
end
|
13
7
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
class Migration < ActiveRecord::Migration
|
18
|
-
def up
|
19
|
-
create_hydra_entity :products do |t|
|
20
|
-
t.string :name
|
21
|
-
t.timestamps
|
22
|
-
end
|
23
|
-
end
|
8
|
+
ENV['DB'] ||= 'sqlite'
|
9
|
+
require File.expand_path("../environments/#{ENV['DB']}", __FILE__)
|
24
10
|
|
25
|
-
|
26
|
-
|
11
|
+
if ENV['SQL_LOGGER']
|
12
|
+
require 'active_support/all'
|
13
|
+
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
27
14
|
end
|
28
15
|
|
29
|
-
|
30
|
-
|
31
|
-
def redefine_hydra_entity(klass)
|
32
|
-
::ActiveSupport::Dependencies.clear
|
33
|
-
|
34
|
-
Object.send(:remove_const, klass.to_sym) if Object.const_defined?(klass.to_sym)
|
35
|
-
|
36
|
-
::HydraAttribute::SUPPORTED_BACKEND_TYPES.each do |type|
|
37
|
-
class_name = "Hydra#{type.capitalize}#{klass}".to_sym
|
38
|
-
::HydraAttribute.send(:remove_const, class_name) if ::HydraAttribute.const_defined?(class_name)
|
39
|
-
end
|
40
|
-
|
41
|
-
Object.const_set(klass.to_sym, Class.new(::ActiveRecord::Base))
|
42
|
-
klass.to_s.constantize.send(:accessible_attributes_configs).values.each(&:clear)
|
43
|
-
klass.to_s.constantize.attr_accessible :name, :hydra_set_id
|
44
|
-
klass.to_s.constantize.send(:include, ::HydraAttribute::ActiveRecord)
|
16
|
+
Dir[File.expand_path('../fixtures/*.rb', __FILE__)].each do |file|
|
17
|
+
load file
|
45
18
|
end
|
46
19
|
|
47
20
|
RSpec.configure do |config|
|
48
21
|
config.before do
|
49
|
-
|
50
|
-
DatabaseCleaner.start
|
51
|
-
end
|
52
|
-
|
53
|
-
config.after do
|
54
|
-
DatabaseCleaner.clean
|
22
|
+
Thread.current[:hydra_attribute] = nil
|
55
23
|
end
|
56
24
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hydra_attribute
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.5.0.rc1
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Kostyantyn Stepanyuk
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-10-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '3.
|
21
|
+
version: '3.2'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,39 +26,23 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '3.
|
29
|
+
version: '3.2'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: rspec
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
35
|
-
- -
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0'
|
38
|
-
type: :development
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: cucumber
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ! '>='
|
35
|
+
- - ~>
|
52
36
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
37
|
+
version: '2.13'
|
54
38
|
type: :development
|
55
39
|
prerelease: false
|
56
40
|
version_requirements: !ruby/object:Gem::Requirement
|
57
41
|
none: false
|
58
42
|
requirements:
|
59
|
-
- -
|
43
|
+
- - ~>
|
60
44
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
45
|
+
version: '2.13'
|
62
46
|
- !ruby/object:Gem::Dependency
|
63
47
|
name: sqlite3
|
64
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -76,7 +60,7 @@ dependencies:
|
|
76
60
|
- !ruby/object:Gem::Version
|
77
61
|
version: '0'
|
78
62
|
- !ruby/object:Gem::Dependency
|
79
|
-
name:
|
63
|
+
name: mysql2
|
80
64
|
requirement: !ruby/object:Gem::Requirement
|
81
65
|
none: false
|
82
66
|
requirements:
|
@@ -92,7 +76,7 @@ dependencies:
|
|
92
76
|
- !ruby/object:Gem::Version
|
93
77
|
version: '0'
|
94
78
|
- !ruby/object:Gem::Dependency
|
95
|
-
name:
|
79
|
+
name: pg
|
96
80
|
requirement: !ruby/object:Gem::Requirement
|
97
81
|
none: false
|
98
82
|
requirements:
|
@@ -133,72 +117,72 @@ files:
|
|
133
117
|
- .gitignore
|
134
118
|
- .rspec
|
135
119
|
- .travis.yml
|
136
|
-
- Appraisals
|
137
120
|
- CHANGELOG.md
|
138
121
|
- Gemfile
|
139
122
|
- LICENSE
|
140
123
|
- README.md
|
141
124
|
- Rakefile
|
142
|
-
-
|
143
|
-
- features/entity/create.feature
|
144
|
-
- features/entity/destroy.feature
|
145
|
-
- features/entity/new.feature
|
146
|
-
- features/entity/update.feature
|
147
|
-
- features/hydra_attribute/create.feature
|
148
|
-
- features/hydra_attribute/destroy.feature
|
149
|
-
- features/hydra_attribute/update.feature
|
150
|
-
- features/hydra_set/destroy.feature
|
151
|
-
- features/migrations/create_and_drop.feature
|
152
|
-
- features/migrations/migrate_and_rollback.feature
|
153
|
-
- features/relation/query_methods/group.feature
|
154
|
-
- features/relation/query_methods/order.feature
|
155
|
-
- features/relation/query_methods/reorder.feature
|
156
|
-
- features/relation/query_methods/reverse_order.feature
|
157
|
-
- features/relation/query_methods/select.feature
|
158
|
-
- features/relation/query_methods/where.feature
|
159
|
-
- features/step_definitions/connections.rb
|
160
|
-
- features/step_definitions/model_steps.rb
|
161
|
-
- features/step_definitions/query_methods.rb
|
162
|
-
- features/step_definitions/record_steps.rb
|
163
|
-
- features/support/env.rb
|
164
|
-
- features/support/world.rb
|
125
|
+
- gemfiles/activerecord-3.2.gemfile
|
165
126
|
- hydra_attribute.gemspec
|
166
127
|
- lib/hydra_attribute.rb
|
167
128
|
- lib/hydra_attribute/active_record.rb
|
168
|
-
- lib/hydra_attribute/active_record/association.rb
|
169
129
|
- lib/hydra_attribute/active_record/association_preloader.rb
|
170
130
|
- lib/hydra_attribute/active_record/attribute_methods.rb
|
131
|
+
- lib/hydra_attribute/active_record/mass_assignment_security.rb
|
171
132
|
- lib/hydra_attribute/active_record/migration.rb
|
172
|
-
- lib/hydra_attribute/active_record/reflection.rb
|
173
133
|
- lib/hydra_attribute/active_record/relation.rb
|
174
134
|
- lib/hydra_attribute/active_record/relation/calculations.rb
|
175
135
|
- lib/hydra_attribute/active_record/relation/query_methods.rb
|
176
136
|
- lib/hydra_attribute/active_record/scoping.rb
|
177
|
-
- lib/hydra_attribute/association_builder.rb
|
178
|
-
- lib/hydra_attribute/builder.rb
|
179
137
|
- lib/hydra_attribute/configuration.rb
|
180
|
-
- lib/hydra_attribute/entity_callbacks.rb
|
181
138
|
- lib/hydra_attribute/hydra_attribute.rb
|
182
|
-
- lib/hydra_attribute/
|
183
|
-
- lib/hydra_attribute/
|
139
|
+
- lib/hydra_attribute/hydra_attribute_set.rb
|
140
|
+
- lib/hydra_attribute/hydra_entity.rb
|
141
|
+
- lib/hydra_attribute/hydra_entity_attribute_association.rb
|
184
142
|
- lib/hydra_attribute/hydra_set.rb
|
185
|
-
- lib/hydra_attribute/
|
186
|
-
- lib/hydra_attribute/
|
187
|
-
- lib/hydra_attribute/
|
143
|
+
- lib/hydra_attribute/hydra_value.rb
|
144
|
+
- lib/hydra_attribute/identity_map.rb
|
145
|
+
- lib/hydra_attribute/middleware/identity_map.rb
|
188
146
|
- lib/hydra_attribute/migrator.rb
|
147
|
+
- lib/hydra_attribute/model.rb
|
148
|
+
- lib/hydra_attribute/model/cacheable.rb
|
149
|
+
- lib/hydra_attribute/model/dirty.rb
|
150
|
+
- lib/hydra_attribute/model/has_many_through.rb
|
151
|
+
- lib/hydra_attribute/model/identity_map.rb
|
152
|
+
- lib/hydra_attribute/model/mediator.rb
|
153
|
+
- lib/hydra_attribute/model/notifiable.rb
|
154
|
+
- lib/hydra_attribute/model/persistence.rb
|
155
|
+
- lib/hydra_attribute/model/validations.rb
|
189
156
|
- lib/hydra_attribute/railtie.rb
|
190
157
|
- lib/hydra_attribute/version.rb
|
191
158
|
- lib/rails/generators/hydra_attribute/install/USAGE
|
192
159
|
- lib/rails/generators/hydra_attribute/install/install_generator.rb
|
193
160
|
- lib/rails/generators/hydra_attribute/install/templates/hydra_attribute.txt
|
161
|
+
- spec/environments/mysql.rb
|
162
|
+
- spec/environments/postgresql.rb
|
163
|
+
- spec/environments/sqlite.rb
|
164
|
+
- spec/fixtures/category.rb
|
165
|
+
- spec/fixtures/product.rb
|
166
|
+
- spec/fixtures/product_black_list.rb
|
167
|
+
- spec/fixtures/product_white_list.rb
|
194
168
|
- spec/hydra_attribute/active_record/attribute_methods_spec.rb
|
195
|
-
- spec/hydra_attribute/active_record/
|
196
|
-
- spec/hydra_attribute/
|
169
|
+
- spec/hydra_attribute/active_record/mass_assignment_security_spec.rb
|
170
|
+
- spec/hydra_attribute/active_record_spec.rb
|
171
|
+
- spec/hydra_attribute/hydra_attribute_set_spec.rb
|
197
172
|
- spec/hydra_attribute/hydra_attribute_spec.rb
|
198
|
-
- spec/hydra_attribute/
|
199
|
-
- spec/hydra_attribute/
|
173
|
+
- spec/hydra_attribute/hydra_entity_attribute_association_spec.rb
|
174
|
+
- spec/hydra_attribute/hydra_entity_spec.rb
|
200
175
|
- spec/hydra_attribute/hydra_set_spec.rb
|
201
|
-
- spec/hydra_attribute/
|
176
|
+
- spec/hydra_attribute/hydra_value_spec.rb
|
177
|
+
- spec/hydra_attribute/identity_map_spec.rb
|
178
|
+
- spec/hydra_attribute/migrator_spec.rb
|
179
|
+
- spec/hydra_attribute/model/cacheable_spec.rb
|
180
|
+
- spec/hydra_attribute/model/has_many_through_spec.rb
|
181
|
+
- spec/hydra_attribute/model/identity_map_spec.rb
|
182
|
+
- spec/hydra_attribute/model/mediator_spec.rb
|
183
|
+
- spec/hydra_attribute/model/persistence_spec.rb
|
184
|
+
- spec/hydra_attribute/model_spec.rb
|
185
|
+
- spec/hydra_attribute_spec.rb
|
202
186
|
- spec/spec_helper.rb
|
203
187
|
homepage: https://github.com/kostyantyn/hydra_attribute
|
204
188
|
licenses: []
|
@@ -215,48 +199,40 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
215
199
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
216
200
|
none: false
|
217
201
|
requirements:
|
218
|
-
- - ! '
|
202
|
+
- - ! '>'
|
219
203
|
- !ruby/object:Gem::Version
|
220
|
-
version:
|
221
|
-
segments:
|
222
|
-
- 0
|
223
|
-
hash: -595006172525400845
|
204
|
+
version: 1.3.1
|
224
205
|
requirements: []
|
225
206
|
rubyforge_project:
|
226
|
-
rubygems_version: 1.8.
|
207
|
+
rubygems_version: 1.8.25
|
227
208
|
signing_key:
|
228
209
|
specification_version: 3
|
229
210
|
summary: hydra_attribute is an implementation of EAV pattern for ActiveRecord models.
|
230
211
|
test_files:
|
231
|
-
-
|
232
|
-
-
|
233
|
-
-
|
234
|
-
-
|
235
|
-
-
|
236
|
-
-
|
237
|
-
-
|
238
|
-
-
|
239
|
-
- features/hydra_set/destroy.feature
|
240
|
-
- features/migrations/create_and_drop.feature
|
241
|
-
- features/migrations/migrate_and_rollback.feature
|
242
|
-
- features/relation/query_methods/group.feature
|
243
|
-
- features/relation/query_methods/order.feature
|
244
|
-
- features/relation/query_methods/reorder.feature
|
245
|
-
- features/relation/query_methods/reverse_order.feature
|
246
|
-
- features/relation/query_methods/select.feature
|
247
|
-
- features/relation/query_methods/where.feature
|
248
|
-
- features/step_definitions/connections.rb
|
249
|
-
- features/step_definitions/model_steps.rb
|
250
|
-
- features/step_definitions/query_methods.rb
|
251
|
-
- features/step_definitions/record_steps.rb
|
252
|
-
- features/support/env.rb
|
253
|
-
- features/support/world.rb
|
212
|
+
- gemfiles/activerecord-3.2.gemfile
|
213
|
+
- spec/environments/mysql.rb
|
214
|
+
- spec/environments/postgresql.rb
|
215
|
+
- spec/environments/sqlite.rb
|
216
|
+
- spec/fixtures/category.rb
|
217
|
+
- spec/fixtures/product.rb
|
218
|
+
- spec/fixtures/product_black_list.rb
|
219
|
+
- spec/fixtures/product_white_list.rb
|
254
220
|
- spec/hydra_attribute/active_record/attribute_methods_spec.rb
|
255
|
-
- spec/hydra_attribute/active_record/
|
256
|
-
- spec/hydra_attribute/
|
221
|
+
- spec/hydra_attribute/active_record/mass_assignment_security_spec.rb
|
222
|
+
- spec/hydra_attribute/active_record_spec.rb
|
223
|
+
- spec/hydra_attribute/hydra_attribute_set_spec.rb
|
257
224
|
- spec/hydra_attribute/hydra_attribute_spec.rb
|
258
|
-
- spec/hydra_attribute/
|
259
|
-
- spec/hydra_attribute/
|
225
|
+
- spec/hydra_attribute/hydra_entity_attribute_association_spec.rb
|
226
|
+
- spec/hydra_attribute/hydra_entity_spec.rb
|
260
227
|
- spec/hydra_attribute/hydra_set_spec.rb
|
261
|
-
- spec/hydra_attribute/
|
228
|
+
- spec/hydra_attribute/hydra_value_spec.rb
|
229
|
+
- spec/hydra_attribute/identity_map_spec.rb
|
230
|
+
- spec/hydra_attribute/migrator_spec.rb
|
231
|
+
- spec/hydra_attribute/model/cacheable_spec.rb
|
232
|
+
- spec/hydra_attribute/model/has_many_through_spec.rb
|
233
|
+
- spec/hydra_attribute/model/identity_map_spec.rb
|
234
|
+
- spec/hydra_attribute/model/mediator_spec.rb
|
235
|
+
- spec/hydra_attribute/model/persistence_spec.rb
|
236
|
+
- spec/hydra_attribute/model_spec.rb
|
237
|
+
- spec/hydra_attribute_spec.rb
|
262
238
|
- spec/spec_helper.rb
|
data/Appraisals
DELETED
data/cucumber.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
default: -r features
|
@@ -1,145 +0,0 @@
|
|
1
|
-
Feature: create models with hydra attributes
|
2
|
-
When create model with hydra attributes
|
3
|
-
Then hydra attributes should be saved with default values
|
4
|
-
|
5
|
-
When hydra set is specified
|
6
|
-
Then only attributes from this hydra set should be saved
|
7
|
-
|
8
|
-
Background: create hydra attributes
|
9
|
-
Given create hydra attributes for "Product" with role "admin" as "hashes":
|
10
|
-
| name | backend_type | default_value | white_list |
|
11
|
-
| code | string | [nil:] | [bool:t] |
|
12
|
-
| info | text | [str:] | [bool:t] |
|
13
|
-
| total | integer | 0 | [bool:t] |
|
14
|
-
| price | float | 0 | [bool:t] |
|
15
|
-
| active | boolean | 0 | [bool:t] |
|
16
|
-
| started | datetime | 2012-01-01 | [bool:t] |
|
17
|
-
|
18
|
-
Scenario: don't pass any hydra attributes
|
19
|
-
Given create "Product" model
|
20
|
-
Then last created "Product" should have the following attributes:
|
21
|
-
| code | [nil:] |
|
22
|
-
| info | [str:] |
|
23
|
-
| price | [float:0] |
|
24
|
-
| total | [int:0] |
|
25
|
-
| active | [bool:f] |
|
26
|
-
| started | [date:2012-01-01] |
|
27
|
-
|
28
|
-
Scenario: pass two hydra attributes
|
29
|
-
Given create "Product" model with attributes as "rows_hash":
|
30
|
-
| code | a |
|
31
|
-
| price | [nil:] |
|
32
|
-
Then last created "Product" should have the following attributes:
|
33
|
-
| code | a |
|
34
|
-
| info | [str:] |
|
35
|
-
| total | [int:0] |
|
36
|
-
| price | [nil:] |
|
37
|
-
| active | [bool:f] |
|
38
|
-
| started | [date:2012-01-01] |
|
39
|
-
|
40
|
-
Scenario: pass all hydra attributes
|
41
|
-
Given create "Product" model with attributes as "rows_hash":
|
42
|
-
| code | a |
|
43
|
-
| info | b |
|
44
|
-
| total | 0 |
|
45
|
-
| price | 2 |
|
46
|
-
| active | 1 |
|
47
|
-
| started | 2012-05-05 |
|
48
|
-
|
49
|
-
Then last created "Product" should have the following attributes:
|
50
|
-
| code | a |
|
51
|
-
| price | [float:2] |
|
52
|
-
| active | [bool:t] |
|
53
|
-
| info | b |
|
54
|
-
| started | [date:2012-05-05] |
|
55
|
-
|
56
|
-
Scenario: create hydra attribute in runtime
|
57
|
-
# create product to cache all hydra attributes
|
58
|
-
Given create "Product" model
|
59
|
-
And create hydra attributes for "Product" with role "admin" as "hashes":
|
60
|
-
| name | backend_type | default_value | white_list |
|
61
|
-
| quantity | integer | [nil:] | [bool:t] |
|
62
|
-
And create "Product" model with attributes as "rows_hash":
|
63
|
-
| quantity | 5 |
|
64
|
-
Then last created "Product" should have the following attributes:
|
65
|
-
| code | [nil:] |
|
66
|
-
| info | [str:] |
|
67
|
-
| price | [float:0] |
|
68
|
-
| total | [int:0] |
|
69
|
-
| active | [bool:f] |
|
70
|
-
| started | [date:2012-01-01] |
|
71
|
-
| quantity | [int:5] |
|
72
|
-
|
73
|
-
Scenario: pass only hydra_set_id
|
74
|
-
Given create hydra sets for "Product" as "hashes":
|
75
|
-
| name |
|
76
|
-
| Default |
|
77
|
-
| General |
|
78
|
-
And add "Product" hydra attributes to hydra set:
|
79
|
-
| hydra attribute name | hydra set name |
|
80
|
-
| code | [array:Default] |
|
81
|
-
| price | [array:Default] |
|
82
|
-
| active | [array:Default,General] |
|
83
|
-
| info | [array:General] |
|
84
|
-
|
85
|
-
When create "Product" model with attributes as "rows_hash":
|
86
|
-
| hydra_set_id | [eval:Product.hydra_sets.find_by_name('Default').id] |
|
87
|
-
Then table "hydra_string_products" should have 1 record:
|
88
|
-
| entity_id | hydra_attribute_id |
|
89
|
-
| [eval:Product.last.id] | [eval:Product.hydra_attributes.find_by_name('code').id] |
|
90
|
-
And table "hydra_float_products" should have 1 record:
|
91
|
-
| entity_id | hydra_attribute_id |
|
92
|
-
| [eval:Product.last.id] | [eval:Product.hydra_attributes.find_by_name('price').id] |
|
93
|
-
And table "hydra_boolean_products" should have 1 record:
|
94
|
-
| entity_id | hydra_attribute_id |
|
95
|
-
| [eval:Product.last.id] | [eval:Product.hydra_attributes.find_by_name('active').id] |
|
96
|
-
And table "hydra_text_products" should have 0 records
|
97
|
-
And table "hydra_integer_products" should have 0 records
|
98
|
-
And table "hydra_datetime_products" should have 0 records
|
99
|
-
|
100
|
-
When create "Product" model with attributes as "rows_hash":
|
101
|
-
| hydra_set_id | [eval:Product.hydra_sets.find_by_name('General').id] |
|
102
|
-
And table "hydra_boolean_products" should have 2 records:
|
103
|
-
| entity_id | hydra_attribute_id |
|
104
|
-
| [eval:Product.last.id] | [eval:Product.hydra_attributes.find_by_name('active').id] |
|
105
|
-
And table "hydra_text_products" should have 1 record:
|
106
|
-
| entity_id | hydra_attribute_id |
|
107
|
-
| [eval:Product.last.id] | [eval:Product.hydra_attributes.find_by_name('info').id] |
|
108
|
-
And table "hydra_string_products" should have 1 record:
|
109
|
-
| entity_id | hydra_attribute_id |
|
110
|
-
| [eval:Product.first.id] | [eval:Product.hydra_attributes.find_by_name('code').id] |
|
111
|
-
And table "hydra_float_products" should have 1 record:
|
112
|
-
| entity_id | hydra_attribute_id |
|
113
|
-
| [eval:Product.first.id] | [eval:Product.hydra_attributes.find_by_name('price').id] |
|
114
|
-
And table "hydra_integer_products" should have 0 records
|
115
|
-
And table "hydra_datetime_products" should have 0 records
|
116
|
-
|
117
|
-
Scenario: build model with all attributes, set hydra_set_id and save it
|
118
|
-
Given create hydra sets for "Product" as "hashes":
|
119
|
-
| name |
|
120
|
-
| Default |
|
121
|
-
| General |
|
122
|
-
And add "Product" hydra attributes to hydra set:
|
123
|
-
| hydra attribute name | hydra set name |
|
124
|
-
| code | [array:Default] |
|
125
|
-
| price | [array:Default] |
|
126
|
-
| active | [array:Default,General] |
|
127
|
-
| info | [array:General] |
|
128
|
-
When build "Product" model:
|
129
|
-
| code | #123 |
|
130
|
-
| price | 2.50 |
|
131
|
-
| active | 1 |
|
132
|
-
| info | desc |
|
133
|
-
| started | 2012-08-20 |
|
134
|
-
And set "hydra_set_id" to "[eval:Product.hydra_sets.find_by_name('General').id]"
|
135
|
-
And save model
|
136
|
-
Then table "hydra_text_products" should have 1 record:
|
137
|
-
| entity_id | hydra_attribute_id |
|
138
|
-
| [eval:Product.last.id] | [eval:Product.hydra_attributes.find_by_name('info').id] |
|
139
|
-
And table "hydra_boolean_products" should have 1 record:
|
140
|
-
| entity_id | hydra_attribute_id |
|
141
|
-
| [eval:Product.last.id] | [eval:Product.hydra_attributes.find_by_name('active').id] |
|
142
|
-
And table "hydra_float_products" should have 0 records
|
143
|
-
And table "hydra_string_products" should have 0 records
|
144
|
-
And table "hydra_integer_products" should have 0 records
|
145
|
-
And table "hydra_datetime_products" should have 0 records
|