easy-resources 0.7.4 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/easy/resources.rb +4 -0
- data/lib/easy/resources/redmine/easy_attendance.rb +13 -0
- data/lib/easy/resources/redmine/easy_server.rb +18 -0
- data/lib/easy/resources/redmine/easy_web_application.rb +3 -1
- data/lib/easy/resources/redmine/errors.rb +15 -0
- data/lib/easy/resources/redmine/redmine_base.rb +11 -1
- data/lib/easy/resources/redmine/time_entry.rb +15 -0
- data/lib/easy/resources/version.rb +1 -1
- data/spec/fixtures/files/easy_attendance/show.xml +1 -0
- data/spec/fixtures/files/time_entry/invalid_update.xml +4 -0
- data/spec/fixtures/files/time_entry/show.xml +24 -0
- data/spec/models/easy-resources/redmine/easy_attendance_spec.rb +14 -0
- data/spec/models/easy-resources/redmine/easy_server_spec.rb +16 -0
- data/spec/models/easy-resources/redmine/errors_spec.rb +15 -0
- data/spec/models/easy-resources/redmine/time_entry_spec.rb +14 -0
- data/spec/support/active_resource.rb +2 -2
- data/spec/support/redmine_active_resource.rb +2 -2
- metadata +42 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: baa165cfc453f4d26f80848a0e3e7e62b53c55510865b0354d5bc610f5cd3651
|
4
|
+
data.tar.gz: f7dea1efcddaef350f4180d2752635928b55cc219b3bb653f51295b932841e4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d74958dc95394cca13daed7e5d0e289d15c0d4f62dd766c651c5ee3ab4c66252eda81668f760789bdfe2a5ada66b1575d4d32aa7c7ef68c69b31420ec7e68061
|
7
|
+
data.tar.gz: '07800fff4965abf4b05f312649f9c8d236d5dcc210d6a966435a004e8b09b54b0feb61fc6c3cce9d2f8a8113ae6f1619b768f641251f114717b628f803742f61'
|
data/README.md
CHANGED
data/lib/easy/resources.rb
CHANGED
@@ -9,7 +9,10 @@ module Easy
|
|
9
9
|
module Resources
|
10
10
|
module Redmine
|
11
11
|
|
12
|
+
autoload :Errors, "easy/resources/redmine/errors"
|
13
|
+
|
12
14
|
autoload :RedmineBase, "easy/resources/redmine/redmine_base"
|
15
|
+
autoload :EasyAttendance, "easy/resources/redmine/easy_attendance"
|
13
16
|
autoload :EasyContact, "easy/resources/redmine/easy_contact"
|
14
17
|
autoload :EasyCrmCase, "easy/resources/redmine/easy_crm_case"
|
15
18
|
autoload :EasyServer, "easy/resources/redmine/easy_server"
|
@@ -19,6 +22,7 @@ module Easy
|
|
19
22
|
autoload :Issue, "easy/resources/redmine/issue"
|
20
23
|
autoload :Project, "easy/resources/redmine/project"
|
21
24
|
autoload :User, "easy/resources/redmine/user"
|
25
|
+
autoload :TimeEntry, "easy/resources/redmine/time_entry"
|
22
26
|
|
23
27
|
end
|
24
28
|
end
|
@@ -7,10 +7,28 @@ module Easy
|
|
7
7
|
|
8
8
|
has_many :easy_web_applications, class_name: 'Easy::Resources::Redmine::EasyWebApplication'
|
9
9
|
|
10
|
+
self.schema = {
|
11
|
+
host_name: :string,
|
12
|
+
server_type: :string,
|
13
|
+
server_status: :string
|
14
|
+
}
|
15
|
+
# Alias for +host_name+ attribute
|
16
|
+
# @return [String]
|
10
17
|
def url
|
11
18
|
host_name
|
12
19
|
end
|
13
20
|
|
21
|
+
# Alias for +server_status+ attribute
|
22
|
+
# @return [String]
|
23
|
+
def status
|
24
|
+
server_status
|
25
|
+
end
|
26
|
+
|
27
|
+
# @param [String] name of status
|
28
|
+
def status=(name)
|
29
|
+
self.server_status = name
|
30
|
+
end
|
31
|
+
|
14
32
|
end
|
15
33
|
end
|
16
34
|
end
|
@@ -11,7 +11,9 @@ module Easy
|
|
11
11
|
git_branch: :string,
|
12
12
|
issue_id: :integer,
|
13
13
|
easy_crm_case_id: :integer,
|
14
|
-
easy_contact_id: :integer
|
14
|
+
easy_contact_id: :integer,
|
15
|
+
aasm_event: :string,
|
16
|
+
notes: :string
|
15
17
|
}
|
16
18
|
|
17
19
|
belongs_to :easy_contact, class_name: 'Easy::Resources::Redmine::EasyContact'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Easy
|
2
|
+
module Resources
|
3
|
+
module Redmine
|
4
|
+
class Errors < ::ActiveResource::Errors
|
5
|
+
|
6
|
+
# Redmine in XML responses specify type="array" on Errors
|
7
|
+
# It cause that `Hash.from_xml` already parsed errors as a Array
|
8
|
+
def from_xml(xml, save_cache = false)
|
9
|
+
array = Array.wrap(Hash.from_xml(xml)["errors"]) rescue []
|
10
|
+
from_array array, save_cache
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -26,10 +26,16 @@ module Easy
|
|
26
26
|
h
|
27
27
|
end
|
28
28
|
|
29
|
+
# Parse value of TOTAL amount of entities from headers or response
|
30
|
+
# @return [Integer]
|
31
|
+
def retrieve_total(response)
|
32
|
+
(response['Total'] || response.body[/total_count[:="]+(\d+)/] && $1).to_i
|
33
|
+
end
|
34
|
+
|
29
35
|
def get_all(**params, &block)
|
30
36
|
records = results = all(params: params)
|
31
37
|
response = results.http_response
|
32
|
-
total = response
|
38
|
+
total = retrieve_total(response)
|
33
39
|
current_page = 1
|
34
40
|
|
35
41
|
while records.any?
|
@@ -46,6 +52,10 @@ module Easy
|
|
46
52
|
end
|
47
53
|
|
48
54
|
end
|
55
|
+
|
56
|
+
def errors
|
57
|
+
@errors ||= Errors.new(self)
|
58
|
+
end
|
49
59
|
end
|
50
60
|
end
|
51
61
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Easy
|
2
|
+
module Resources
|
3
|
+
module Redmine
|
4
|
+
class TimeEntry < RedmineBase
|
5
|
+
|
6
|
+
self.element_name = 'time_entry'
|
7
|
+
|
8
|
+
belongs_to :project, class_name: 'Easy::Resources::Redmine::Project'
|
9
|
+
belongs_to :issue, class_name: 'Easy::Resources::Redmine::Issue'
|
10
|
+
belongs_to :user, class_name: 'Easy::Resources::Redmine::User'
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?><easy_attendance><id>509</id><user id="17" name="Steve Helpdesk Dispatcher"/><arrival>2020-02-05T07:45:00+01:00</arrival><departure>2020-04-28T22:30:38+02:00</departure><easy_attendance_activity id="1" name="Office"/><locked>false</locked><arrival_user_ip>66.249.79.144</arrival_user_ip><departure_user_ip></departure_user_ip><range/><created_at>2020-02-05T07:32:19+01:00</created_at><updated_at>2020-02-05T07:32:19+01:00</updated_at><description/><need_approve>false</need_approve><limit_exceeded>false</limit_exceeded><hours>0.0</hours><easy_external_id/></easy_attendance>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<time_entry>
|
3
|
+
<id>509</id>
|
4
|
+
<project id="110" name="Partner Program Implementation"/>
|
5
|
+
<user id="5" name="Manager Manager"/>
|
6
|
+
<activity id="1" name="Work"/>
|
7
|
+
<hours>4.0</hours>
|
8
|
+
<comments></comments>
|
9
|
+
<spent_on>2020-03-04</spent_on>
|
10
|
+
<easy_range_from/>
|
11
|
+
<easy_range_to/>
|
12
|
+
<easy_external_id/>
|
13
|
+
<entity_id>110</entity_id>
|
14
|
+
<entity_type>Project</entity_type>
|
15
|
+
<created_on>2020-03-04T15:03:56Z</created_on>
|
16
|
+
<updated_on>2020-03-04T15:03:56Z</updated_on>
|
17
|
+
<easy_is_billable>true</easy_is_billable>
|
18
|
+
<easy_billed>false</easy_billed>
|
19
|
+
<custom_fields type="array">
|
20
|
+
<custom_field id="105" name="test" internal_name="" field_format="list">
|
21
|
+
<value/>
|
22
|
+
</custom_field>
|
23
|
+
</custom_fields>
|
24
|
+
</time_entry>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
RSpec.describe Easy::Resources::Redmine::EasyAttendance do
|
2
|
+
include_context "redmine active resource shares" do
|
3
|
+
let(:entity_name) { 'easy_attendance' }
|
4
|
+
end
|
5
|
+
|
6
|
+
it 'get' do
|
7
|
+
expect(find_entity.arrival).not_to be_empty
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'has user' do
|
11
|
+
expect(find_entity.user).to be_a Easy::Resources::Redmine::User
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
RSpec.describe Easy::Resources::Redmine::EasyServer do
|
2
|
+
include_context "redmine active resource shares" do
|
3
|
+
let(:entity_name) { 'easy_server' }
|
4
|
+
end
|
5
|
+
|
6
|
+
it "#status" do
|
7
|
+
expect(find_entity.status).to eq "running"
|
8
|
+
end
|
9
|
+
|
10
|
+
it "#status=" do
|
11
|
+
subject = find_entity
|
12
|
+
subject.status = "stopped"
|
13
|
+
expect(subject.server_status).to eq "stopped"
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
RSpec.describe Easy::Resources::Redmine::Errors do
|
2
|
+
include_context "redmine active resource shares" do
|
3
|
+
let(:entity_name) { 'time_entry' }
|
4
|
+
end
|
5
|
+
|
6
|
+
it 'invalid request' do
|
7
|
+
stub_xml source_file: "invalid_update", path: "#{entity_name.pluralize}.xml", method: :post, status: 422, request_body: { hours: 8.0, user_id: 1 }.to_xml(root: "time_entry")
|
8
|
+
|
9
|
+
time_entry = Easy::Resources::Redmine::TimeEntry.new hours: 8.0, user_id: 1
|
10
|
+
expect(time_entry.save).to eq false
|
11
|
+
expect(time_entry.errors).to be_a described_class
|
12
|
+
expect(time_entry.errors.full_messages).to eq ["Projekt je neplatné"]
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
RSpec.describe Easy::Resources::Redmine::TimeEntry do
|
2
|
+
include_context "redmine active resource shares" do
|
3
|
+
let(:entity_name) { 'time_entry' }
|
4
|
+
end
|
5
|
+
|
6
|
+
it 'get' do
|
7
|
+
expect(find_entity.spent_on).not_to be_empty
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'has project' do
|
11
|
+
expect(find_entity.project).to be_a Easy::Resources::Redmine::Project
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -17,13 +17,13 @@ RSpec.shared_context "active resource shares", shared_context: :metadata do
|
|
17
17
|
# @param [Hash] options @see #stub_easy_resource_request
|
18
18
|
def stub_json(**options)
|
19
19
|
options[:format] = "json"
|
20
|
-
stub_resource_request(options)
|
20
|
+
stub_resource_request(**options)
|
21
21
|
end
|
22
22
|
|
23
23
|
# @param [Hash] options @see #stub_easy_resource_request
|
24
24
|
def stub_xml(**options)
|
25
25
|
options[:format] = "xml"
|
26
|
-
stub_resource_request(options)
|
26
|
+
stub_resource_request(**options)
|
27
27
|
end
|
28
28
|
|
29
29
|
# @param [String] format XML or JSON
|
@@ -9,13 +9,13 @@ RSpec.shared_context "redmine active resource shares", shared_context: :metadata
|
|
9
9
|
# @param [Hash] options @see #stub_easy_resource_request
|
10
10
|
def stub_json(**options)
|
11
11
|
options[:format] = "json"
|
12
|
-
stub_easy_resource_request(options)
|
12
|
+
stub_easy_resource_request(**options)
|
13
13
|
end
|
14
14
|
|
15
15
|
# @param [Hash] options @see #stub_easy_resource_request
|
16
16
|
def stub_xml(**options)
|
17
17
|
options[:format] = "xml"
|
18
|
-
stub_easy_resource_request(options)
|
18
|
+
stub_easy_resource_request(**options)
|
19
19
|
end
|
20
20
|
|
21
21
|
def stub_easy_resource_request(format:, path:, **options)
|
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.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- petr
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -135,19 +135,23 @@ files:
|
|
135
135
|
- lib/easy/resource.rb
|
136
136
|
- lib/easy/resources.rb
|
137
137
|
- lib/easy/resources/railtie.rb
|
138
|
+
- lib/easy/resources/redmine/easy_attendance.rb
|
138
139
|
- lib/easy/resources/redmine/easy_contact.rb
|
139
140
|
- lib/easy/resources/redmine/easy_crm_case.rb
|
140
141
|
- lib/easy/resources/redmine/easy_server.rb
|
141
142
|
- lib/easy/resources/redmine/easy_web_application.rb
|
142
143
|
- lib/easy/resources/redmine/easy_web_application_activity.rb
|
143
144
|
- lib/easy/resources/redmine/easy_web_hook.rb
|
145
|
+
- lib/easy/resources/redmine/errors.rb
|
144
146
|
- lib/easy/resources/redmine/issue.rb
|
145
147
|
- lib/easy/resources/redmine/project.rb
|
146
148
|
- lib/easy/resources/redmine/redmine_base.rb
|
149
|
+
- lib/easy/resources/redmine/time_entry.rb
|
147
150
|
- lib/easy/resources/redmine/user.rb
|
148
151
|
- lib/easy/resources/spec_helper.rb
|
149
152
|
- lib/easy/resources/version.rb
|
150
153
|
- spec/easy_resources_spec.rb
|
154
|
+
- spec/fixtures/files/easy_attendance/show.xml
|
151
155
|
- spec/fixtures/files/easy_contact.json
|
152
156
|
- spec/fixtures/files/easy_contact/show.xml
|
153
157
|
- spec/fixtures/files/easy_crm_case.json
|
@@ -165,14 +169,20 @@ files:
|
|
165
169
|
- spec/fixtures/files/issue/show.xml
|
166
170
|
- spec/fixtures/files/project.json
|
167
171
|
- spec/fixtures/files/project/show.xml
|
172
|
+
- spec/fixtures/files/time_entry/invalid_update.xml
|
173
|
+
- spec/fixtures/files/time_entry/show.xml
|
168
174
|
- spec/fixtures/files/user/show.xml
|
175
|
+
- spec/models/easy-resources/redmine/easy_attendance_spec.rb
|
169
176
|
- spec/models/easy-resources/redmine/easy_contact_spec.rb
|
170
177
|
- spec/models/easy-resources/redmine/easy_crm_case_spec.rb
|
178
|
+
- spec/models/easy-resources/redmine/easy_server_spec.rb
|
171
179
|
- spec/models/easy-resources/redmine/easy_web_application_activity_spec.rb
|
172
180
|
- spec/models/easy-resources/redmine/easy_web_application_spec.rb
|
181
|
+
- spec/models/easy-resources/redmine/errors_spec.rb
|
173
182
|
- spec/models/easy-resources/redmine/issue_spec.rb
|
174
183
|
- spec/models/easy-resources/redmine/project_spec.rb
|
175
184
|
- spec/models/easy-resources/redmine/redmine_base_spec.rb
|
185
|
+
- spec/models/easy-resources/redmine/time_entry_spec.rb
|
176
186
|
- spec/models/easy-resources/redmine/user_spec.rb
|
177
187
|
- spec/models/easy-resources/resource_spec.rb
|
178
188
|
- spec/spec_helper.rb
|
@@ -184,7 +194,7 @@ licenses:
|
|
184
194
|
- MIT
|
185
195
|
metadata:
|
186
196
|
allowed_push_host: https://rubygems.org
|
187
|
-
post_install_message:
|
197
|
+
post_install_message:
|
188
198
|
rdoc_options: []
|
189
199
|
require_paths:
|
190
200
|
- lib
|
@@ -199,40 +209,47 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
199
209
|
- !ruby/object:Gem::Version
|
200
210
|
version: '0'
|
201
211
|
requirements: []
|
202
|
-
rubygems_version: 3.0.
|
203
|
-
signing_key:
|
212
|
+
rubygems_version: 3.0.8
|
213
|
+
signing_key:
|
204
214
|
specification_version: 4
|
205
215
|
summary: Summary of Easy::Resources.
|
206
216
|
test_files:
|
207
|
-
- spec/
|
208
|
-
- spec/
|
209
|
-
- spec/support/redmine_active_resource.rb
|
210
|
-
- spec/support/fixtures.rb
|
211
|
-
- spec/models/easy-resources/resource_spec.rb
|
212
|
-
- spec/models/easy-resources/redmine/easy_web_application_spec.rb
|
213
|
-
- spec/models/easy-resources/redmine/user_spec.rb
|
217
|
+
- spec/spec_helper.rb
|
218
|
+
- spec/models/easy-resources/redmine/project_spec.rb
|
214
219
|
- spec/models/easy-resources/redmine/easy_crm_case_spec.rb
|
215
|
-
- spec/models/easy-resources/redmine/redmine_base_spec.rb
|
216
220
|
- spec/models/easy-resources/redmine/easy_contact_spec.rb
|
217
221
|
- spec/models/easy-resources/redmine/issue_spec.rb
|
222
|
+
- spec/models/easy-resources/redmine/time_entry_spec.rb
|
223
|
+
- spec/models/easy-resources/redmine/redmine_base_spec.rb
|
218
224
|
- spec/models/easy-resources/redmine/easy_web_application_activity_spec.rb
|
219
|
-
- spec/models/easy-resources/redmine/
|
220
|
-
- spec/
|
221
|
-
- spec/
|
222
|
-
- spec/
|
223
|
-
- spec/
|
225
|
+
- spec/models/easy-resources/redmine/easy_web_application_spec.rb
|
226
|
+
- spec/models/easy-resources/redmine/easy_server_spec.rb
|
227
|
+
- spec/models/easy-resources/redmine/errors_spec.rb
|
228
|
+
- spec/models/easy-resources/redmine/user_spec.rb
|
229
|
+
- spec/models/easy-resources/redmine/easy_attendance_spec.rb
|
230
|
+
- spec/models/easy-resources/resource_spec.rb
|
231
|
+
- spec/support/active_resource.rb
|
232
|
+
- spec/support/fixtures.rb
|
233
|
+
- spec/support/redmine_active_resource.rb
|
234
|
+
- spec/easy_resources_spec.rb
|
224
235
|
- spec/fixtures/files/easy_contact/show.xml
|
225
|
-
- spec/fixtures/files/
|
236
|
+
- spec/fixtures/files/time_entry/show.xml
|
237
|
+
- spec/fixtures/files/time_entry/invalid_update.xml
|
226
238
|
- spec/fixtures/files/easy_crm_case.json
|
239
|
+
- spec/fixtures/files/easy_crm_case/show.xml
|
240
|
+
- spec/fixtures/files/project.json
|
227
241
|
- spec/fixtures/files/issue.json
|
228
242
|
- spec/fixtures/files/user/show.xml
|
243
|
+
- spec/fixtures/files/project/show.xml
|
244
|
+
- spec/fixtures/files/issue/show.xml
|
229
245
|
- spec/fixtures/files/easy_contact.json
|
246
|
+
- spec/fixtures/files/easy_server/index.xml
|
247
|
+
- spec/fixtures/files/easy_server/show.xml
|
248
|
+
- spec/fixtures/files/easy_attendance/show.xml
|
249
|
+
- spec/fixtures/files/easy_web_application/index.xml
|
230
250
|
- spec/fixtures/files/easy_web_application/with_ewaa.xml
|
251
|
+
- spec/fixtures/files/easy_web_application/with_custom_fields.xml
|
231
252
|
- spec/fixtures/files/easy_web_application/show.xml
|
232
253
|
- spec/fixtures/files/easy_web_application/with_easy_contact.xml
|
233
|
-
- spec/fixtures/files/easy_web_application/with_custom_fields.xml
|
234
|
-
- spec/fixtures/files/easy_web_application/index.xml
|
235
|
-
- spec/fixtures/files/easy_web_application/show.json
|
236
254
|
- spec/fixtures/files/easy_web_application/with_easy_crm_case.xml
|
237
|
-
- spec/fixtures/files/
|
238
|
-
- spec/spec_helper.rb
|
255
|
+
- spec/fixtures/files/easy_web_application/show.json
|