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.
Files changed (101) hide show
  1. data/.gitignore +2 -1
  2. data/.travis.yml +6 -5
  3. data/CHANGELOG.md +6 -0
  4. data/Gemfile +1 -1
  5. data/README.md +3 -3
  6. data/Rakefile +2 -7
  7. data/gemfiles/activerecord-3.2.gemfile +5 -0
  8. data/hydra_attribute.gemspec +6 -7
  9. data/lib/hydra_attribute.rb +17 -18
  10. data/lib/hydra_attribute/active_record.rb +34 -13
  11. data/lib/hydra_attribute/active_record/association_preloader.rb +47 -28
  12. data/lib/hydra_attribute/active_record/attribute_methods.rb +29 -140
  13. data/lib/hydra_attribute/active_record/mass_assignment_security.rb +39 -0
  14. data/lib/hydra_attribute/active_record/migration.rb +4 -4
  15. data/lib/hydra_attribute/active_record/relation.rb +6 -7
  16. data/lib/hydra_attribute/active_record/relation/query_methods.rb +28 -18
  17. data/lib/hydra_attribute/hydra_attribute.rb +12 -49
  18. data/lib/hydra_attribute/hydra_attribute_set.rb +67 -0
  19. data/lib/hydra_attribute/hydra_entity.rb +110 -0
  20. data/lib/hydra_attribute/hydra_entity_attribute_association.rb +155 -0
  21. data/lib/hydra_attribute/hydra_set.rb +24 -26
  22. data/lib/hydra_attribute/hydra_value.rb +210 -0
  23. data/lib/hydra_attribute/identity_map.rb +18 -0
  24. data/lib/hydra_attribute/middleware/identity_map.rb +15 -0
  25. data/lib/hydra_attribute/migrator.rb +24 -21
  26. data/lib/hydra_attribute/model.rb +47 -0
  27. data/lib/hydra_attribute/model/cacheable.rb +207 -0
  28. data/lib/hydra_attribute/model/dirty.rb +39 -0
  29. data/lib/hydra_attribute/model/has_many_through.rb +168 -0
  30. data/lib/hydra_attribute/model/identity_map.rb +59 -0
  31. data/lib/hydra_attribute/model/mediator.rb +89 -0
  32. data/lib/hydra_attribute/model/notifiable.rb +23 -0
  33. data/lib/hydra_attribute/model/persistence.rb +424 -0
  34. data/lib/hydra_attribute/model/validations.rb +40 -0
  35. data/lib/hydra_attribute/version.rb +1 -1
  36. data/spec/environments/mysql.rb +23 -0
  37. data/spec/environments/postgresql.rb +23 -0
  38. data/spec/environments/sqlite.rb +12 -0
  39. data/spec/fixtures/category.rb +8 -0
  40. data/spec/fixtures/product.rb +8 -0
  41. data/spec/fixtures/product_black_list.rb +13 -0
  42. data/spec/fixtures/product_white_list.rb +13 -0
  43. data/spec/hydra_attribute/active_record/attribute_methods_spec.rb +23 -28
  44. data/spec/hydra_attribute/active_record/mass_assignment_security_spec.rb +41 -0
  45. data/spec/hydra_attribute/active_record_spec.rb +577 -0
  46. data/spec/hydra_attribute/hydra_attribute_set_spec.rb +651 -0
  47. data/spec/hydra_attribute/hydra_attribute_spec.rb +208 -10
  48. data/spec/hydra_attribute/hydra_entity_attribute_association_spec.rb +216 -0
  49. data/spec/hydra_attribute/hydra_entity_spec.rb +71 -0
  50. data/spec/hydra_attribute/hydra_set_spec.rb +51 -10
  51. data/spec/hydra_attribute/hydra_value_spec.rb +286 -0
  52. data/spec/hydra_attribute/identity_map_spec.rb +47 -0
  53. data/spec/hydra_attribute/migrator_spec.rb +411 -0
  54. data/spec/hydra_attribute/model/cacheable_spec.rb +106 -0
  55. data/spec/hydra_attribute/model/has_many_through_spec.rb +132 -0
  56. data/spec/hydra_attribute/model/identity_map_spec.rb +39 -0
  57. data/spec/hydra_attribute/model/mediator_spec.rb +62 -0
  58. data/spec/hydra_attribute/model/persistence_spec.rb +550 -0
  59. data/spec/hydra_attribute/model_spec.rb +39 -0
  60. data/spec/hydra_attribute_spec.rb +36 -0
  61. data/spec/spec_helper.rb +10 -42
  62. metadata +76 -100
  63. data/Appraisals +0 -7
  64. data/cucumber.yml +0 -1
  65. data/features/entity/create.feature +0 -145
  66. data/features/entity/destroy.feature +0 -111
  67. data/features/entity/new.feature +0 -121
  68. data/features/entity/update.feature +0 -147
  69. data/features/hydra_attribute/create.feature +0 -30
  70. data/features/hydra_attribute/destroy.feature +0 -26
  71. data/features/hydra_attribute/update.feature +0 -36
  72. data/features/hydra_set/destroy.feature +0 -31
  73. data/features/migrations/create_and_drop.feature +0 -165
  74. data/features/migrations/migrate_and_rollback.feature +0 -211
  75. data/features/relation/query_methods/group.feature +0 -42
  76. data/features/relation/query_methods/order.feature +0 -67
  77. data/features/relation/query_methods/reorder.feature +0 -29
  78. data/features/relation/query_methods/reverse_order.feature +0 -29
  79. data/features/relation/query_methods/select.feature +0 -50
  80. data/features/relation/query_methods/where.feature +0 -115
  81. data/features/step_definitions/connections.rb +0 -65
  82. data/features/step_definitions/model_steps.rb +0 -136
  83. data/features/step_definitions/query_methods.rb +0 -48
  84. data/features/step_definitions/record_steps.rb +0 -93
  85. data/features/support/env.rb +0 -38
  86. data/features/support/world.rb +0 -61
  87. data/lib/hydra_attribute/active_record/association.rb +0 -113
  88. data/lib/hydra_attribute/active_record/reflection.rb +0 -16
  89. data/lib/hydra_attribute/association_builder.rb +0 -69
  90. data/lib/hydra_attribute/builder.rb +0 -37
  91. data/lib/hydra_attribute/entity_callbacks.rb +0 -26
  92. data/lib/hydra_attribute/hydra_attribute_methods.rb +0 -226
  93. data/lib/hydra_attribute/hydra_methods.rb +0 -528
  94. data/lib/hydra_attribute/hydra_set_methods.rb +0 -95
  95. data/lib/hydra_attribute/hydra_value_methods.rb +0 -21
  96. data/lib/hydra_attribute/memoizable.rb +0 -37
  97. data/spec/hydra_attribute/active_record/relation/query_methods_spec.rb +0 -31
  98. data/spec/hydra_attribute/hydra_attribute_methods_spec.rb +0 -458
  99. data/spec/hydra_attribute/hydra_methods_spec.rb +0 -456
  100. data/spec/hydra_attribute/hydra_set_methods_spec.rb +0 -203
  101. data/spec/hydra_attribute/memoizable_spec.rb +0 -95
