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.
- data/CHANGELOG.md +1 -1
- data/README.md +7 -0
- data/features/entity/create.feature +128 -0
- data/features/entity/destroy.feature +111 -0
- data/features/entity/new.feature +121 -0
- data/features/entity/update.feature +147 -0
- data/features/{attributes → hydra_attribute}/create.feature +7 -7
- data/features/{attributes → hydra_attribute}/destroy.feature +2 -4
- data/features/{attributes → hydra_attribute}/update.feature +10 -10
- data/features/hydra_set/destroy.feature +31 -0
- data/features/migrations/create_and_drop.feature +165 -0
- data/features/migrations/migrate_and_rollback.feature +211 -0
- data/features/relation/query_methods/group.feature +42 -0
- data/features/relation/query_methods/order.feature +67 -0
- data/features/relation/query_methods/reorder.feature +29 -0
- data/features/relation/query_methods/reverse_order.feature +29 -0
- data/features/relation/query_methods/select.feature +50 -0
- data/features/relation/query_methods/where.feature +70 -0
- data/features/step_definitions/connections.rb +65 -0
- data/features/step_definitions/model_steps.rb +79 -6
- data/features/step_definitions/query_methods.rb +3 -3
- data/features/step_definitions/record_steps.rb +3 -4
- data/features/support/env.rb +17 -3
- data/features/support/world.rb +15 -10
- data/gemfiles/3.1.gemfile.lock +15 -15
- data/gemfiles/3.2.gemfile.lock +15 -15
- data/lib/hydra_attribute/active_record/association.rb +74 -38
- data/lib/hydra_attribute/active_record/association_preloader.rb +49 -49
- data/lib/hydra_attribute/active_record/attribute_methods.rb +37 -85
- data/lib/hydra_attribute/active_record/migration.rb +2 -2
- data/lib/hydra_attribute/active_record/reflection.rb +1 -1
- data/lib/hydra_attribute/active_record/relation/query_methods.rb +8 -7
- data/lib/hydra_attribute/active_record/relation.rb +1 -0
- data/lib/hydra_attribute/active_record.rb +20 -12
- data/lib/hydra_attribute/association_builder.rb +1 -2
- data/lib/hydra_attribute/builder.rb +7 -8
- data/lib/hydra_attribute/entity_callbacks.rb +12 -32
- data/lib/hydra_attribute/hydra_attribute.rb +25 -16
- data/lib/hydra_attribute/hydra_attribute_methods.rb +85 -0
- data/lib/hydra_attribute/hydra_methods.rb +123 -0
- data/lib/hydra_attribute/hydra_set.rb +36 -0
- data/lib/hydra_attribute/hydra_set_methods.rb +39 -0
- data/lib/hydra_attribute/hydra_value_methods.rb +14 -0
- data/lib/hydra_attribute/memoize.rb +37 -0
- data/lib/hydra_attribute/migrator.rb +100 -51
- data/lib/hydra_attribute/railtie.rb +1 -3
- data/lib/hydra_attribute/version.rb +1 -1
- data/lib/hydra_attribute.rb +7 -1
- data/spec/hydra_attribute_methods_spec.rb +458 -0
- data/spec/hydra_attribute_spec.rb +19 -0
- data/spec/hydra_methods_spec.rb +457 -0
- data/spec/hydra_set_methods_spec.rb +203 -0
- data/spec/hydra_set_spec.rb +19 -0
- data/spec/memoize_spec.rb +95 -0
- data/spec/spec_helper.rb +42 -2
- metadata +71 -43
- data/features/create.feature +0 -47
- data/features/define.feature +0 -38
- data/features/destroy.feature +0 -102
- data/features/query_methods/group.feature +0 -42
- data/features/query_methods/order.feature +0 -99
- data/features/query_methods/select.feature +0 -50
- data/features/query_methods/where.feature +0 -70
- data/features/support/schema.rb +0 -79
- data/features/update.feature +0 -114
@@ -0,0 +1,165 @@
|
|
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
|
@@ -0,0 +1,211 @@
|
|
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:] |
|
@@ -0,0 +1,42 @@
|
|
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 |
|
@@ -0,0 +1,67 @@
|
|
1
|
+
Feature: order conditions by hydra attributes
|
2
|
+
When order records by hydra attribute
|
3
|
+
Then correct table should be joined and order by value should be added
|
4
|
+
|
5
|
+
When correct table is already joined
|
6
|
+
Then only order condition should be added
|
7
|
+
|
8
|
+
When order by several attributes
|
9
|
+
Then order all of them by ascending
|
10
|
+
|
11
|
+
Background: create hydra attributes
|
12
|
+
Given create hydra attributes for "Product" with role "admin" as "hashes":
|
13
|
+
| name | backend_type | white_list |
|
14
|
+
| code | integer | [bool:t] |
|
15
|
+
| state | integer | [bool:t] |
|
16
|
+
| title | string | [bool:t] |
|
17
|
+
|
18
|
+
Scenario Outline: order by one field
|
19
|
+
Given create "Product" model with attributes as "hashes":
|
20
|
+
| name | code | state |
|
21
|
+
| c | 1 | 1 |
|
22
|
+
| b | 2 | 2 |
|
23
|
+
| a | 3 | 3 |
|
24
|
+
When order "Product" records by "<attributes>"
|
25
|
+
Then "first" record should have "<first identifier>"
|
26
|
+
And "last" record should have "<last identifier>"
|
27
|
+
|
28
|
+
Scenarios: order conditions
|
29
|
+
| attributes | first identifier | last identifier |
|
30
|
+
| state=asc | code=[int:1] | code=[int:3] |
|
31
|
+
| state=desc | code=[int:3] | code=[int:1] |
|
32
|
+
| name=asc | code=[int:3] | code=[int:1] |
|
33
|
+
| name=desc | code=[int:1] | code=[int:3] |
|
34
|
+
|
35
|
+
Scenario Outline: order by several attributes
|
36
|
+
Given create "Product" model with attributes as "hashes":
|
37
|
+
| name | code | state | title |
|
38
|
+
| c | 1 | 1 | b |
|
39
|
+
| b | 2 | 2 | a |
|
40
|
+
| a | 3 | 3 | c |
|
41
|
+
When order "Product" records by "<attributes>"
|
42
|
+
Then "first" record should have "<first identifier>"
|
43
|
+
And "last" record should have "<last identifier>"
|
44
|
+
|
45
|
+
Scenarios: order conditions
|
46
|
+
| attributes | first identifier | last identifier |
|
47
|
+
| name state | code=[int:3] | code=[int:1] |
|
48
|
+
| state title | code=[int:1] | code=[int:3] |
|
49
|
+
| title state | code=[int:2] | code=[int:3] |
|
50
|
+
|
51
|
+
Scenario Outline: order by filtered attribute
|
52
|
+
Given create "Product" model with attributes as "hashes":
|
53
|
+
| code | state | title |
|
54
|
+
| 1 | 1 | |
|
55
|
+
| 2 | | |
|
56
|
+
| 3 | 1 | a |
|
57
|
+
When filter "Product" records by "<filter attribute>"
|
58
|
+
And order records by "<order attributes>"
|
59
|
+
Then total records should be "<count>"
|
60
|
+
And "first" record should have "<first identifier>"
|
61
|
+
And "last" record should have "<last identifier>"
|
62
|
+
|
63
|
+
Scenarios: order conditions
|
64
|
+
| filter attribute | order attributes | count | first identifier | last identifier |
|
65
|
+
| state=[int:1] | state code | 2 | code=[int:1] | code=[int:3] |
|
66
|
+
| state=[nil:] | state code | 1 | code=[int:2] | code=[int:2] |
|
67
|
+
| title=[nil:] | title code | 2 | code=[int:1] | code=[int:2] |
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Feature: reorder by hydra attributes
|
2
|
+
When reorder relation object with new hydra attributes
|
3
|
+
Then old order hydra attributes should be removed
|
4
|
+
And new hydra attributes should be added to order list
|
5
|
+
|
6
|
+
Background: create hydra attributes
|
7
|
+
Given create hydra attributes for "Product" with role "admin" as "hashes":
|
8
|
+
| name | backend_type | white_list |
|
9
|
+
| code | integer | [bool:t] |
|
10
|
+
| state | integer | [bool:t] |
|
11
|
+
| title | string | [bool:t] |
|
12
|
+
|
13
|
+
Scenario Outline: reorder
|
14
|
+
Given create "Product" model with attributes as "hashes":
|
15
|
+
| code | name | title |
|
16
|
+
| 1 | a | c |
|
17
|
+
| 2 | b | b |
|
18
|
+
| 3 | c | a |
|
19
|
+
When order "Product" records by "<order>"
|
20
|
+
And reorder records by "<reorder>"
|
21
|
+
Then total records should be "<count>"
|
22
|
+
And "first" record should have "<first identifier>"
|
23
|
+
And "last" record should have "<last identifier>"
|
24
|
+
|
25
|
+
Scenarios: order conditions
|
26
|
+
| order | reorder | count | first identifier | last identifier |
|
27
|
+
| title | name title | 3 | code=[int:1] | code=[int:3] |
|
28
|
+
| name | title name | 3 | code=[int:3] | code=[int:1] |
|
29
|
+
| code | title | 3 | code=[int:3] | code=[int:1] |
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Feature: reverse order relation object
|
2
|
+
When reverse order by hydra attribute
|
3
|
+
Then relation object should reverse order of hydra attribute. ASC to DESC and vise versa
|
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
|
+
| code | integer | [bool:t] |
|
9
|
+
| state | integer | [bool:t] |
|
10
|
+
| title | string | [bool:t] |
|
11
|
+
|
12
|
+
Scenario Outline: reverse order
|
13
|
+
Given create "Product" model with attributes as "hashes":
|
14
|
+
| code | state | title |
|
15
|
+
| 1 | 3 | a |
|
16
|
+
| 2 | 2 | b |
|
17
|
+
| 3 | 1 | c |
|
18
|
+
When order "Product" records by "<order>"
|
19
|
+
And reverse order records
|
20
|
+
Then total records should be "3"
|
21
|
+
And "first" record should have "<first>"
|
22
|
+
And "last" record should have "<last>"
|
23
|
+
|
24
|
+
Scenarios: conditions
|
25
|
+
| order | first | last |
|
26
|
+
| code | code=[int:3] | code=[int:1] |
|
27
|
+
| state | code=[int:1] | code=[int:3] |
|
28
|
+
| title | code=[int:3] | code=[int:1] |
|
29
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
Feature: select concrete attributes
|
2
|
+
When select concrete attribute
|
3
|
+
Then model should response only to these attributes
|
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
|
+
| code | integer | [bool:t] |
|
9
|
+
| price | float | [bool:t] |
|
10
|
+
| title | string | [bool:t] |
|
11
|
+
| note | text | [bool:t] |
|
12
|
+
| active | boolean | [bool:t] |
|
13
|
+
| schedule | datetime | [bool:t] |
|
14
|
+
And create "Product" model with attributes as "hashes":
|
15
|
+
| name | code | price | title | note | active | schedule |
|
16
|
+
| a | 1 | 4 | q | z | 1 | 2012-06-01 |
|
17
|
+
| b | 2 | 5 | w | x | 0 | 2012-06-02 |
|
18
|
+
| c | 3 | 6 | | c | 1 | 2012-06-03 |
|
19
|
+
| d | | 7 | | v | 0 | 2012-06-04 |
|
20
|
+
|
21
|
+
Scenario Outline: select concrete attributes
|
22
|
+
When "Product" select only the following columns "<selected columns>"
|
23
|
+
Then records should have only the following "<expected columns>" names
|
24
|
+
And records should raise "ActiveModel::MissingAttributeError" when call the following "<methods>"
|
25
|
+
And total records should be "4"
|
26
|
+
|
27
|
+
Scenarios: select attributes
|
28
|
+
| selected columns | expected columns | methods |
|
29
|
+
| name | id hydra_set_id name | code price title note active schedule |
|
30
|
+
| name code | id hydra_set_id name code | price title note active schedule |
|
31
|
+
| name code price | id hydra_set_id name code price | title note active schedule |
|
32
|
+
| code price title | id hydra_set_id code price title | name note active schedule |
|
33
|
+
| title note active | id hydra_set_id title note active | name code price schedule |
|
34
|
+
| schedule | id hydra_set_id schedule | name code price title note active |
|
35
|
+
| id schedule | id hydra_set_id schedule | name code price title note active |
|
36
|
+
|
37
|
+
Scenario Outline: filter collection and select concrete attributes
|
38
|
+
When "Product" select only the following columns "<selected columns>"
|
39
|
+
And filter records by "<filter attributes>"
|
40
|
+
Then records should have only the following "<expected columns>" names
|
41
|
+
And records should raise "ActiveModel::MissingAttributeError" when call the following "<methods>"
|
42
|
+
And total records should be "<total>"
|
43
|
+
|
44
|
+
Scenarios: filter and select attributes
|
45
|
+
| selected columns | expected columns | filter attributes | methods | total |
|
46
|
+
| name code | id hydra_set_id name code | name=a | price title note active schedule | 1 |
|
47
|
+
| code | id hydra_set_id code | code=[int:1] | name price title note active schedule | 1 |
|
48
|
+
| name code | id hydra_set_id name code | code=[int:1] | price title note active schedule | 1 |
|
49
|
+
| code title | id hydra_set_id code title | title=[nil:] | name price note active schedule | 2 |
|
50
|
+
| code note | id hydra_set_id code note | title=[nil:] | name price title active schedule | 2 |
|