flutter 0.1.0.pre.2 → 0.1.0.pre.3

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 (82) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -1
  3. data/README.md +3 -1
  4. data/lib/flutter/persistence.rb +51 -5
  5. data/lib/flutter/tracker.rb +47 -5
  6. data/lib/flutter/version.rb +1 -1
  7. metadata +16 -91
  8. data/integration_tests/minitest/grape_app/.gitignore +0 -67
  9. data/integration_tests/minitest/grape_app/.ruby-version +0 -1
  10. data/integration_tests/minitest/grape_app/Gemfile +0 -17
  11. data/integration_tests/minitest/grape_app/Gemfile.lock +0 -89
  12. data/integration_tests/minitest/grape_app/README.md +0 -2
  13. data/integration_tests/minitest/grape_app/Rakefile +0 -9
  14. data/integration_tests/minitest/grape_app/api/api.rb +0 -34
  15. data/integration_tests/minitest/grape_app/api/routes/api_helpers.rb +0 -12
  16. data/integration_tests/minitest/grape_app/api/routes/change_request/api.rb +0 -69
  17. data/integration_tests/minitest/grape_app/api/routes/change_request/response_entity.rb +0 -18
  18. data/integration_tests/minitest/grape_app/api/routes/event/api.rb +0 -121
  19. data/integration_tests/minitest/grape_app/api/routes/event/response_entity.rb +0 -41
  20. data/integration_tests/minitest/grape_app/api/routes/project/api.rb +0 -59
  21. data/integration_tests/minitest/grape_app/api/routes/project/response_entity.rb +0 -13
  22. data/integration_tests/minitest/grape_app/api/routes/property/api.rb +0 -78
  23. data/integration_tests/minitest/grape_app/api/routes/property/response_entity.rb +0 -31
  24. data/integration_tests/minitest/grape_app/api/routes/trackable_object/api.rb +0 -64
  25. data/integration_tests/minitest/grape_app/api/routes/trackable_object/response_entity.rb +0 -24
  26. data/integration_tests/minitest/grape_app/api/routes/tracking_spec/api.rb +0 -88
  27. data/integration_tests/minitest/grape_app/api/routes/tracking_spec/response_entity.rb +0 -17
  28. data/integration_tests/minitest/grape_app/api/routes/tracking_spec/spec_response.rb +0 -19
  29. data/integration_tests/minitest/grape_app/api/routes/user/api.rb +0 -22
  30. data/integration_tests/minitest/grape_app/api/routes/user/response_entity.rb +0 -12
  31. data/integration_tests/minitest/grape_app/app/app.rb +0 -30
  32. data/integration_tests/minitest/grape_app/app/change_request/endpoint.rb +0 -24
  33. data/integration_tests/minitest/grape_app/app/change_request/generate_system_changes.rb +0 -25
  34. data/integration_tests/minitest/grape_app/app/change_request/service.rb +0 -79
  35. data/integration_tests/minitest/grape_app/app/event/endpoint.rb +0 -78
  36. data/integration_tests/minitest/grape_app/app/event/service.rb +0 -68
  37. data/integration_tests/minitest/grape_app/app/event/validator.rb +0 -108
  38. data/integration_tests/minitest/grape_app/app/project/endpoint.rb +0 -24
  39. data/integration_tests/minitest/grape_app/app/project/service.rb +0 -42
  40. data/integration_tests/minitest/grape_app/app/property/endpoint.rb +0 -39
  41. data/integration_tests/minitest/grape_app/app/property/service.rb +0 -56
  42. data/integration_tests/minitest/grape_app/app/trackable_object/endpoint.rb +0 -38
  43. data/integration_tests/minitest/grape_app/app/trackable_object/service.rb +0 -49
  44. data/integration_tests/minitest/grape_app/app/trackable_object/validator.rb +0 -40
  45. data/integration_tests/minitest/grape_app/app/tracking_spec/endpoint.rb +0 -58
  46. data/integration_tests/minitest/grape_app/app/tracking_spec/expand_tracking_spec_events.rb +0 -91
  47. data/integration_tests/minitest/grape_app/app/tracking_spec/service.rb +0 -51
  48. data/integration_tests/minitest/grape_app/app/tracking_spec/validator.rb +0 -61
  49. data/integration_tests/minitest/grape_app/app/utils/errors/api_exceptions.rb +0 -10
  50. data/integration_tests/minitest/grape_app/app/utils/errors/service_exceptions.rb +0 -12
  51. data/integration_tests/minitest/grape_app/app/versioned_entity/entity.rb +0 -110
  52. data/integration_tests/minitest/grape_app/app/versioned_entity/service.rb +0 -47
  53. data/integration_tests/minitest/grape_app/app/versioned_entity/validator.rb +0 -61
  54. data/integration_tests/minitest/grape_app/app/versioned_entity_snapshot/entity.rb +0 -32
  55. data/integration_tests/minitest/grape_app/config/boot.rb +0 -9
  56. data/integration_tests/minitest/grape_app/config.ru +0 -3
  57. data/integration_tests/minitest/grape_app/db/proto/change_request.rb +0 -10
  58. data/integration_tests/minitest/grape_app/db/proto/common/doc.rb +0 -86
  59. data/integration_tests/minitest/grape_app/db/proto/event.rb +0 -10
  60. data/integration_tests/minitest/grape_app/db/proto/event_snapshot.rb +0 -10
  61. data/integration_tests/minitest/grape_app/db/proto/project.rb +0 -21
  62. data/integration_tests/minitest/grape_app/db/proto/property.rb +0 -10
  63. data/integration_tests/minitest/grape_app/db/proto/property_snapshot.rb +0 -10
  64. data/integration_tests/minitest/grape_app/db/proto/trackable_object.rb +0 -10
  65. data/integration_tests/minitest/grape_app/db/proto/trackable_object_snapshot.rb +0 -10
  66. data/integration_tests/minitest/grape_app/db/proto/tracking_spec.rb +0 -10
  67. data/integration_tests/minitest/grape_app/test/api/functional/event_test.rb +0 -186
  68. data/integration_tests/minitest/grape_app/test/api/functional/property_test.rb +0 -197
  69. data/integration_tests/minitest/grape_app/test/api/functional/trackable_object_test.rb +0 -134
  70. data/integration_tests/minitest/grape_app/test/api/functional/tracking_spec_test.rb +0 -56
  71. data/integration_tests/minitest/grape_app/test/api/functional/user_test.rb +0 -24
  72. data/integration_tests/minitest/grape_app/test/api/functional/versioned_entity_helper.rb +0 -157
  73. data/integration_tests/minitest/grape_app/test/fixtures/change_requests.rb +0 -83
  74. data/integration_tests/minitest/grape_app/test/fixtures/event_snapshots.rb +0 -105
  75. data/integration_tests/minitest/grape_app/test/fixtures/events.rb +0 -58
  76. data/integration_tests/minitest/grape_app/test/fixtures/properties.rb +0 -66
  77. data/integration_tests/minitest/grape_app/test/fixtures/property_snapshots.rb +0 -124
  78. data/integration_tests/minitest/grape_app/test/fixtures/sample_tracking_spec.json +0 -125
  79. data/integration_tests/minitest/grape_app/test/fixtures/trackable_objects.rb +0 -58
  80. data/integration_tests/minitest/grape_app/test/fixtures/trackable_objects_snapshots.rb +0 -61
  81. data/integration_tests/minitest/grape_app/test/fixtures/tracking_specs.rb +0 -22
  82. data/integration_tests/minitest/grape_app/test/test_helper.rb +0 -15
