easy-resources 0.5.4 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/easy/resources/version.rb +1 -1
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +3 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/javascripts/cable.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/jobs/application_job.rb +2 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/views/layouts/application.html.erb +15 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +36 -0
- data/spec/dummy/bin/update +31 -0
- data/spec/dummy/bin/yarn +11 -0
- data/spec/dummy/config.ru +5 -0
- data/spec/dummy/config/application.rb +19 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/cable.yml +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +61 -0
- data/spec/dummy/config/environments/production.rb +94 -0
- data/spec/dummy/config/environments/test.rb +46 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/dummy/config/initializers/assets.rb +14 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/content_security_policy.rb +25 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/new_framework_defaults_5_2.rb +38 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +33 -0
- data/spec/dummy/config/puma.rb +34 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/config/spring.rb +6 -0
- data/spec/dummy/config/storage.yml +34 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -0
- data/spec/dummy/log/test.log +0 -0
- data/spec/dummy/package.json +5 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/easy_resources_spec.rb +8 -0
- data/spec/fixtures/files/easy_contact.json +71 -0
- data/spec/fixtures/files/easy_contact/show.xml +48 -0
- data/spec/fixtures/files/easy_crm_case.json +41 -0
- data/spec/fixtures/files/easy_crm_case/show.xml +36 -0
- data/spec/fixtures/files/easy_server/index.xml +36 -0
- data/spec/fixtures/files/easy_server/show.xml +33 -0
- data/spec/fixtures/files/easy_web_application/index.xml +32 -0
- data/spec/fixtures/files/easy_web_application/show.json +54 -0
- data/spec/fixtures/files/easy_web_application/show.xml +16 -0
- data/spec/fixtures/files/easy_web_application/with_custom_fields.xml +0 -0
- data/spec/fixtures/files/easy_web_application/with_easy_contact.xml +17 -0
- data/spec/fixtures/files/easy_web_application/with_easy_crm_case.xml +17 -0
- data/spec/fixtures/files/easy_web_application/with_ewaa.xml +7 -0
- data/spec/fixtures/files/issue.json +56 -0
- data/spec/fixtures/files/issue/show.xml +31 -0
- data/spec/fixtures/files/project.json +40 -0
- data/spec/fixtures/files/project/show.xml +32 -0
- data/spec/models/easy-resources/redmine/easy_contact_spec.rb +26 -0
- data/spec/models/easy-resources/redmine/easy_crm_case_spec.rb +19 -0
- data/spec/models/easy-resources/redmine/easy_web_application_activity_spec.rb +6 -0
- data/spec/models/easy-resources/redmine/easy_web_application_spec.rb +59 -0
- data/spec/models/easy-resources/redmine/issue_spec.rb +15 -0
- data/spec/models/easy-resources/redmine/project_spec.rb +11 -0
- data/spec/models/easy-resources/redmine/redmine_base_spec.rb +8 -0
- data/spec/models/easy-resources/resource_spec.rb +42 -0
- data/spec/spec_helper.rb +24 -0
- data/spec/support/active_resource.rb +57 -0
- data/spec/support/fixtures.rb +5 -0
- data/spec/support/redmine_active_resource.rb +28 -0
- metadata +173 -3
@@ -0,0 +1,57 @@
|
|
1
|
+
RSpec.shared_context "active resource shares", shared_context: :metadata do
|
2
|
+
let(:site) { 'https://test.dummy' }
|
3
|
+
let(:api_key) { 'secret' }
|
4
|
+
|
5
|
+
let(:entity_name) {}
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
ActiveResource::HttpMock.reset!
|
9
|
+
end
|
10
|
+
|
11
|
+
def find_entity(source_file = nil)
|
12
|
+
stub_xml source_file: (source_file || "show"), path: "#{entity_name.pluralize}/1.xml"
|
13
|
+
|
14
|
+
described_class.find 1
|
15
|
+
end
|
16
|
+
|
17
|
+
# @param [Hash] options @see #stub_easy_resource_request
|
18
|
+
def stub_json(**options)
|
19
|
+
options[:format] = "json"
|
20
|
+
stub_resource_request(options)
|
21
|
+
end
|
22
|
+
|
23
|
+
# @param [Hash] options @see #stub_easy_resource_request
|
24
|
+
def stub_xml(**options)
|
25
|
+
options[:format] = "xml"
|
26
|
+
stub_resource_request(options)
|
27
|
+
end
|
28
|
+
|
29
|
+
# @param [String] format XML or JSON
|
30
|
+
# @param [String] path relative path in uri
|
31
|
+
# @param [Hash] options Request&response options
|
32
|
+
# @option options [String] :method (:get) HTTP method if request
|
33
|
+
# @option options [Integer] :status (200) response status code
|
34
|
+
# @option options [String] :source_file path for fixture
|
35
|
+
# @option options [String] :response_body
|
36
|
+
# @option options [String] :request_body
|
37
|
+
# @option options [String] :request_headers ({ "X-Redmine-API-Key" => some key })
|
38
|
+
# @option options [String] :response_headers ({})
|
39
|
+
# @return [ActiveResource::HttpMock::Responder]
|
40
|
+
def stub_resource_request(format:, path:, **options)
|
41
|
+
response_body = options[:response_body]
|
42
|
+
response_body ||= file_fixture("#{entity_name}/#{options[:source_file]}.#{format}").read if options[:source_file]
|
43
|
+
raise ArgumentError, "response_body must be given" if response_body.nil?
|
44
|
+
|
45
|
+
method = options[:method] || :get
|
46
|
+
r_headers = options[:request_headers] || {}
|
47
|
+
if %i[get delete].include?(method.to_sym)
|
48
|
+
r_headers["Accept"] = "application/#{format}"
|
49
|
+
else
|
50
|
+
r_headers["Content-Type"] = "application/#{format}"
|
51
|
+
end
|
52
|
+
|
53
|
+
request = ActiveResource::Request.new(method, "/#{path}", options[:request_body], r_headers)
|
54
|
+
response = ActiveResource::Response.new(response_body.to_s, options[:status] || 200, options[:response_headers] || {})
|
55
|
+
ActiveResource::HttpMock.respond_to({ request => response }, false)
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
RSpec.shared_context "redmine active resource shares", shared_context: :metadata do
|
2
|
+
include_context "active resource shares"
|
3
|
+
|
4
|
+
before :each do
|
5
|
+
Easy::Resources::Redmine::RedmineBase.site = site
|
6
|
+
Easy::Resources::Redmine::RedmineBase.api_key = api_key
|
7
|
+
end
|
8
|
+
|
9
|
+
# @param [Hash] options @see #stub_easy_resource_request
|
10
|
+
def stub_json(**options)
|
11
|
+
options[:format] = "json"
|
12
|
+
stub_easy_resource_request(options)
|
13
|
+
end
|
14
|
+
|
15
|
+
# @param [Hash] options @see #stub_easy_resource_request
|
16
|
+
def stub_xml(**options)
|
17
|
+
options[:format] = "xml"
|
18
|
+
stub_easy_resource_request(options)
|
19
|
+
end
|
20
|
+
|
21
|
+
def stub_easy_resource_request(format:, path:, **options)
|
22
|
+
options[:request_headers] ||= {}
|
23
|
+
options[:request_headers]["X-Redmine-API-Key"] = api_key
|
24
|
+
options[:format] = format
|
25
|
+
options[:path] = path
|
26
|
+
stub_resource_request options
|
27
|
+
end
|
28
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy-resources
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- petr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -145,6 +145,91 @@ files:
|
|
145
145
|
- lib/easy/resources/redmine/redmine_base.rb
|
146
146
|
- lib/easy/resources/spec_helper.rb
|
147
147
|
- lib/easy/resources/version.rb
|
148
|
+
- spec/dummy/Rakefile
|
149
|
+
- spec/dummy/app/assets/config/manifest.js
|
150
|
+
- spec/dummy/app/assets/javascripts/application.js
|
151
|
+
- spec/dummy/app/assets/javascripts/cable.js
|
152
|
+
- spec/dummy/app/assets/stylesheets/application.css
|
153
|
+
- spec/dummy/app/channels/application_cable/channel.rb
|
154
|
+
- spec/dummy/app/channels/application_cable/connection.rb
|
155
|
+
- spec/dummy/app/controllers/application_controller.rb
|
156
|
+
- spec/dummy/app/helpers/application_helper.rb
|
157
|
+
- spec/dummy/app/jobs/application_job.rb
|
158
|
+
- spec/dummy/app/mailers/application_mailer.rb
|
159
|
+
- spec/dummy/app/models/application_record.rb
|
160
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
161
|
+
- spec/dummy/app/views/layouts/mailer.html.erb
|
162
|
+
- spec/dummy/app/views/layouts/mailer.text.erb
|
163
|
+
- spec/dummy/bin/bundle
|
164
|
+
- spec/dummy/bin/rails
|
165
|
+
- spec/dummy/bin/rake
|
166
|
+
- spec/dummy/bin/setup
|
167
|
+
- spec/dummy/bin/update
|
168
|
+
- spec/dummy/bin/yarn
|
169
|
+
- spec/dummy/config.ru
|
170
|
+
- spec/dummy/config/application.rb
|
171
|
+
- spec/dummy/config/boot.rb
|
172
|
+
- spec/dummy/config/cable.yml
|
173
|
+
- spec/dummy/config/database.yml
|
174
|
+
- spec/dummy/config/environment.rb
|
175
|
+
- spec/dummy/config/environments/development.rb
|
176
|
+
- spec/dummy/config/environments/production.rb
|
177
|
+
- spec/dummy/config/environments/test.rb
|
178
|
+
- spec/dummy/config/initializers/application_controller_renderer.rb
|
179
|
+
- spec/dummy/config/initializers/assets.rb
|
180
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
181
|
+
- spec/dummy/config/initializers/content_security_policy.rb
|
182
|
+
- spec/dummy/config/initializers/cookies_serializer.rb
|
183
|
+
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
184
|
+
- spec/dummy/config/initializers/inflections.rb
|
185
|
+
- spec/dummy/config/initializers/mime_types.rb
|
186
|
+
- spec/dummy/config/initializers/new_framework_defaults_5_2.rb
|
187
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
188
|
+
- spec/dummy/config/locales/en.yml
|
189
|
+
- spec/dummy/config/puma.rb
|
190
|
+
- spec/dummy/config/routes.rb
|
191
|
+
- spec/dummy/config/spring.rb
|
192
|
+
- spec/dummy/config/storage.yml
|
193
|
+
- spec/dummy/db/test.sqlite3
|
194
|
+
- spec/dummy/log/development.log
|
195
|
+
- spec/dummy/log/test.log
|
196
|
+
- spec/dummy/package.json
|
197
|
+
- spec/dummy/public/404.html
|
198
|
+
- spec/dummy/public/422.html
|
199
|
+
- spec/dummy/public/500.html
|
200
|
+
- spec/dummy/public/apple-touch-icon-precomposed.png
|
201
|
+
- spec/dummy/public/apple-touch-icon.png
|
202
|
+
- spec/dummy/public/favicon.ico
|
203
|
+
- spec/easy_resources_spec.rb
|
204
|
+
- spec/fixtures/files/easy_contact.json
|
205
|
+
- spec/fixtures/files/easy_contact/show.xml
|
206
|
+
- spec/fixtures/files/easy_crm_case.json
|
207
|
+
- spec/fixtures/files/easy_crm_case/show.xml
|
208
|
+
- spec/fixtures/files/easy_server/index.xml
|
209
|
+
- spec/fixtures/files/easy_server/show.xml
|
210
|
+
- spec/fixtures/files/easy_web_application/index.xml
|
211
|
+
- spec/fixtures/files/easy_web_application/show.json
|
212
|
+
- spec/fixtures/files/easy_web_application/show.xml
|
213
|
+
- spec/fixtures/files/easy_web_application/with_custom_fields.xml
|
214
|
+
- spec/fixtures/files/easy_web_application/with_easy_contact.xml
|
215
|
+
- spec/fixtures/files/easy_web_application/with_easy_crm_case.xml
|
216
|
+
- spec/fixtures/files/easy_web_application/with_ewaa.xml
|
217
|
+
- spec/fixtures/files/issue.json
|
218
|
+
- spec/fixtures/files/issue/show.xml
|
219
|
+
- spec/fixtures/files/project.json
|
220
|
+
- spec/fixtures/files/project/show.xml
|
221
|
+
- spec/models/easy-resources/redmine/easy_contact_spec.rb
|
222
|
+
- spec/models/easy-resources/redmine/easy_crm_case_spec.rb
|
223
|
+
- spec/models/easy-resources/redmine/easy_web_application_activity_spec.rb
|
224
|
+
- spec/models/easy-resources/redmine/easy_web_application_spec.rb
|
225
|
+
- spec/models/easy-resources/redmine/issue_spec.rb
|
226
|
+
- spec/models/easy-resources/redmine/project_spec.rb
|
227
|
+
- spec/models/easy-resources/redmine/redmine_base_spec.rb
|
228
|
+
- spec/models/easy-resources/resource_spec.rb
|
229
|
+
- spec/spec_helper.rb
|
230
|
+
- spec/support/active_resource.rb
|
231
|
+
- spec/support/fixtures.rb
|
232
|
+
- spec/support/redmine_active_resource.rb
|
148
233
|
homepage: https://www.easysoftware.com
|
149
234
|
licenses:
|
150
235
|
- MIT
|
@@ -169,4 +254,89 @@ rubygems_version: 3.0.2
|
|
169
254
|
signing_key:
|
170
255
|
specification_version: 4
|
171
256
|
summary: Summary of Easy::Resources.
|
172
|
-
test_files:
|
257
|
+
test_files:
|
258
|
+
- spec/spec_helper.rb
|
259
|
+
- spec/dummy/app/mailers/application_mailer.rb
|
260
|
+
- spec/dummy/app/models/application_record.rb
|
261
|
+
- spec/dummy/app/jobs/application_job.rb
|
262
|
+
- spec/dummy/app/controllers/application_controller.rb
|
263
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
264
|
+
- spec/dummy/app/views/layouts/mailer.html.erb
|
265
|
+
- spec/dummy/app/views/layouts/mailer.text.erb
|
266
|
+
- spec/dummy/app/assets/config/manifest.js
|
267
|
+
- spec/dummy/app/assets/javascripts/cable.js
|
268
|
+
- spec/dummy/app/assets/javascripts/application.js
|
269
|
+
- spec/dummy/app/assets/stylesheets/application.css
|
270
|
+
- spec/dummy/app/helpers/application_helper.rb
|
271
|
+
- spec/dummy/app/channels/application_cable/connection.rb
|
272
|
+
- spec/dummy/app/channels/application_cable/channel.rb
|
273
|
+
- spec/dummy/bin/update
|
274
|
+
- spec/dummy/bin/rake
|
275
|
+
- spec/dummy/bin/setup
|
276
|
+
- spec/dummy/bin/bundle
|
277
|
+
- spec/dummy/bin/yarn
|
278
|
+
- spec/dummy/bin/rails
|
279
|
+
- spec/dummy/config/routes.rb
|
280
|
+
- spec/dummy/config/locales/en.yml
|
281
|
+
- spec/dummy/config/cable.yml
|
282
|
+
- spec/dummy/config/environments/production.rb
|
283
|
+
- spec/dummy/config/environments/development.rb
|
284
|
+
- spec/dummy/config/environments/test.rb
|
285
|
+
- spec/dummy/config/spring.rb
|
286
|
+
- spec/dummy/config/environment.rb
|
287
|
+
- spec/dummy/config/storage.yml
|
288
|
+
- spec/dummy/config/application.rb
|
289
|
+
- spec/dummy/config/puma.rb
|
290
|
+
- spec/dummy/config/database.yml
|
291
|
+
- spec/dummy/config/boot.rb
|
292
|
+
- spec/dummy/config/initializers/application_controller_renderer.rb
|
293
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
294
|
+
- spec/dummy/config/initializers/mime_types.rb
|
295
|
+
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
296
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
297
|
+
- spec/dummy/config/initializers/assets.rb
|
298
|
+
- spec/dummy/config/initializers/cookies_serializer.rb
|
299
|
+
- spec/dummy/config/initializers/content_security_policy.rb
|
300
|
+
- spec/dummy/config/initializers/inflections.rb
|
301
|
+
- spec/dummy/config/initializers/new_framework_defaults_5_2.rb
|
302
|
+
- spec/dummy/config.ru
|
303
|
+
- spec/dummy/Rakefile
|
304
|
+
- spec/dummy/public/favicon.ico
|
305
|
+
- spec/dummy/public/422.html
|
306
|
+
- spec/dummy/public/apple-touch-icon.png
|
307
|
+
- spec/dummy/public/500.html
|
308
|
+
- spec/dummy/public/404.html
|
309
|
+
- spec/dummy/public/apple-touch-icon-precomposed.png
|
310
|
+
- spec/dummy/package.json
|
311
|
+
- spec/dummy/db/test.sqlite3
|
312
|
+
- spec/dummy/log/test.log
|
313
|
+
- spec/dummy/log/development.log
|
314
|
+
- spec/models/easy-resources/redmine/project_spec.rb
|
315
|
+
- spec/models/easy-resources/redmine/easy_crm_case_spec.rb
|
316
|
+
- spec/models/easy-resources/redmine/easy_contact_spec.rb
|
317
|
+
- spec/models/easy-resources/redmine/issue_spec.rb
|
318
|
+
- spec/models/easy-resources/redmine/redmine_base_spec.rb
|
319
|
+
- spec/models/easy-resources/redmine/easy_web_application_activity_spec.rb
|
320
|
+
- spec/models/easy-resources/redmine/easy_web_application_spec.rb
|
321
|
+
- spec/models/easy-resources/resource_spec.rb
|
322
|
+
- spec/support/active_resource.rb
|
323
|
+
- spec/support/fixtures.rb
|
324
|
+
- spec/support/redmine_active_resource.rb
|
325
|
+
- spec/easy_resources_spec.rb
|
326
|
+
- spec/fixtures/files/easy_contact/show.xml
|
327
|
+
- spec/fixtures/files/easy_crm_case.json
|
328
|
+
- spec/fixtures/files/easy_crm_case/show.xml
|
329
|
+
- spec/fixtures/files/project.json
|
330
|
+
- spec/fixtures/files/issue.json
|
331
|
+
- spec/fixtures/files/project/show.xml
|
332
|
+
- spec/fixtures/files/issue/show.xml
|
333
|
+
- spec/fixtures/files/easy_contact.json
|
334
|
+
- spec/fixtures/files/easy_server/index.xml
|
335
|
+
- spec/fixtures/files/easy_server/show.xml
|
336
|
+
- spec/fixtures/files/easy_web_application/index.xml
|
337
|
+
- spec/fixtures/files/easy_web_application/with_ewaa.xml
|
338
|
+
- spec/fixtures/files/easy_web_application/with_custom_fields.xml
|
339
|
+
- spec/fixtures/files/easy_web_application/show.xml
|
340
|
+
- spec/fixtures/files/easy_web_application/with_easy_contact.xml
|
341
|
+
- spec/fixtures/files/easy_web_application/with_easy_crm_case.xml
|
342
|
+
- spec/fixtures/files/easy_web_application/show.json
|