@@ -1,31 +0,0 @@
1
- Feature: destroy hydra set
2
- When destroy hydra set
3
- Then column hydra_set_id should be set to NULL for entity table
4
-
5
- Background: create hydra set and add hydra attributes to it
6
- Given create hydra attributes for "Product" with role "admin" as "hashes":
7
- | name | backend_type | white_list |
8
- | code | integer | [bool:t] |
9
- | state | integer | [bool:t] |
10
- | title | string | [bool:t] |
11
- And create hydra set "Default" for "Product"
12
- And add "Product" hydra attributes to hydra set:
13
- | hydra attribute name | hydra set name |
14
- | code | [array:Default] |
15
- | state | [array:Default] |
16
- And create "Product" model with attributes as "rows_hash":
17
- | hydra_set_id | [eval:Product.hydra_sets.find_by_name('Default').id] |
18
-
19
- Scenario: after removing hydra set the hydra_set_id for entity should be NULL
20
- When destroy all "HydraAttribute::HydraSet" models with attributes as "rows_hash":
21
- | name | Default|
22
- Then table "products" should have 1 record:
23
- | hydra_set_id |
24
- | [nil:] |
25
- And last created "Product" should have attribute "hydra_set_id" with value "[nil:]"
26
-
27
- Scenario: after removing hydra set entity should respond to all hydra attributes
28
- Given destroy all "HydraAttribute::HydraSet" models with attributes as "rows_hash":
29
- | name | Default|
30
- When find last "Product" model
31
- Then model attributes should match "[array:id,hydra_set_id,name,created_at,updated_at,code,state,title]"
@@ -1,165 +0,0 @@
1
- Feature: create and drop hydra EAV stack
2
- When create hydra entity
3
- Then all necessary tables with indexes should be created
4
-
5
- When drop hydra entity
6
- Then all necessary tables should be dropped
7
-
8
- Background: create migration with separate connection
9
- Given create connection
10
-
11
- Scenario: create and drop hydra entity
12
- When create hydra entity "wheels"
13
- Then should have the following 10 tables:
14
- | tables |
15
- | wheels |
16
- | hydra_attributes |
17
- | hydra_sets |
18
- | hydra_attribute_sets |
19
- | hydra_string_wheels |
20
- | hydra_text_wheels |
21
- | hydra_float_wheels |
22
- | hydra_integer_wheels |
23
- | hydra_boolean_wheels |
24
- | hydra_datetime_wheels |
25
- And table "wheels" should have the following columns:
26
- | name | type | limit | default | null | precision | scale |
27
- | id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
28
- | hydra_set_id | [sym:integer] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
29
- And table "wheels" should have the following indexes:
30
- | name | columns | unique |
31
- | wheels_hydra_set_id_index | [array:hydra_set_id] | [bool:f] |
32
- And table "hydra_attributes" should have the following columns:
33
- | name | type | limit | default | null | precision | scale |
34
- | id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
35
- | entity_type | [sym:string] | [int:32] | [nil:] | [bool:f] | [nil:] | [nil:] |
36
- | name | [sym:string] | [int:32] | [nil:] | [bool:f] | [nil:] | [nil:] |
37
- | backend_type | [sym:string] | [int:16] | [nil:] | [bool:f] | [nil:] | [nil:] |
38
- | default_value | [sym:string] | [int:255] | [nil:] | [bool:t] | [nil:] | [nil:] |
39
- | white_list | [sym:boolean] | [nil:] | [bool:f] | [bool:f] | [nil:] | [nil:] |
40
- | created_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
41
- | updated_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
42
- And table "hydra_attributes" should have the following indexes:
43
- | name | columns | unique |
44
- | hydra_attributes_index | [array:entity_type,name] | [bool:t] |
45
- And table "hydra_sets" should have the following columns:
46
- | name | type | limit | default | null | precision | scale |
47
- | id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
48
- | entity_type | [sym:string] | [int:32] | [nil:] | [bool:f] | [nil:] | [nil:] |
49
- | name | [sym:string] | [int:32] | [nil:] | [bool:f] | [nil:] | [nil:] |
50
- | created_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
51
- | updated_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
52
- And table "hydra_sets" should have the following indexes:
53
- | name | columns | unique |
54
- | hydra_sets_index | [array:entity_type,name] | [bool:t] |
55
- And table "hydra_attribute_sets" should have the following columns:
56
- | name | type | limit | default | null | precision | scale |
57
- | hydra_attribute_id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
58
- | hydra_set_id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
59
- And table "hydra_attribute_sets" should have the following indexes:
60
- | name | columns | unique |
61
- | hydra_attribute_sets_index | [array:hydra_attribute_id,hydra_set_id] | [bool:t] |
62
- And table "hydra_string_wheels" should have the following columns:
63
- | name | type | limit | default | null | precision | scale |
64
- | id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
65
- | entity_id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
66
- | hydra_attribute_id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
67
- | value | [sym:string] | [int:255] | [nil:] | [bool:t] | [nil:] | [nil:] |
68
- | created_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
69
- | updated_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
70
- And table "hydra_string_wheels" should have the following indexes:
71
- | name | columns | unique |
72
- | hydra_string_wheels_index | [array:entity_id,hydra_attribute_id] | [bool:t] |
73
- And table "hydra_text_wheels" should have the following columns:
74
- | name | type | limit | default | null | precision | scale |
75
- | id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
76
- | entity_id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
77
- | hydra_attribute_id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
78
- | value | [sym:text] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
79
- | created_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
80
- | updated_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
81
- And table "hydra_text_wheels" should have the following indexes:
82
- | name | columns | unique |
83
- | hydra_text_wheels_index | [array:entity_id,hydra_attribute_id] | [bool:t] |
84
- And table "hydra_integer_wheels" should have the following columns:
85
- | name | type | limit | default | null | precision | scale |
86
- | id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
87
- | entity_id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
88
- | hydra_attribute_id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
89
- | value | [sym:integer] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
90
- | created_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
91
- | updated_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
92
- And table "hydra_integer_wheels" should have the following indexes:
93
- | name | columns | unique |
94
- | hydra_integer_wheels_index | [array:entity_id,hydra_attribute_id] | [bool:t] |
95
- And table "hydra_float_wheels" should have the following columns:
96
- | name | type | limit | default | null | precision | scale |
97
- | id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
98
- | entity_id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
99
- | hydra_attribute_id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
100
- | value | [sym:float] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
101
- | created_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
102
- | updated_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
103
- And table "hydra_float_wheels" should have the following indexes:
104
- | name | columns | unique |
105
- | hydra_float_wheels_index | [array:entity_id,hydra_attribute_id] | [bool:t] |
106
- And table "hydra_boolean_wheels" should have the following columns:
107
- | name | type | limit | default | null | precision | scale |
108
- | id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
109
- | entity_id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
110
- | hydra_attribute_id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
111
- | value | [sym:boolean] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
112
- | created_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
113
- | updated_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
114
- And table "hydra_boolean_wheels" should have the following indexes:
115
- | name | columns | unique |
116
- | hydra_boolean_wheels_index | [array:entity_id,hydra_attribute_id] | [bool:t] |
117
- And table "hydra_datetime_wheels" should have the following columns:
118
- | name | type | limit | default | null | precision | scale |
119
- | id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
120
- | entity_id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
121
- | hydra_attribute_id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
122
- | value | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
123
- | created_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
124
- | updated_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
125
- And table "hydra_datetime_wheels" should have the following indexes:
126
- | name | columns | unique |
127
- | hydra_datetime_wheels_index | [array:entity_id,hydra_attribute_id] | [bool:t] |
128
-
129
- When create hydra entity "cars"
130
- Then should have the following 17 tables:
131
- | tables |
132
- | wheels |
133
- | hydra_attributes |
134
- | hydra_sets |
135
- | hydra_attribute_sets |
136
- | hydra_string_wheels |
137
- | hydra_text_wheels |
138
- | hydra_float_wheels |
139
- | hydra_integer_wheels |
140
- | hydra_boolean_wheels |
141
- | hydra_datetime_wheels |
142
- | cars |
143
- | hydra_string_cars |
144
- | hydra_text_cars |
145
- | hydra_float_cars |
146
- | hydra_integer_cars |
147
- | hydra_boolean_cars |
148
- | hydra_datetime_cars |
149
-
150
- When drop hydra entity "wheels"
151
- Then should have the following 10 tables:
152
- | tables |
153
- | hydra_attributes |
154
- | hydra_sets |
155
- | hydra_attribute_sets |
156
- | cars |
157
- | hydra_string_cars |
158
- | hydra_text_cars |
159
- | hydra_float_cars |
160
- | hydra_integer_cars |
161
- | hydra_boolean_cars |
162
- | hydra_datetime_cars |
163
-
164
- When drop hydra entity "cars"
165
- Then should not have any tables
@@ -1,211 +0,0 @@
1
- Feature: migrate to and rollback from hydra EAV stack
2
- When migrate existing table to EAV
3
- Then all additional tables with indexes should be created
4
-
5
- When rollback from hydra entity
6
- Then all hydra attribute tables should be dropped
7
- And hydra_set_id column from entity table should be removed
8
- But main entity table should be kept
9
-
10
- Background: create migration with separate connection
11
- Given create connection
12
-
13
- Scenario: migrate existing tables to hydra and then rollback them
14
- When create table "wheels"
15
- And create table "cars"
16
- Then should have the following 2 tables:
17
- | tables |
18
- | wheels |
19
- | cars |
20
- And table "wheels" should have the following columns:
21
- | name | type | limit | default | null | precision | scale |
22
- | id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
23
- And table "cars" should have the following columns:
24
- | name | type | limit | default | null | precision | scale |
25
- | id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
26
-
27
- When migrate to hydra entity "wheels"
28
- Then should have the following 11 tables:
29
- | tables |
30
- | wheels |
31
- | cars |
32
- | hydra_attributes |
33
- | hydra_sets |
34
- | hydra_attribute_sets |
35
- | hydra_string_wheels |
36
- | hydra_text_wheels |
37
- | hydra_float_wheels |
38
- | hydra_integer_wheels |
39
- | hydra_boolean_wheels |
40
- | hydra_datetime_wheels |
41
- And table "wheels" should have the following columns:
42
- | name | type | limit | default | null | precision | scale |
43
- | id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
44
- | hydra_set_id | [sym:integer] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
45
- And table "wheels" should have the following indexes:
46
- | name | columns | unique |
47
- | wheels_hydra_set_id_index | [array:hydra_set_id] | [bool:f] |
48
- And table "cars" should have the following columns:
49
- | name | type | limit | default | null | precision | scale |
50
- | id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
51
- And table "hydra_attributes" should have the following columns:
52
- | name | type | limit | default | null | precision | scale |
53
- | id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
54
- | entity_type | [sym:string] | [int:32] | [nil:] | [bool:f] | [nil:] | [nil:] |
55
- | name | [sym:string] | [int:32] | [nil:] | [bool:f] | [nil:] | [nil:] |
56
- | backend_type | [sym:string] | [int:16] | [nil:] | [bool:f] | [nil:] | [nil:] |
57
- | default_value | [sym:string] | [int:255] | [nil:] | [bool:t] | [nil:] | [nil:] |
58
- | white_list | [sym:boolean] | [nil:] | [bool:f] | [bool:f] | [nil:] | [nil:] |
59
- | created_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
60
- | updated_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
61
- And table "hydra_attributes" should have the following indexes:
62
- | name | columns | unique |
63
- | hydra_attributes_index | [array:entity_type,name] | [bool:t] |
64
- And table "hydra_sets" should have the following columns:
65
- | name | type | limit | default | null | precision | scale |
66
- | id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
67
- | entity_type | [sym:string] | [int:32] | [nil:] | [bool:f] | [nil:] | [nil:] |
68
- | name | [sym:string] | [int:32] | [nil:] | [bool:f] | [nil:] | [nil:] |
69
- | created_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
70
- | updated_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
71
- And table "hydra_sets" should have the following indexes:
72
- | name | columns | unique |
73
- | hydra_sets_index | [array:entity_type,name] | [bool:t] |
74
- And table "hydra_attribute_sets" should have the following columns:
75
- | name | type | limit | default | null | precision | scale |
76
- | hydra_attribute_id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
77
- | hydra_set_id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
78
- And table "hydra_attribute_sets" should have the following indexes:
79
- | name | columns | unique |
80
- | hydra_attribute_sets_index | [array:hydra_attribute_id,hydra_set_id] | [bool:t] |
81
- And table "hydra_string_wheels" should have the following columns:
82
- | name | type | limit | default | null | precision | scale |
83
- | id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
84
- | entity_id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
85
- | hydra_attribute_id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
86
- | value | [sym:string] | [int:255] | [nil:] | [bool:t] | [nil:] | [nil:] |
87
- | created_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
88
- | updated_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
89
- And table "hydra_string_wheels" should have the following indexes:
90
- | name | columns | unique |
91
- | hydra_string_wheels_index | [array:entity_id,hydra_attribute_id] | [bool:t] |
92
- And table "hydra_text_wheels" should have the following columns:
93
- | name | type | limit | default | null | precision | scale |
94
- | id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
95
- | entity_id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
96
- | hydra_attribute_id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
97
- | value | [sym:text] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
98
- | created_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
99
- | updated_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
100
- And table "hydra_text_wheels" should have the following indexes:
101
- | name | columns | unique |
102
- | hydra_text_wheels_index | [array:entity_id,hydra_attribute_id] | [bool:t] |
103
- And table "hydra_integer_wheels" should have the following columns:
104
- | name | type | limit | default | null | precision | scale |
105
- | id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
106
- | entity_id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
107
- | hydra_attribute_id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
108
- | value | [sym:integer] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
109
- | created_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
110
- | updated_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
111
- And table "hydra_integer_wheels" should have the following indexes:
112
- | name | columns | unique |
113
- | hydra_integer_wheels_index | [array:entity_id,hydra_attribute_id] | [bool:t] |
114
- And table "hydra_float_wheels" should have the following columns:
115
- | name | type | limit | default | null | precision | scale |
116
- | id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
117
- | entity_id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
118
- | hydra_attribute_id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
119
- | value | [sym:float] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
120
- | created_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
121
- | updated_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
122
- And table "hydra_float_wheels" should have the following indexes:
123
- | name | columns | unique |
124
- | hydra_float_wheels_index | [array:entity_id,hydra_attribute_id] | [bool:t] |
125
- And table "hydra_boolean_wheels" should have the following columns:
126
- | name | type | limit | default | null | precision | scale |
127
- | id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
128
- | entity_id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
129
- | hydra_attribute_id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
130
- | value | [sym:boolean] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
131
- | created_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
132
- | updated_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
133
- And table "hydra_boolean_wheels" should have the following indexes:
134
- | name | columns | unique |
135
- | hydra_boolean_wheels_index | [array:entity_id,hydra_attribute_id] | [bool:t] |
136
- And table "hydra_datetime_wheels" should have the following columns:
137
- | name | type | limit | default | null | precision | scale |
138
- | id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
139
- | entity_id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
140
- | hydra_attribute_id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
141
- | value | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
142
- | created_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
143
- | updated_at | [sym:datetime] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
144
- And table "hydra_datetime_wheels" should have the following indexes:
145
- | name | columns | unique |
146
- | hydra_datetime_wheels_index | [array:entity_id,hydra_attribute_id] | [bool:t] |
147
-
148
- When migrate to hydra entity "cars"
149
- Then should have the following 17 tables:
150
- | tables |
151
- | wheels |
152
- | hydra_attributes |
153
- | hydra_sets |
154
- | hydra_attribute_sets |
155
- | hydra_string_wheels |
156
- | hydra_text_wheels |
157
- | hydra_float_wheels |
158
- | hydra_integer_wheels |
159
- | hydra_boolean_wheels |
160
- | hydra_datetime_wheels |
161
- | cars |
162
- | hydra_string_cars |
163
- | hydra_text_cars |
164
- | hydra_float_cars |
165
- | hydra_integer_cars |
166
- | hydra_boolean_cars |
167
- | hydra_datetime_cars |
168
- And table "cars" should have the following columns:
169
- | name | type | limit | default | null | precision | scale |
170
- | id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
171
- | hydra_set_id | [sym:integer] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
172
- And table "cars" should have the following indexes:
173
- | name | columns | unique |
174
- | cars_hydra_set_id_index | [array:hydra_set_id] | [bool:f] |
175
-
176
- When rollback from hydra entity "wheels"
177
- Then should have the following 11 tables:
178
- | tables |
179
- | wheels |
180
- | hydra_attributes |
181
- | hydra_sets |
182
- | hydra_attribute_sets |
183
- | cars |
184
- | hydra_string_cars |
185
- | hydra_text_cars |
186
- | hydra_float_cars |
187
- | hydra_integer_cars |
188
- | hydra_boolean_cars |
189
- | hydra_datetime_cars |
190
- And table "wheels" should have the following columns:
191
- | name | type | limit | default | null | precision | scale |
192
- | id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
193
- And table "cars" should have the following columns:
194
- | name | type | limit | default | null | precision | scale |
195
- | id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
196
- | hydra_set_id | [sym:integer] | [nil:] | [nil:] | [bool:t] | [nil:] | [nil:] |
197
- And table "cars" should have the following indexes:
198
- | name | columns | unique |
199
- | cars_hydra_set_id_index | [array:hydra_set_id] | [bool:f] |
200
-
201
- When rollback from hydra entity "cars"
202
- Then should have the following 2 tables:
203
- | tables |
204
- | wheels |
205
- | cars |
206
- And table "wheels" should have the following columns:
207
- | name | type | limit | default | null | precision | scale |
208
- | string:id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [nil:] |
209
- And table "cars" should have the following columns:
210
- | name | type | limit | default | null | precision | scale |
211
- | id | [sym:integer] | [nil:] | [nil:] | [bool:f] | [nil:] | [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
- | code | integer | [bool:t] |
9
- | title | string | [bool:t] |
10
- | total | integer | [bool:t] |
11
- Given create "Product" model with attributes as "hashes":
12
- | name | code | title | total |
13
- | a | 1 | q | 5 |
14
- | b | 2 | w | 5 |
15
- | b | 3 | w | |
16
- | c | 4 | 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=[int:1] | code=[int:4] |
27
- | name | 3 | name=a code=[int:1] | name=c code=[int:4] |
28
- | name title | 3 | name=a code=[int:1] | name=c code=[int: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=w | 2 | code=[int:2] | code=[int:3] |
40
- | name | title=w | 1 | name=b title=w | name=b title=w |
41
- | name title | title=w | 1 | name=b title=w | name=b title=w |
42
- | name title | total=[nil:] | 2 | name=b title=w | name=c title=e |