@@ -1,197 +0,0 @@
1
- require_relative '../../test_helper'
2
- require_relative 'versioned_entity_helper'
3
- module Skee
4
- module API
5
- module Test
6
- module Functional
7
- class PropertyTest < MiniTest::Test
8
- include Rack::Test::Methods
9
- include Skee::API::Test::Functional::VersionedEntityHelper
10
-
11
- def app
12
- Skee::API::Routes::Property::API
13
- end
14
-
15
- def initialize_db
16
- @properties = Skee::Test::Fixtures::Properties.all
17
- @properties.each { |entity| Skee::DB::Proto::Property.create(entity) }
18
- @property_snapshots = Skee::Test::Fixtures::PropertySnapshots.all
19
- @property_snapshots.each { |entity| Skee::DB::Proto::PropertySnapshot.create(entity) }
20
- @trackable_objects = Skee::Test::Fixtures::TrackableObjects.all
21
- @trackable_objects.each { |entity| Skee::DB::Proto::TrackableObject.create(entity) }
22
- @trackable_object_snapshots = Skee::Test::Fixtures::TrackableObjectSnapshots.all
23
- @trackable_object_snapshots.each { |entity| Skee::DB::Proto::TrackableObjectSnapshot.create(entity) }
24
- @change_requests = Skee::Test::Fixtures::ChangeRequests.all
25
- @change_requests.each { |entity| Skee::DB::Proto::ChangeRequest.create(entity) }
26
- @tracking_specs = Skee::Test::Fixtures::TrackingSpecs.all
27
- @tracking_specs.each { |entity| Skee::DB::Proto::TrackingSpec.create(entity) }
28
- end
29
-
30
- def clear_db
31
- Skee::DB::Proto::Property.delete_all
32
- Skee::DB::Proto::TrackableObject.delete_all
33
- Skee::DB::Proto::ChangeRequest.delete_all
34
- Skee::DB::Proto::TrackingSpec.delete_all
35
- end
36
-
37
- def setup
38
- clear_db
39
- initialize_db
40
- @entity_type = :property
41
- @entity_path = 'properties'
42
- @entity_fixture = Skee::Test::Fixtures::Properties
43
- end
44
-
45
- # def test_get_all_properties
46
- # get_all_entities
47
- # end
48
-
49
- def test_retrieve_property
50
- id = '4'
51
- retrieve_entity(id)
52
- end
53
-
54
- def test_retrieve_property_with_change_request
55
- id = '4'
56
- snapshot_id = '5'
57
- params = {'change_request_id' => '1'}
58
- retrieved_entity = retrieve_entity(id, params)
59
- assert_equal(
60
- snapshot_id,
61
- retrieved_entity['snapshot_id']
62
- )
63
- end
64
-
65
- def test_create_property_invalid_change_request
66
- new_entity_params = {
67
- 'name' => 'phone number',
68
- 'property_of' => 'trackable_object',
69
- 'change_request_id' => '-999',
70
- 'parent_reference_id' => '1',
71
- 'data_type' => 'String'
72
- }
73
- create_entity_invalid_change_request(new_entity_params)
74
- end
75
-
76
- def test_create_property_valid_for_updated_trackable_object
77
- trackable_object_id = '4'
78
- new_entity_params = {
79
- 'name' => 'phone number',
80
- 'property_of' => 'trackable_object',
81
- 'change_request_id' => '1',
82
- 'parent_reference_id' => trackable_object_id,
83
- 'data_type' => 'String'
84
- }
85
- new_property = create_entity_valid_name(new_entity_params)
86
- trackable_object = Skee::App::TrackableObject::Service.get(
87
- id: trackable_object_id,
88
- change_request_id: new_entity_params['change_request_id']
89
- )
90
- assert_includes(trackable_object.versioned_entity_snapshot.property_ids, new_property['id'])
91
- end
92
-
93
- def test_create_property_valid_for_non_updated_trackable_object
94
- trackable_object_id = '1'
95
- change_request_id = '1'
96
- new_entity_params = {
97
- 'name' => 'name',
98
- 'property_of' => 'trackable_object',
99
- 'change_request_id' => '1',
100
- 'parent_reference_id' => trackable_object_id,
101
- 'data_type' => 'String'
102
- }
103
- new_property = create_entity_valid_name(new_entity_params)
104
- old_trackable_object = Skee::App::TrackableObject::Service.get(
105
- id: trackable_object_id
106
- )
107
- new_trackable_object = Skee::App::TrackableObject::Service.get(
108
- id: trackable_object_id,
109
- change_request_id: new_entity_params['change_request_id']
110
- )
111
- refute_includes(old_trackable_object.versioned_entity_snapshot.property_ids, new_property['id'])
112
- assert_includes(new_trackable_object.versioned_entity_snapshot.property_ids, new_property['id'])
113
- end
114
-
115
- def test_update_property_belonging_to_non_updated_trackable_object
116
- property_id = '1'
117
- trackable_object_id = '1'
118
- change_request_id = '1'
119
- update_entity_params = {
120
- 'name' => 'first_name',
121
- 'property_of' => 'trackable_object',
122
- 'change_request_id' => change_request_id,
123
- 'parent_reference_id' => trackable_object_id,
124
- 'data_type' => 'String'
125
- }
126
- updated_property = update_entity_valid_creates_new_entity(property_id, update_entity_params)
127
-
128
- old_trackable_object = Skee::App::TrackableObject::Service.get(
129
- id: trackable_object_id
130
- )
131
- new_trackable_object = Skee::App::TrackableObject::Service.get(
132
- id: trackable_object_id,
133
- change_request_id: update_entity_params['change_request_id']
134
- )
135
- assert_includes(old_trackable_object.versioned_entity_snapshot.property_ids, property_id)
136
- assert_includes(new_trackable_object.versioned_entity_snapshot.property_ids, property_id)
137
- end
138
-
139
- def test_update_previously_updated_property
140
- property_id = '1'
141
- trackable_object_id = '1'
142
- change_request_id = '1'
143
- update_entity_params = {
144
- 'name' => 'first_name',
145
- 'property_of' => 'trackable_object',
146
- 'change_request_id' => change_request_id,
147
- 'parent_reference_id' => trackable_object_id,
148
- 'data_type' => 'String'
149
- }
150
- updated_property = update_entity_valid_creates_new_entity(property_id, update_entity_params)
151
-
152
- new_update_params = update_entity_params.merge(
153
- 'name' => 'last_name',
154
- )
155
-
156
- new_updated_property = update_entity_valid_updates_existing_snapshot_of_updated_entity(property_id, new_update_params)
157
-
158
- old_trackable_object = Skee::App::TrackableObject::Service.get(
159
- id: trackable_object_id
160
- )
161
- new_trackable_object = Skee::App::TrackableObject::Service.get(
162
- id: trackable_object_id,
163
- change_request_id: update_entity_params['change_request_id']
164
- )
165
- assert_includes(old_trackable_object.versioned_entity_snapshot.property_ids, property_id)
166
- assert_includes(new_trackable_object.versioned_entity_snapshot.property_ids, property_id)
167
- assert_equal(new_update_params['name'], new_updated_property['name'])
168
- assert_equal(property_id, new_updated_property['id'])
169
- assert_equal(updated_property['id'], new_updated_property['id'])
170
- assert_equal(updated_property['snapshot_id'], new_updated_property['snapshot_id'])
171
- end
172
-
173
- def test_remove_property_belonging_to_non_updated_trackable_object
174
- property_id = '1'
175
- trackable_object_id = '1'
176
- change_request_id = '1'
177
- remove_entity_params = {
178
- 'change_request_id' => change_request_id,
179
- 'parent_reference_id' => trackable_object_id,
180
- }
181
- updated_property = remove_entity_valid_creates_new_entity(property_id, remove_entity_params)
182
-
183
- old_trackable_object = Skee::App::TrackableObject::Service.get(
184
- id: trackable_object_id
185
- )
186
- new_trackable_object = Skee::App::TrackableObject::Service.get(
187
- id: trackable_object_id,
188
- change_request_id: remove_entity_params['change_request_id']
189
- )
190
- assert_includes(old_trackable_object.versioned_entity_snapshot.property_ids, property_id)
191
- assert_includes(new_trackable_object.versioned_entity_snapshot.property_ids, property_id)
192
- end
193
- end
194
- end
195
- end
196
- end
197
- end
@@ -1,134 +0,0 @@
1
- require_relative '../../test_helper'
2
- require_relative 'versioned_entity_helper'
3
- module Skee
4
- module API
5
- module Test
6
- module Functional
7
- class TrackableObjectTest < MiniTest::Test
8
- include Rack::Test::Methods
9
- include Skee::API::Test::Functional::VersionedEntityHelper
10
-
11
- def app
12
- Skee::API::Routes::TrackableObject::API
13
- end
14
-
15
- def initialize_db
16
- @trackable_objects = Skee::Test::Fixtures::TrackableObjects.all
17
- @trackable_objects.each { |entity| Skee::DB::Proto::TrackableObject.create(entity) }
18
- @trackable_object_snapshots = Skee::Test::Fixtures::TrackableObjectSnapshots.all
19
- @trackable_object_snapshots.each { |entity| Skee::DB::Proto::TrackableObjectSnapshot.create(entity) }
20
- @change_requests = Skee::Test::Fixtures::ChangeRequests.all
21
- @change_requests.each { |entity| Skee::DB::Proto::ChangeRequest.create(entity) }
22
- @tracking_specs = Skee::Test::Fixtures::TrackingSpecs.all
23
- @tracking_specs.each { |entity| Skee::DB::Proto::TrackingSpec.create(entity) }
24
- end
25
-
26
- def clear_db
27
- Skee::DB::Proto::TrackableObject.delete_all
28
- Skee::DB::Proto::ChangeRequest.delete_all
29
- Skee::DB::Proto::TrackingSpec.delete_all
30
- end
31
-
32
- def setup
33
- clear_db
34
- initialize_db
35
- @entity_type = :trackable_object
36
- @entity_path = 'trackable_objects'
37
- @entity_fixture = Skee::Test::Fixtures::TrackableObjects
38
- end
39
-
40
- # def test_get_all_trackable_objects
41
- # get_all_entities
42
- # end
43
-
44
- def test_retrieve_trackable_object
45
- id = '4'
46
- retrieve_entity(id)
47
- end
48
-
49
- def test_retrieve_trackable_object_with_change_request
50
- id = '4'
51
- snapshot_id = '5'
52
- params = {'change_request_id' => '1'}
53
- retrieved_entity = retrieve_entity(id, params)
54
- assert_equal(
55
- snapshot_id,
56
- retrieved_entity['snapshot_id']
57
- )
58
- end
59
-
60
- def test_create_trackable_object_invalid_change_request
61
- new_entity_params = {'name' => 'name', 'change_request_id' => '-999'}
62
- create_entity_invalid_change_request(new_entity_params)
63
- end
64
-
65
- def test_create_trackable_object_valid_name
66
- new_entity_params = {'name' => 'Cart', 'change_request_id' => '1'}
67
- create_entity_valid_name(new_entity_params)
68
- end
69
-
70
- def test_update_trackable_object_invalid_change_request
71
- id = '3'
72
- params = {'name' => 'name', 'change_request_id' => '-999'}
73
- update_entity_invalid_change_request(id, params)
74
- end
75
-
76
- def test_update_trackable_object_valid_creates_new_entity
77
- id = '3'
78
- params = {'name' => 'Cart', 'change_request_id' => '1'}
79
- updated_entity = update_entity_valid_creates_new_entity(id, params)
80
- assert_equal(
81
- params['name'],
82
- updated_entity['name']
83
- )
84
- assert_equal(id, updated_entity['previous_snapshot_id'])
85
- end
86
-
87
- def test_update_trackable_object_valid_updates_existing_snapshot_of_updated_trackable_object
88
- id = '4'
89
- params = {'name' => 'All Shops', 'change_request_id' => '1'}
90
- updated_entity = update_entity_valid_updates_existing_snapshot_of_updated_entity(id, params)
91
- assert_equal(
92
- params['name'],
93
- updated_entity['name']
94
- )
95
- end
96
-
97
- def test_update_trackable_object_valid_updates_existing_snapshot_of_new_trackable_object
98
- id = '5'
99
- params = {'name' => 'Logged-in User', 'change_request_id' => '1'}
100
- updated_entity = update_entity_valid_updates_existing_snapshot_of_new_entity(id, params)
101
- assert_equal(
102
- params['name'],
103
- updated_entity['name']
104
- )
105
- end
106
-
107
- def test_remove_trackable_object_invalid_change_request
108
- id = '3'
109
- params = {'change_request_id' => '-999'}
110
- remove_entity_invalid_change_request(id, params)
111
- end
112
-
113
- def test_remove_trackable_object_valid_creates_new_entity
114
- id = '3'
115
- params = {'change_request_id' => '1'}
116
- remove_entity_valid_creates_new_entity(id, params)
117
- end
118
-
119
- def test_remove_trackable_object_valid_updates_existing_snapshot_of_updated_trackable_object
120
- id = '4'
121
- params = {'change_request_id' => '1'}
122
- remove_entity_valid_updates_existing_snapshot_of_updated_entity(id, params)
123
- end
124
-
125
- def test_remove_trackable_object_valid_updates_existing_snapshot_of_new_trackable_object
126
- id = '5'
127
- params = {'change_request_id' => '1'}
128
- remove_entity_valid_updates_existing_snapshot_of_new_entity(id, params)
129
- end
130
- end
131
- end
132
- end
133
- end
134
- end
@@ -1,56 +0,0 @@
1
- require_relative '../../test_helper'
2
- module Skee
3
- module API
4
- module Test
5
- module Functional
6
- class TrackingSpecTest < MiniTest::Test
7
- include Rack::Test::Methods
8
-
9
- def app
10
- Skee::API::Routes::TrackingSpec::API
11
- end
12
-
13
- def initialize_db
14
- @properties = Skee::Test::Fixtures::Properties.all
15
- @properties.each { |entity| Skee::DB::Proto::Property.create(entity) }
16
- @property_snapshots = Skee::Test::Fixtures::PropertySnapshots.all
17
- @property_snapshots.each { |entity| Skee::DB::Proto::PropertySnapshot.create(entity) }
18
- @trackable_objects = Skee::Test::Fixtures::TrackableObjects.all
19
- @trackable_objects.each { |entity| Skee::DB::Proto::TrackableObject.create(entity) }
20
- @trackable_object_snapshots = Skee::Test::Fixtures::TrackableObjectSnapshots.all
21
- @trackable_object_snapshots.each { |entity| Skee::DB::Proto::TrackableObjectSnapshot.create(entity) }
22
- @change_requests = Skee::Test::Fixtures::ChangeRequests.all
23
- @change_requests.each { |entity| Skee::DB::Proto::ChangeRequest.create(entity) }
24
- @tracking_specs = Skee::Test::Fixtures::TrackingSpecs.all
25
- @tracking_specs.each { |entity| Skee::DB::Proto::TrackingSpec.create(entity) }
26
- @events = Skee::Test::Fixtures::Events.all
27
- @events.each { |entity| Skee::DB::Proto::Event.create(entity) }
28
- @event_snapshots = Skee::Test::Fixtures::EventSnapshots.all
29
- @event_snapshots.each { |entity| Skee::DB::Proto::EventSnapshot.create(entity) }
30
- end
31
-
32
- def clear_db
33
- Skee::DB::Proto::Property.delete_all
34
- Skee::DB::Proto::TrackableObject.delete_all
35
- Skee::DB::Proto::ChangeRequest.delete_all
36
- Skee::DB::Proto::TrackingSpec.delete_all
37
- Skee::DB::Proto::Event.delete_all
38
- end
39
-
40
- def setup
41
- clear_db
42
- initialize_db
43
- end
44
-
45
- def test_expands_results
46
- change_request_id = '0'
47
- tracking_spec_id = '1'
48
- params = {'change_request_id' => change_request_id}
49
- get "/api/tracking_specs/#{tracking_spec_id}/expand", params
50
- assert last_response.ok?
51
- end
52
- end
53
- end
54
- end
55
- end
56
- end
@@ -1,24 +0,0 @@
1
- require_relative '../../test_helper'
2
- module Skee
3
- module API
4
- module Test
5
- module Functional
6
- class UserTest < MiniTest::Test
7
- include Rack::Test::Methods
8
-
9
- def app
10
- Skee::API::Routes::User::API
11
- end
12
-
13
- def test_authenticate
14
- post '/api/users/authenticate', username: 'user', password: 'password'
15
- assert last_response.created?
16
- body = JSON.parse(last_response.body)
17
- assert_equal('user', body['username'])
18
- assert_equal('123', body['access_token'])
19
- end
20
- end
21
- end
22
- end
23
- end
24
- end
@@ -1,157 +0,0 @@
1
- require_relative '../../test_helper'
2
- module Skee
3
- module API
4
- module Test
5
- module Functional
6
- module VersionedEntityHelper
7
-
8
- def get_all_entities
9
- get "/api/#{@entity_path}"
10
- assert last_response.ok?
11
- expected_entity_ids = @entity_fixture.all.map{ |e| e[:id] }
12
- response_entity_ids = JSON.parse(last_response.body).map{ |e| e['id'] }
13
- assert_empty(expected_entity_ids - response_entity_ids)
14
- end
15
-
16
- def retrieve_entity(id, params=nil)
17
- get "/api/#{@entity_path}/#{id}", params
18
- retrieved_entity = JSON.parse(last_response.body)
19
- assert last_response.ok?
20
- assert_equal(
21
- id,
22
- retrieved_entity['id']
23
- )
24
- retrieved_entity
25
- end
26
-
27
- def create_entity_invalid_change_request(new_entity_params)
28
- post "/api/#{@entity_path}", new_entity_params
29
- assert_equal(400, last_response.status)
30
- assert_equal(
31
- "{\"error\":\"Invalid change request\"}",
32
- last_response.body
33
- )
34
- end
35
-
36
- def create_entity_valid_name(new_entity_params)
37
- post "/api/#{@entity_path}", new_entity_params
38
- change_request = Skee::App::DB_MAPPING_ENTITY[:change_request].find(new_entity_params['change_request_id'])
39
- new_entity = JSON.parse(last_response.body)
40
- assert_equal(201,last_response.status)
41
- assert_equal(
42
- new_entity_params['name'],
43
- new_entity['name']
44
- )
45
- assert_includes(change_request.change_set[@entity_type][new_entity['id']].values, new_entity['snapshot_id'])
46
- new_entity
47
- end
48
-
49
- def update_entity_invalid_change_request(id, update_params)
50
- post "/api/#{@entity_path}/#{id}", update_params
51
- assert_equal(400, last_response.status)
52
- assert_equal(
53
- "{\"error\":\"Invalid change request\"}",
54
- last_response.body
55
- )
56
- end
57
-
58
- def update_entity_valid_creates_new_entity(id, update_params)
59
- post "/api/#{@entity_path}/#{id}", update_params
60
- change_request = Skee::App::DB_MAPPING_ENTITY[:change_request].find(update_params['change_request_id'])
61
- updated_entity = JSON.parse(last_response.body)
62
- assert_equal(201, last_response.status)
63
- assert_equal(id, updated_entity['id'])
64
- assert_includes(change_request.change_set[@entity_type].keys, id)
65
- assert_equal(change_request.change_set[@entity_type][id].values.first, updated_entity['snapshot_id'])
66
- assert_equal(change_request.change_set[@entity_type][id].keys.first, updated_entity['previous_snapshot_id'])
67
- updated_entity
68
- end
69
-
70
- def update_entity_valid_updates_existing_snapshot_of_updated_entity(id, update_params)
71
- old_change_request = Skee::App::DB_MAPPING_ENTITY[:change_request].find(update_params['change_request_id'])
72
- post "/api/#{@entity_path}/#{id}", update_params
73
- updated_change_request = Skee::App::DB_MAPPING_ENTITY[:change_request].find(update_params['change_request_id'])
74
- updated_entity = JSON.parse(last_response.body)
75
- assert_equal(201, last_response.status)
76
- assert_equal(id, updated_entity['id'])
77
- assert_includes(updated_change_request.change_set[@entity_type].keys, id)
78
- assert_equal(updated_change_request.change_set[@entity_type][id].values.first,
79
- old_change_request.change_set[@entity_type][id].values.first)
80
- assert_equal(updated_change_request.change_set[@entity_type][id].keys.first,
81
- old_change_request.change_set[@entity_type][id].keys.first)
82
- updated_entity
83
- end
84
-
85
- def update_entity_valid_updates_existing_snapshot_of_new_entity(id, update_params)
86
- old_change_request = Skee::App::DB_MAPPING_ENTITY[:change_request].find(update_params['change_request_id'])
87
- post "/api/#{@entity_path}/#{id}", update_params
88
- updated_change_request = Skee::App::DB_MAPPING_ENTITY[:change_request].find(update_params['change_request_id'])
89
- updated_entity = JSON.parse(last_response.body)
90
- assert_equal(201, last_response.status)
91
- assert_equal(id, updated_entity['id'])
92
- assert_includes(updated_change_request.change_set[@entity_type].keys, id)
93
- assert_equal(old_change_request.change_set[@entity_type][id].values.first,
94
- updated_change_request.change_set[@entity_type][id].values.first)
95
- assert_nil(updated_change_request.change_set[@entity_type][id].keys.first)
96
- assert_nil(updated_entity['previous_snapshot_id'])
97
- updated_entity
98
- end
99
-
100
- def remove_entity_invalid_change_request(id, remove_params)
101
- post "/api/#{@entity_path}/#{id}/remove", remove_params
102
- assert_equal(400, last_response.status)
103
- assert_equal(
104
- "{\"error\":\"Invalid change request\"}",
105
- last_response.body
106
- )
107
- end
108
-
109
- def remove_entity_valid_creates_new_entity(id, remove_params)
110
- post "/api/#{@entity_path}/#{id}/remove", remove_params
111
- change_request = Skee::App::DB_MAPPING_ENTITY[:change_request].find(remove_params['change_request_id'])
112
- updated_entity = JSON.parse(last_response.body)
113
- assert_equal(201, last_response.status)
114
- assert_equal(true, updated_entity['is_removed'])
115
- assert_equal(id, updated_entity['id'])
116
- assert_includes(change_request.change_set[@entity_type].keys, id)
117
- assert_equal(change_request.change_set[@entity_type][id].values.first, updated_entity['snapshot_id'])
118
- assert_equal(change_request.change_set[@entity_type][id].keys.first, updated_entity['previous_snapshot_id'])
119
- updated_entity
120
- end
121
-
122
- def remove_entity_valid_updates_existing_snapshot_of_updated_entity(id, remove_params)
123
- old_change_request = Skee::App::DB_MAPPING_ENTITY[:change_request].find(remove_params['change_request_id'])
124
- post "/api/#{@entity_path}/#{id}/remove", remove_params
125
- updated_change_request = Skee::App::DB_MAPPING_ENTITY[:change_request].find(remove_params['change_request_id'])
126
- updated_entity = JSON.parse(last_response.body)
127
- assert_equal(201, last_response.status)
128
- assert_equal(true, updated_entity['is_removed'])
129
- assert_equal(id, updated_entity['id'])
130
- assert_includes(updated_change_request.change_set[@entity_type].keys, id)
131
- assert_equal(updated_change_request.change_set[@entity_type][id].values.first,
132
- old_change_request.change_set[@entity_type][id].values.first)
133
- assert_equal(updated_change_request.change_set[@entity_type][id].keys.first,
134
- old_change_request.change_set[@entity_type][id].keys.first)
135
- updated_entity
136
- end
137
-
138
- def remove_entity_valid_updates_existing_snapshot_of_new_entity(id, remove_params)
139
- old_change_request = Skee::App::DB_MAPPING_ENTITY[:change_request].find(remove_params['change_request_id'])
140
- post "/api/#{@entity_path}/#{id}/remove", remove_params
141
- updated_change_request = Skee::App::DB_MAPPING_ENTITY[:change_request].find(remove_params['change_request_id'])
142
- updated_entity = JSON.parse(last_response.body)
143
- assert_equal(201, last_response.status)
144
- assert_equal(true, updated_entity['is_removed'])
145
- assert_equal(id, updated_entity['id'])
146
- assert_includes(updated_change_request.change_set[@entity_type].keys, id)
147
- assert_equal(old_change_request.change_set[@entity_type][id].values.first,
148
- updated_change_request.change_set[@entity_type][id].values.first)
149
- assert_nil(updated_change_request.change_set[@entity_type][id].keys.first)
150
- assert_nil(updated_entity['previous_snapshot_id'])
151
- updated_entity
152
- end
153
- end
154
- end
155
- end
156
- end
157
- end
@@ -1,83 +0,0 @@
1
- module Skee
2
- module Test
3
- module Fixtures
4
- class ChangeRequests
5
- def self.all
6
- all_change_requests = [
7
- {
8
- 'id': '1',
9
- 'name': 'Self-enabling disintermediate budgetary management',
10
- 'identifier': 'Voltsillam',
11
- 'project_id': '1',
12
- 'source_tracking_spec_id': '0',
13
- 'status': 'open',
14
- 'description': 'nulla suscipit ligula in lacus curabitur at ipsum',
15
- 'change_set': {
16
- trackable_object: {
17
- '4' => {
18
- '4' => '5'
19
- },
20
- '5' => {
21
- nil => '7'
22
- }
23
- },
24
- property: {
25
- '4' => {
26
- '4' => '5'
27
- },
28
- '5' => {
29
- nil => '7'
30
- }
31
- },
32
- event: {
33
- '4' => {
34
- '4' => '5'
35
- },
36
- '5' => {
37
- nil => '7'
38
- }
39
- },
40
- }
41
- }
42
- ]
43
- all_change_requests << initial_change_request
44
- end
45
-
46
- def self.initial_change_request
47
- {
48
- 'id': '0',
49
- 'name': 'Budgetary management',
50
- 'identifier': 'beginning',
51
- 'project_id': '1',
52
- 'source_tracking_spec_id': nil,
53
- 'status': 'open',
54
- 'description': 'nulla suscipit ligula in lacus curabitur at ipsum',
55
- 'change_set': {
56
- trackable_object: {
57
- '4' => {
58
- nil => '4'
59
- },
60
- },
61
- property: {
62
- '5' => {
63
- nil => '7'
64
- }
65
- },
66
- event: {
67
- '1' => {
68
- nil => '1'
69
- },
70
- '3' => {
71
- nil => '5'
72
- },
73
- '4' => {
74
- nil => '4'
75
- }
76
- },
77
- }
78
- }
79
- end
80
- end
81
- end
82
- end
83
- end