montage_rails 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/montage_rails/model_generator.rb +49 -0
- data/lib/generators/montage_rails/templates/model.rb +5 -0
- data/lib/generators/montage_rails/templates/resource.rb +22 -0
- data/lib/generators/montage_rails/templates/test_data.rb +6 -0
- data/lib/montage_rails/application_resource.rb +63 -0
- data/lib/montage_rails/mock_server.rb +54 -0
- data/lib/montage_rails/railtie.rb +5 -0
- data/lib/montage_rails/version.rb +1 -1
- data/lib/montage_rails.rb +34 -1
- data/test/dummy/app/models/movie.rb +1 -0
- data/test/dummy/app/models/test_mod.rb +3 -0
- data/test/dummy/app/models/test_one.rb +3 -0
- data/test/dummy/config/initializers/montage.rb +1 -0
- data/test/dummy/config/routes.rb +3 -54
- data/test/dummy/log/development.log +8 -0
- data/test/dummy/log/test.log +4074 -0
- data/test/dummy/test/fixtures/actors.yml +9 -0
- data/test/dummy/test/fixtures/movies.yml +17 -0
- data/test/dummy/test/fixtures/studios.yml +7 -0
- data/test/dummy/test/fixtures/test_mods.yml +9 -0
- data/test/dummy/test/fixtures/test_ones.yml +11 -0
- data/test/dummy/test/models/actor_test.rb +7 -0
- data/test/dummy/test/models/movie_test.rb +7 -0
- data/test/dummy/test/models/studio_test.rb +7 -0
- data/test/dummy/test/models/test_mod_test.rb +5 -0
- data/test/dummy/test/models/test_one_test.rb +7 -0
- data/test/dummy/test/montage_resources/actor_resource.rb +26 -0
- data/test/dummy/test/montage_resources/movie_resource.rb +43 -0
- data/test/dummy/test/montage_resources/studio_resource.rb +18 -0
- data/test/dummy/test/montage_resources/test_data/actor_test_data.yml +8 -0
- data/test/dummy/test/montage_resources/test_data/movie_test_data.yml +8 -0
- data/test/dummy/test/montage_resources/test_data/studio_test_data.yml +3 -0
- data/test/dummy/test/resources/test_mod_resource.rb +22 -0
- data/test/dummy/test/resources/test_one_resource.rb +26 -0
- data/test/dummy/test/test_helper.rb +0 -0
- data/test/montage_rails/application_resource_test.rb +92 -0
- data/test/montage_rails/base_test.rb +22 -22
- data/test/montage_rails/relation_test.rb +1 -1
- data/test/montage_rails_test.rb +57 -14
- data/test/test_helper.rb +9 -166
- metadata +108 -22
- data/test/resources/actor_resource.rb +0 -141
- data/test/resources/movie_resource.rb +0 -221
- data/test/resources/studio_resource.rb +0 -56
@@ -1,221 +0,0 @@
|
|
1
|
-
module MontageRails
|
2
|
-
class MovieResource
|
3
|
-
def self.schema_definition
|
4
|
-
{
|
5
|
-
name: "movies",
|
6
|
-
fields: [
|
7
|
-
{name: "studio_id", datatype: "text", indexed: false, required: false},
|
8
|
-
{name: "rank", datatype: "numeric", indexed: false, required: true},
|
9
|
-
{name: "rating", datatype: "numeric", indexed: false, required: true},
|
10
|
-
{name: "title", datatype: "text", indexed: false, required: true},
|
11
|
-
{name: "votes", datatype: "numeric", indexed: false, required: true},
|
12
|
-
{name: "year", datatype: "numeric", indexed: false, required: true}
|
13
|
-
],
|
14
|
-
links: {
|
15
|
-
query: "http://testco.dev.montagehot.club/api/v1/schemas/movies/query/",
|
16
|
-
self: "http://testco.dev.montagehot.club/api/v1/schemas/movies/",
|
17
|
-
create_document: "http://testco.dev.montagehot.club/api/v1/schemas/movies/save/"
|
18
|
-
}
|
19
|
-
}
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.to_hash
|
23
|
-
{
|
24
|
-
studio_id: "19442e09-5c2d-4e5d-8f34-675570e81414",
|
25
|
-
rank: 4,
|
26
|
-
rating: 2.0,
|
27
|
-
title: "The Jerk",
|
28
|
-
votes: 500,
|
29
|
-
year: 1983
|
30
|
-
}
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.save_with_update_hash
|
34
|
-
{
|
35
|
-
id: nil,
|
36
|
-
studio_id: "19442e09-5c2d-4e5d-8f34-675570e81414",
|
37
|
-
rank: 4,
|
38
|
-
rating: 2.0,
|
39
|
-
title: "The Jerk",
|
40
|
-
votes: 500,
|
41
|
-
year: 1983
|
42
|
-
}
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.update_body
|
46
|
-
[
|
47
|
-
{
|
48
|
-
id: "69cc93af-1f0e-43bc-ac9a-19117111978e",
|
49
|
-
studio_id: "19442e09-5c2d-4e5d-8f34-675570e81414",
|
50
|
-
rank: 4,
|
51
|
-
rating: 2.0,
|
52
|
-
title: "The Jerk",
|
53
|
-
votes: 600,
|
54
|
-
year: 1983
|
55
|
-
}
|
56
|
-
]
|
57
|
-
end
|
58
|
-
|
59
|
-
def self.update_votes
|
60
|
-
[
|
61
|
-
{
|
62
|
-
id: "69cc93af-1f0e-43bc-ac9a-19117111978e",
|
63
|
-
studio_id: "19442e09-5c2d-4e5d-8f34-675570e81414",
|
64
|
-
rank: 4,
|
65
|
-
rating: 2.0,
|
66
|
-
title: "The Jerk",
|
67
|
-
votes: 900,
|
68
|
-
year: 1983
|
69
|
-
}
|
70
|
-
]
|
71
|
-
end
|
72
|
-
|
73
|
-
def self.save_response
|
74
|
-
{
|
75
|
-
data: [
|
76
|
-
{
|
77
|
-
votes: 500,
|
78
|
-
_meta: {
|
79
|
-
modified: "2015-04-20T18:39:47.751Z",
|
80
|
-
created: "2015-04-20T18:39:47.751Z"
|
81
|
-
},
|
82
|
-
rating: 2.0,
|
83
|
-
year: 1983,
|
84
|
-
id: "69cc93af-1f0e-43bc-ac9a-19117111978e",
|
85
|
-
title:"The Jerk",
|
86
|
-
rank: 4,
|
87
|
-
studio_id: "19442e09-5c2d-4e5d-8f34-675570e81414"
|
88
|
-
}
|
89
|
-
]
|
90
|
-
}
|
91
|
-
end
|
92
|
-
|
93
|
-
def self.update_response
|
94
|
-
{
|
95
|
-
data: [
|
96
|
-
{
|
97
|
-
votes: 600,
|
98
|
-
_meta: {
|
99
|
-
modified: "2015-04-20T18:39:47.751Z",
|
100
|
-
created: "2015-04-20T18:39:47.751Z"
|
101
|
-
},
|
102
|
-
rating: 2.0,
|
103
|
-
year: 1983,
|
104
|
-
id: "69cc93af-1f0e-43bc-ac9a-19117111978e",
|
105
|
-
title:"The Jerk",
|
106
|
-
rank: 4,
|
107
|
-
studio_id: "19442e09-5c2d-4e5d-8f34-675570e81414"
|
108
|
-
}
|
109
|
-
]
|
110
|
-
}
|
111
|
-
end
|
112
|
-
|
113
|
-
def self.update_votes_response
|
114
|
-
{
|
115
|
-
data: [
|
116
|
-
{
|
117
|
-
votes: 900,
|
118
|
-
_meta: {
|
119
|
-
modified: "2015-04-20T18:39:47.751Z",
|
120
|
-
created: "2015-04-20T18:39:47.751Z"
|
121
|
-
},
|
122
|
-
rating: 2.0,
|
123
|
-
year: 1983,
|
124
|
-
id: "69cc93af-1f0e-43bc-ac9a-19117111978e",
|
125
|
-
title:"The Jerk",
|
126
|
-
rank: 4,
|
127
|
-
studio_id: "19442e09-5c2d-4e5d-8f34-675570e81414"
|
128
|
-
}
|
129
|
-
]
|
130
|
-
}
|
131
|
-
end
|
132
|
-
|
133
|
-
def self.movie_query
|
134
|
-
{
|
135
|
-
filter: {
|
136
|
-
title: "The Jerk"
|
137
|
-
},
|
138
|
-
limit: 1
|
139
|
-
}
|
140
|
-
end
|
141
|
-
|
142
|
-
def self.movie_query_pluck
|
143
|
-
{
|
144
|
-
filter: {
|
145
|
-
title: "The Jerk"
|
146
|
-
},
|
147
|
-
pluck: ["title"]
|
148
|
-
}
|
149
|
-
end
|
150
|
-
|
151
|
-
def self.query_result
|
152
|
-
{
|
153
|
-
data: [
|
154
|
-
{
|
155
|
-
_meta: {
|
156
|
-
modified: "2015-04-20T18:39:50.095Z",
|
157
|
-
created: "2015-04-20T18:39:47.751Z"
|
158
|
-
},
|
159
|
-
votes: 600,
|
160
|
-
rating: 2.0,
|
161
|
-
year: 1983,
|
162
|
-
id: "69cc93af-1f0e-43bc-ac9a-19117111978e",
|
163
|
-
title: "The Jerk",
|
164
|
-
rank: 4,
|
165
|
-
studio_id: "19442e09-5c2d-4e5d-8f34-675570e81414"
|
166
|
-
}
|
167
|
-
],
|
168
|
-
cursors: {
|
169
|
-
previous: nil,
|
170
|
-
next: nil
|
171
|
-
}
|
172
|
-
}
|
173
|
-
end
|
174
|
-
|
175
|
-
def self.pluck_response
|
176
|
-
{
|
177
|
-
data: [
|
178
|
-
{
|
179
|
-
_meta: {
|
180
|
-
modified: "2015-04-20T18:39:50.095Z",
|
181
|
-
created: "2015-04-20T18:39:47.751Z"
|
182
|
-
},
|
183
|
-
title: "The Jerk",
|
184
|
-
}
|
185
|
-
],
|
186
|
-
cursors: {
|
187
|
-
previous: nil,
|
188
|
-
next: nil
|
189
|
-
}
|
190
|
-
}
|
191
|
-
end
|
192
|
-
|
193
|
-
def self.find_movie_query
|
194
|
-
{
|
195
|
-
filter: {
|
196
|
-
title: "The Jerk"
|
197
|
-
}
|
198
|
-
}
|
199
|
-
end
|
200
|
-
|
201
|
-
def self.movie_not_found_query
|
202
|
-
{
|
203
|
-
filter: {
|
204
|
-
title: "Foo"
|
205
|
-
}
|
206
|
-
}
|
207
|
-
end
|
208
|
-
|
209
|
-
def self.all_movies_query
|
210
|
-
{ filter: {} }
|
211
|
-
end
|
212
|
-
|
213
|
-
def self.gt_query
|
214
|
-
{
|
215
|
-
filter: {
|
216
|
-
votes__gt: 900000
|
217
|
-
}
|
218
|
-
}
|
219
|
-
end
|
220
|
-
end
|
221
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
module MontageRails
|
2
|
-
class StudioResource
|
3
|
-
def self.schema_definition
|
4
|
-
{
|
5
|
-
name: "studios",
|
6
|
-
fields: [
|
7
|
-
{
|
8
|
-
name: "name",
|
9
|
-
datatype: "text",
|
10
|
-
indexed: false,
|
11
|
-
required: true
|
12
|
-
}
|
13
|
-
],
|
14
|
-
links: {
|
15
|
-
self: "http://testco.dev.montagehot.club/api/v1/schemas/studios/",
|
16
|
-
query: "http://testco.dev.montagehot.club/api/v1/schemas/studios/query/",
|
17
|
-
create_document: "http://testco.dev.montagehot.club/api/v1/schemas/studios/save/"
|
18
|
-
}
|
19
|
-
}
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.to_hash
|
23
|
-
{
|
24
|
-
name: "Universal"
|
25
|
-
}
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.save_response
|
29
|
-
{
|
30
|
-
data: [
|
31
|
-
{
|
32
|
-
id: "19442e09-5c2d-4e5d-8f34-675570e81414",
|
33
|
-
_meta: {
|
34
|
-
modified: "2015-04-20T18:39:51.394Z",
|
35
|
-
created: "2015-04-20T18:39:51.394Z"
|
36
|
-
},
|
37
|
-
name: "Universal"
|
38
|
-
}
|
39
|
-
]
|
40
|
-
}
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.get_studio_response
|
44
|
-
{
|
45
|
-
data: {
|
46
|
-
id: "19442e09-5c2d-4e5d-8f34-675570e81414",
|
47
|
-
_meta: {
|
48
|
-
modified: "2015-04-20T18:39:51.394Z",
|
49
|
-
created: "2015-04-20T18:39:51.394Z"
|
50
|
-
},
|
51
|
-
name: "Universal"
|
52
|
-
}
|
53
|
-
}
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|