hydra_attribute 0.3.2 → 0.4.0.rc1

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.
Files changed (65) hide show
  1. data/CHANGELOG.md +1 -1
  2. data/README.md +7 -0
  3. data/features/entity/create.feature +128 -0
  4. data/features/entity/destroy.feature +111 -0
  5. data/features/entity/new.feature +121 -0
  6. data/features/entity/update.feature +147 -0
  7. data/features/{attributes → hydra_attribute}/create.feature +7 -7
  8. data/features/{attributes → hydra_attribute}/destroy.feature +2 -4
  9. data/features/{attributes → hydra_attribute}/update.feature +10 -10
  10. data/features/hydra_set/destroy.feature +31 -0
  11. data/features/migrations/create_and_drop.feature +165 -0
  12. data/features/migrations/migrate_and_rollback.feature +211 -0
  13. data/features/relation/query_methods/group.feature +42 -0
  14. data/features/relation/query_methods/order.feature +67 -0
  15. data/features/relation/query_methods/reorder.feature +29 -0
  16. data/features/relation/query_methods/reverse_order.feature +29 -0
  17. data/features/relation/query_methods/select.feature +50 -0
  18. data/features/relation/query_methods/where.feature +70 -0
  19. data/features/step_definitions/connections.rb +65 -0
  20. data/features/step_definitions/model_steps.rb +79 -6
  21. data/features/step_definitions/query_methods.rb +3 -3
  22. data/features/step_definitions/record_steps.rb +3 -4
  23. data/features/support/env.rb +17 -3
  24. data/features/support/world.rb +15 -10
  25. data/gemfiles/3.1.gemfile.lock +15 -15
  26. data/gemfiles/3.2.gemfile.lock +15 -15
  27. data/lib/hydra_attribute/active_record/association.rb +74 -38
  28. data/lib/hydra_attribute/active_record/association_preloader.rb +49 -49
  29. data/lib/hydra_attribute/active_record/attribute_methods.rb +37 -85
  30. data/lib/hydra_attribute/active_record/migration.rb +2 -2
  31. data/lib/hydra_attribute/active_record/reflection.rb +1 -1
  32. data/lib/hydra_attribute/active_record/relation/query_methods.rb +8 -7
  33. data/lib/hydra_attribute/active_record/relation.rb +1 -0
  34. data/lib/hydra_attribute/active_record.rb +20 -12
  35. data/lib/hydra_attribute/association_builder.rb +1 -2
  36. data/lib/hydra_attribute/builder.rb +7 -8
  37. data/lib/hydra_attribute/entity_callbacks.rb +12 -32
  38. data/lib/hydra_attribute/hydra_attribute.rb +25 -16
  39. data/lib/hydra_attribute/hydra_attribute_methods.rb +85 -0
  40. data/lib/hydra_attribute/hydra_methods.rb +123 -0
  41. data/lib/hydra_attribute/hydra_set.rb +36 -0
  42. data/lib/hydra_attribute/hydra_set_methods.rb +39 -0
  43. data/lib/hydra_attribute/hydra_value_methods.rb +14 -0
  44. data/lib/hydra_attribute/memoize.rb +37 -0
  45. data/lib/hydra_attribute/migrator.rb +100 -51
  46. data/lib/hydra_attribute/railtie.rb +1 -3
  47. data/lib/hydra_attribute/version.rb +1 -1
  48. data/lib/hydra_attribute.rb +7 -1
  49. data/spec/hydra_attribute_methods_spec.rb +458 -0
  50. data/spec/hydra_attribute_spec.rb +19 -0
  51. data/spec/hydra_methods_spec.rb +457 -0
  52. data/spec/hydra_set_methods_spec.rb +203 -0
  53. data/spec/hydra_set_spec.rb +19 -0
  54. data/spec/memoize_spec.rb +95 -0
  55. data/spec/spec_helper.rb +42 -2
  56. metadata +71 -43
  57. data/features/create.feature +0 -47
  58. data/features/define.feature +0 -38
  59. data/features/destroy.feature +0 -102
  60. data/features/query_methods/group.feature +0 -42
  61. data/features/query_methods/order.feature +0 -99
  62. data/features/query_methods/select.feature +0 -50
  63. data/features/query_methods/where.feature +0 -70
  64. data/features/support/schema.rb +0 -79
  65. data/features/update.feature +0 -114
@@ -0,0 +1,95 @@
1
+ require 'spec_helper'
2
+
3
+ describe HydraAttribute::Memoize do
4
+ def anonymous(arity = 0)
5
+ params = (1..arity).map{ |i| "a#{i}" }.join(', ')
6
+
7
+ anonymous = Class.new do
8
+ extend HydraAttribute::Memoize
9
+
10
+ class_eval <<-EOS, __FILE__, __LINE__ + 1
11
+ def my_method(#{params})
12
+ result(#{params})
13
+ end
14
+ hydra_memoize :my_method
15
+ EOS
16
+ end
17
+ anonymous.new
18
+ end
19
+
20
+ describe '#memoize' do
21
+ it 'method without parameters' do
22
+ instance = anonymous
23
+ instance.should_receive(:result).once.and_return([1,2,3])
24
+ 2.times { instance.my_method.should == [1,2,3] }
25
+ end
26
+
27
+ it 'method without parameters which returns nil' do
28
+ instance = anonymous
29
+ instance.should_receive(:result).once.and_return(nil)
30
+ 2.times { instance.my_method.should == nil }
31
+ end
32
+
33
+ it 'method with one parameter' do
34
+ instance = anonymous(1)
35
+ instance.should_receive(:result).with(1).once.and_return([1,1,1])
36
+ instance.should_receive(:result).with(2).once.and_return([2,2,2])
37
+
38
+ 2.times { instance.my_method(1).should == [1,1,1] }
39
+ 2.times { instance.my_method(2).should == [2,2,2] }
40
+ end
41
+
42
+ it 'method with one parameter which returns nil' do
43
+ instance = anonymous(1)
44
+ instance.should_receive(:result).with(1).once.and_return(nil)
45
+ instance.should_receive(:result).with(2).once.and_return(nil)
46
+
47
+ 2.times { instance.my_method(1).should == nil }
48
+ 2.times { instance.my_method(2).should == nil }
49
+ end
50
+
51
+ it 'method with two parameters' do
52
+ instance = anonymous(2)
53
+ instance.should_receive(:result).with(1, 1).once.and_return([1,1,1])
54
+ instance.should_receive(:result).with(1, 2).once.and_return([1,1,2])
55
+ instance.should_receive(:result).with(2, 1).once.and_return([2,2,1])
56
+
57
+ 2.times { instance.my_method(1, 1).should == [1,1,1] }
58
+ 2.times { instance.my_method(1, 2).should == [1,1,2] }
59
+ 2.times { instance.my_method(2, 1).should == [2,2,1] }
60
+ end
61
+
62
+ it 'method with two parameters' do
63
+ instance = anonymous(2)
64
+ instance.should_receive(:result).with(1, 1).once.and_return(nil)
65
+ instance.should_receive(:result).with(1, 2).once.and_return(nil)
66
+ instance.should_receive(:result).with(2, 1).once.and_return(nil)
67
+
68
+ 2.times { instance.my_method(1, 1).should == nil }
69
+ 2.times { instance.my_method(1, 2).should == nil }
70
+ 2.times { instance.my_method(2, 1).should == nil }
71
+ end
72
+
73
+ it 'method with three parameters' do
74
+ instance = anonymous(3)
75
+ instance.should_receive(:result).with(1, 1, 2).once.and_return([1,1,2])
76
+ instance.should_receive(:result).with(1, 2, 2).once.and_return([1,2,2])
77
+ instance.should_receive(:result).with(2, 2, 1).once.and_return([2,2,1])
78
+
79
+ 2.times { instance.my_method(1, 1, 2).should == [1,1,2] }
80
+ 2.times { instance.my_method(1, 2, 2).should == [1,2,2] }
81
+ 2.times { instance.my_method(2, 2, 1).should == [2,2,1] }
82
+ end
83
+
84
+ it 'method with three parameters' do
85
+ instance = anonymous(3)
86
+ instance.should_receive(:result).with(1, 1, 2).once.and_return(nil)
87
+ instance.should_receive(:result).with(1, 2, 2).once.and_return(nil)
88
+ instance.should_receive(:result).with(2, 2, 1).once.and_return(nil)
89
+
90
+ 2.times { instance.my_method(1, 1, 2).should == nil }
91
+ 2.times { instance.my_method(1, 2, 2).should == nil }
92
+ 2.times { instance.my_method(2, 2, 1).should == nil }
93
+ end
94
+ end
95
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,12 +1,52 @@
1
1
  require 'active_record'
2
2
  require 'hydra_attribute'
3
+ require 'database_cleaner'
4
+
5
+ ActiveSupport.on_load(:active_record) do
6
+ self.default_timezone = :utc
7
+ unless ActiveRecord::VERSION::STRING.start_with?('3.1.') # @COMPATIBILITY with 3.1.x. active_record 3.1 doesn't have "mass_assignment_sanitizer" method
8
+ self.mass_assignment_sanitizer = :strict
9
+ end
10
+
11
+ ActiveRecord::Migration.send(:include, HydraAttribute::ActiveRecord::Migration)
12
+ end
3
13
 
4
14
  ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
5
- ActiveRecord::Base.extend(HydraAttribute::ActiveRecord)
15
+ DatabaseCleaner.strategy = :truncation
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
24
+
25
+ def down
26
+ end
27
+ end
28
+
29
+ Migration.new.up
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)
45
+ end
6
46
 
7
- require 'database_cleaner'
8
47
  RSpec.configure do |config|
9
48
  config.before do
49
+ redefine_hydra_entity('Product')
10
50
  DatabaseCleaner.start
11
51
  end
12
52
 
metadata CHANGED
@@ -1,19 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hydra_attribute
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
5
- prerelease:
4
+ version: 0.4.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: 2012-07-31 00:00:00.000000000Z
12
+ date: 2012-09-03 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
- requirement: &2152407120 !ruby/object:Gem::Requirement
16
+ requirement: &2156441720 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.1.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2152407120
24
+ version_requirements: *2156441720
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &2152406720 !ruby/object:Gem::Requirement
27
+ requirement: &2156436880 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2152406720
35
+ version_requirements: *2156436880
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: cucumber
38
- requirement: &2152406180 !ruby/object:Gem::Requirement
38
+ requirement: &2156427620 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2152406180
46
+ version_requirements: *2156427620
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: sqlite3
49
- requirement: &2152405740 !ruby/object:Gem::Requirement
49
+ requirement: &2156426920 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2152405740
57
+ version_requirements: *2156426920
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: database_cleaner
60
- requirement: &2152405300 !ruby/object:Gem::Requirement
60
+ requirement: &2156425880 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2152405300
68
+ version_requirements: *2156425880
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: appraisal
71
- requirement: &2152404880 !ruby/object:Gem::Requirement
71
+ requirement: &2156421380 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2152404880
79
+ version_requirements: *2156421380
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rake
82
- requirement: &2152404460 !ruby/object:Gem::Requirement
82
+ requirement: &2156408820 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *2152404460
90
+ version_requirements: *2156408820
91
91
  description: hydra_attribute is an implementation of EAV pattern for ActiveRecord
92
92
  models.
93
93
  email: kostya.stepanyuk@gmail.com
@@ -105,23 +105,28 @@ files:
105
105
  - README.md
106
106
  - Rakefile
107
107
  - cucumber.yml
108
- - features/attributes/create.feature
109
- - features/attributes/destroy.feature
110
- - features/attributes/update.feature
111
- - features/create.feature
112
- - features/define.feature
113
- - features/destroy.feature
114
- - features/query_methods/group.feature
115
- - features/query_methods/order.feature
116
- - features/query_methods/select.feature
117
- - features/query_methods/where.feature
108
+ - features/entity/create.feature
109
+ - features/entity/destroy.feature
110
+ - features/entity/new.feature
111
+ - features/entity/update.feature
112
+ - features/hydra_attribute/create.feature
113
+ - features/hydra_attribute/destroy.feature
114
+ - features/hydra_attribute/update.feature
115
+ - features/hydra_set/destroy.feature
116
+ - features/migrations/create_and_drop.feature
117
+ - features/migrations/migrate_and_rollback.feature
118
+ - features/relation/query_methods/group.feature
119
+ - features/relation/query_methods/order.feature
120
+ - features/relation/query_methods/reorder.feature
121
+ - features/relation/query_methods/reverse_order.feature
122
+ - features/relation/query_methods/select.feature
123
+ - features/relation/query_methods/where.feature
124
+ - features/step_definitions/connections.rb
118
125
  - features/step_definitions/model_steps.rb
119
126
  - features/step_definitions/query_methods.rb
120
127
  - features/step_definitions/record_steps.rb
121
128
  - features/support/env.rb
122
- - features/support/schema.rb
123
129
  - features/support/world.rb
124
- - features/update.feature
125
130
  - gemfiles/3.1.gemfile
126
131
  - gemfiles/3.1.gemfile.lock
127
132
  - gemfiles/3.2.gemfile
@@ -142,12 +147,24 @@ files:
142
147
  - lib/hydra_attribute/configuration.rb
143
148
  - lib/hydra_attribute/entity_callbacks.rb
144
149
  - lib/hydra_attribute/hydra_attribute.rb
150
+ - lib/hydra_attribute/hydra_attribute_methods.rb
151
+ - lib/hydra_attribute/hydra_methods.rb
152
+ - lib/hydra_attribute/hydra_set.rb
153
+ - lib/hydra_attribute/hydra_set_methods.rb
154
+ - lib/hydra_attribute/hydra_value_methods.rb
155
+ - lib/hydra_attribute/memoize.rb
145
156
  - lib/hydra_attribute/migrator.rb
146
157
  - lib/hydra_attribute/railtie.rb
147
158
  - lib/hydra_attribute/version.rb
148
159
  - lib/rails/generators/hydra_attribute/install/USAGE
149
160
  - lib/rails/generators/hydra_attribute/install/install_generator.rb
150
161
  - lib/rails/generators/hydra_attribute/install/templates/hydra_attribute.txt
162
+ - spec/hydra_attribute_methods_spec.rb
163
+ - spec/hydra_attribute_spec.rb
164
+ - spec/hydra_methods_spec.rb
165
+ - spec/hydra_set_methods_spec.rb
166
+ - spec/hydra_set_spec.rb
167
+ - spec/memoize_spec.rb
151
168
  - spec/spec_helper.rb
152
169
  homepage: https://github.com/kostyantyn/hydra_attribute
153
170
  licenses: []
@@ -164,9 +181,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
164
181
  required_rubygems_version: !ruby/object:Gem::Requirement
165
182
  none: false
166
183
  requirements:
167
- - - ! '>='
184
+ - - ! '>'
168
185
  - !ruby/object:Gem::Version
169
- version: '0'
186
+ version: 1.3.1
170
187
  requirements: []
171
188
  rubyforge_project:
172
189
  rubygems_version: 1.8.10
@@ -175,25 +192,36 @@ specification_version: 3
175
192
  summary: hydra_attribute is an implementation of EAV pattern for ActiveRecord models.
176
193
  test_files:
177
194
  - Appraisals
178
- - features/attributes/create.feature
179
- - features/attributes/destroy.feature
180
- - features/attributes/update.feature
181
- - features/create.feature
182
- - features/define.feature
183
- - features/destroy.feature
184
- - features/query_methods/group.feature
185
- - features/query_methods/order.feature
186
- - features/query_methods/select.feature
187
- - features/query_methods/where.feature
195
+ - features/entity/create.feature
196
+ - features/entity/destroy.feature
197
+ - features/entity/new.feature
198
+ - features/entity/update.feature
199
+ - features/hydra_attribute/create.feature
200
+ - features/hydra_attribute/destroy.feature
201
+ - features/hydra_attribute/update.feature
202
+ - features/hydra_set/destroy.feature
203
+ - features/migrations/create_and_drop.feature
204
+ - features/migrations/migrate_and_rollback.feature
205
+ - features/relation/query_methods/group.feature
206
+ - features/relation/query_methods/order.feature
207
+ - features/relation/query_methods/reorder.feature
208
+ - features/relation/query_methods/reverse_order.feature
209
+ - features/relation/query_methods/select.feature
210
+ - features/relation/query_methods/where.feature
211
+ - features/step_definitions/connections.rb
188
212
  - features/step_definitions/model_steps.rb
189
213
  - features/step_definitions/query_methods.rb
190
214
  - features/step_definitions/record_steps.rb
191
215
  - features/support/env.rb
192
- - features/support/schema.rb
193
216
  - features/support/world.rb
194
- - features/update.feature
195
217
  - gemfiles/3.1.gemfile
196
218
  - gemfiles/3.1.gemfile.lock
197
219
  - gemfiles/3.2.gemfile
198
220
  - gemfiles/3.2.gemfile.lock
221
+ - spec/hydra_attribute_methods_spec.rb
222
+ - spec/hydra_attribute_spec.rb
223
+ - spec/hydra_methods_spec.rb
224
+ - spec/hydra_set_methods_spec.rb
225
+ - spec/hydra_set_spec.rb
226
+ - spec/memoize_spec.rb
199
227
  - spec/spec_helper.rb
@@ -1,47 +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
- Background: create hydra attributes
6
- Given create hydra attributes for "Product" with role "admin" as "hashes":
7
- | name | backend_type | default_value | white_list |
8
- | [string:code] | [string:string] | [nil:] | [boolean:true] |
9
- | [string:price] | [string:float] | [string:0] | [boolean:true] |
10
- | [string:active] | [string:boolean] | [string:0] | [boolean:true] |
11
- | [string:info] | [string:text] | [string:] | [boolean:true] |
12
- | [string:started] | [string:datetime] | [string:2012-01-01] | [boolean:true] |
13
-
14
- Scenario: create model without hydra attributes
15
- Given create "Product" model
16
- Then last created "Product" should have the following attributes:
17
- | code | [nil:] |
18
- | price | [float:0] |
19
- | active | [boolean:false] |
20
- | info | [string:] |
21
- | started | [datetime:2012-01-01] |
22
-
23
- Scenario: create model with several hydra attributes
24
- Given create "Product" model with attributes as "rows_hash":
25
- | code | [string:a] |
26
- | price | [nil:] |
27
- Then last created "Product" should have the following attributes:
28
- | code | [string:a] |
29
- | price | [nil:] |
30
- | active | [boolean:false] |
31
- | info | [string:] |
32
- | started | [datetime:2012-01-01] |
33
-
34
- Scenario: create model hydra attributes
35
- Given create "Product" model with attributes as "rows_hash":
36
- | code | [string:a] |
37
- | price | [string:2] |
38
- | active | [boolean:true] |
39
- | info | [string:b] |
40
- | started | [datetime:2012-05-05] |
41
-
42
- Then last created "Product" should have the following attributes:
43
- | code | [string:a] |
44
- | price | [float:2] |
45
- | active | [boolean:true] |
46
- | info | [string:b] |
47
- | started | [datetime:2012-05-05] |
@@ -1,38 +0,0 @@
1
- Feature: define hydra attributes
2
- When use_hydra_attributes was called in model class
3
- Then entity should respond to attributes which are saved in hydra_attributes table
4
-
5
- Background: create hydra attributes
6
- Given create hydra attributes for "Product" with role "admin" as "hashes":
7
- | name | backend_type | white_list |
8
- | [string:code] | [string:string] | [boolean:true] |
9
- | [string:price] | [string:float] | [boolean:false] |
10
-
11
- Scenario Outline: models should respond to hydra attributes
12
- Then model "<model>" <action> respond to "<attributes>"
13
-
14
- Scenarios: hydra attributes
15
- | model | action | attributes |
16
- | Product | should | code |
17
- | Product | should | code= |
18
- | Product | should | code? |
19
- | Product | should | code_before_type_cast |
20
- | Product | should | code_changed? |
21
- | Product | should | code_change |
22
- | Product | should | code_will_change! |
23
- | Product | should | code_was |
24
- | Product | should | reset_code! |
25
- | Product | should | price |
26
- | Product | should | price= |
27
- | Product | should | price? |
28
- | Product | should | price_before_type_cast |
29
- | Product | should | price_changed? |
30
- | Product | should | price_change |
31
- | Product | should | price_will_change! |
32
- | Product | should | price_was |
33
- | Product | should | reset_price! |
34
-
35
- Scenario: model should have appropriate attributes in white list
36
- When redefine "Product" class to use hydra attributes
37
- Then class "Product" should have "code" in white list
38
- And class "Product" should not have "price" in white list
@@ -1,102 +0,0 @@
1
- Feature: destroy model
2
- When destroy model
3
- Then all associated values should be deleted too
4
-
5
- Background: create hydra attributes
6
- Given create hydra attributes for "Product" with role "admin" as "hashes":
7
- | name | backend_type | default_value | white_list |
8
- | [string:code] | [string:string] | [nil:] | [boolean:true] |
9
- | [string:price] | [string:float] | [string:0] | [boolean:true] |
10
- | [string:active] | [string:boolean] | [string:0] | [boolean:true] |
11
- | [string:info] | [string:text] | [string:] | [boolean:true] |
12
- | [string:started] | [string:datetime] | [string:2012-01-01] | [boolean:true] |
13
-
14
- Scenario: destroy model
15
- Given create "Product" model with attributes as "hashes":
16
- | code | price | active | info | started |
17
- | [string:1] | [float:1] | [boolean:true] | [string:a] | [string:2012-01-01] |
18
- | [string:2] | [float:2] | [boolean:true] | [string:b] | [string:2012-01-02] |
19
- | [string:3] | [float:3] | [boolean:true] | [string:c] | [string:2012-01-03] |
20
- | [string:4] | [float:4] | [boolean:true] | [string:d] | [string:2012-01-04] |
21
- | [string:5] | [float:5] | [boolean:true] | [string:e] | [string:2012-01-05] |
22
-
23
- When select first "HydraAttribute::HydraStringProduct" record
24
- Then record read attribute "value" and value should be "[string:1]"
25
- When select first "HydraAttribute::HydraFloatProduct" record
26
- Then record read attribute "value" and value should be "[float:1]"
27
- When select first "HydraAttribute::HydraBooleanProduct" record
28
- Then record read attribute "value" and value should be "[boolean:true]"
29
- When select first "HydraAttribute::HydraTextProduct" record
30
- Then record read attribute "value" and value should be "[string:a]"
31
- When select first "HydraAttribute::HydraDatetimeProduct" record
32
- Then record read attribute "value" and value should be "[string:2012-01-01]"
33
-
34
- Given select first "Product" record
35
- And destroy record
36
-
37
- When select first "HydraAttribute::HydraStringProduct" record
38
- Then record read attribute "value" and value should be "[string:2]"
39
- When select first "HydraAttribute::HydraFloatProduct" record
40
- Then record read attribute "value" and value should be "[float:2]"
41
- When select first "HydraAttribute::HydraBooleanProduct" record
42
- Then record read attribute "value" and value should be "[boolean:true]"
43
- When select first "HydraAttribute::HydraTextProduct" record
44
- Then record read attribute "value" and value should be "[string:b]"
45
- When select first "HydraAttribute::HydraDatetimeProduct" record
46
- Then record read attribute "value" and value should be "[string:2012-01-02]"
47
-
48
- Given select first "Product" record
49
- And destroy record
50
-
51
- When select first "HydraAttribute::HydraStringProduct" record
52
- Then record read attribute "value" and value should be "[string:3]"
53
- When select first "HydraAttribute::HydraFloatProduct" record
54
- Then record read attribute "value" and value should be "[float:3]"
55
- When select first "HydraAttribute::HydraBooleanProduct" record
56
- Then record read attribute "value" and value should be "[boolean:true]"
57
- When select first "HydraAttribute::HydraTextProduct" record
58
- Then record read attribute "value" and value should be "[string:c]"
59
- When select first "HydraAttribute::HydraDatetimeProduct" record
60
- Then record read attribute "value" and value should be "[string:2012-01-03]"
61
-
62
- Given select first "Product" record
63
- And destroy record
64
-
65
- When select first "HydraAttribute::HydraStringProduct" record
66
- Then record read attribute "value" and value should be "[string:4]"
67
- When select first "HydraAttribute::HydraFloatProduct" record
68
- Then record read attribute "value" and value should be "[float:4]"
69
- When select first "HydraAttribute::HydraBooleanProduct" record
70
- Then record read attribute "value" and value should be "[boolean:true]"
71
- When select first "HydraAttribute::HydraTextProduct" record
72
- Then record read attribute "value" and value should be "[string:d]"
73
- When select first "HydraAttribute::HydraDatetimeProduct" record
74
- Then record read attribute "value" and value should be "[string:2012-01-04]"
75
-
76
- Given select first "Product" record
77
- And destroy record
78
-
79
- When select first "HydraAttribute::HydraStringProduct" record
80
- Then record read attribute "value" and value should be "[string:5]"
81
- When select first "HydraAttribute::HydraFloatProduct" record
82
- Then record read attribute "value" and value should be "[float:5]"
83
- When select first "HydraAttribute::HydraBooleanProduct" record
84
- Then record read attribute "value" and value should be "[boolean:true]"
85
- When select first "HydraAttribute::HydraTextProduct" record
86
- Then record read attribute "value" and value should be "[string:e]"
87
- When select first "HydraAttribute::HydraDatetimeProduct" record
88
- Then record read attribute "value" and value should be "[string:2012-01-05]"
89
-
90
- Given select first "Product" record
91
- And destroy record
92
-
93
- When select first "HydraAttribute::HydraStringProduct" record
94
- Then record should be nil
95
- When select first "HydraAttribute::HydraFloatProduct" record
96
- Then record should be nil
97
- When select first "HydraAttribute::HydraBooleanProduct" record
98
- Then record should be nil
99
- When select first "HydraAttribute::HydraTextProduct" record
100
- Then record should be nil
101
- When select first "HydraAttribute::HydraDatetimeProduct" record
102
- Then record should be nil
@@ -1,42 +0,0 @@
1
- Feature: group conditions by hydra attributes
2
- When group by hydra attribute
3
- Then correct table should be joined and group condition should be added
4
-
5
- Background: create models and describe hydra attributes
6
- Given create hydra attributes for "Product" with role "admin" as "hashes":
7
- | name | backend_type | white_list |
8
- | [string:code] | [string:integer] | [boolean:true] |
9
- | [string:title] | [string:string] | [boolean:true] |
10
- | [string:total] | [string:integer] | [boolean:true] |
11
- Given create "Product" model with attributes as "hashes":
12
- | name | code | title | total |
13
- | [string:a] | [integer:1] | [string:q] | [integer:5] |
14
- | [string:b] | [integer:2] | [string:w] | [integer:5] |
15
- | [string:b] | [integer:3] | [string:w] | [nil:] |
16
- | [string:c] | [integer:4] | [string:e] | |
17
-
18
- Scenario Outline: group by attributes
19
- When group "Product" by "<group by>"
20
- Then total records should be "<total>"
21
- And "first" record should have "<first attribute>"
22
- And "last" record should have "<last attribute>"
23
-
24
- Scenarios: group attributes
25
- | group by | total | first attribute | last attribute |
26
- | code | 4 | code=[integer:1] | code=[integer:4] |
27
- | name | 3 | name=[string:a] code=[integer:1] | name=[string:c] code=[integer:4] |
28
- | name title | 3 | name=[string:a] code=[integer:1] | name=[string:c] code=[integer:4] |
29
-
30
- Scenario Outline: group by attributes with filter
31
- When group "Product" by "<group by>"
32
- And filter records by "<filter>"
33
- Then total records should be "<total>"
34
- And "first" record should have "<first attribute>"
35
- And "last" record should have "<last attribute>"
36
-
37
- Scenarios: group attributes
38
- | group by | filter | total | first attribute | last attribute |
39
- | code | title=[string:w] | 2 | code=[integer:2] | code=[integer:3] |
40
- | name | title=[string:w] | 1 | name=[string:b] title=[string:w] | name=[string:b] title=[string:w] |
41
- | name title | title=[string:w] | 1 | name=[string:b] title=[string:w] | name=[string:b] title=[string:w] |
42
- | name title | total=[nil:] | 2 | name=[string:b] title=[string:w] | name=[string:c] title=[string:e] |