easy-resources 0.8.0 → 0.9.1

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 (50) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +64 -0
  3. data/lib/easy/resource.rb +10 -7
  4. data/lib/easy/resources/redmine/custom_field.rb +36 -0
  5. data/lib/easy/resources/redmine/easy_attendance.rb +0 -1
  6. data/lib/easy/resources/redmine/easy_contact.rb +0 -1
  7. data/lib/easy/resources/redmine/easy_crm_case.rb +0 -1
  8. data/lib/easy/resources/redmine/easy_server.rb +1 -1
  9. data/lib/easy/resources/redmine/easy_web_application.rb +19 -2
  10. data/lib/easy/resources/redmine/easy_web_application_activity.rb +0 -1
  11. data/lib/easy/resources/redmine/easy_web_hook.rb +0 -1
  12. data/lib/easy/resources/redmine/errors.rb +20 -0
  13. data/lib/easy/resources/redmine/issue.rb +0 -1
  14. data/lib/easy/resources/redmine/project.rb +0 -1
  15. data/lib/easy/resources/redmine/redmine_base.rb +13 -3
  16. data/lib/easy/resources/redmine/time_entry.rb +0 -1
  17. data/lib/easy/resources/redmine/user.rb +0 -1
  18. data/lib/easy/resources/spec_helper.rb +2 -2
  19. data/lib/easy/resources/version.rb +3 -1
  20. data/lib/easy/resources.rb +5 -0
  21. data/spec/easy_resources_spec.rb +0 -3
  22. data/spec/fixtures/files/custom_field/bool.xml +4 -0
  23. data/spec/fixtures/files/custom_field/date.xml +4 -0
  24. data/spec/fixtures/files/custom_field/datetime.xml +5 -0
  25. data/spec/fixtures/files/custom_field/float.xml +4 -0
  26. data/spec/fixtures/files/custom_field/int.xml +4 -0
  27. data/spec/fixtures/files/custom_field/string.xml +4 -0
  28. data/spec/fixtures/files/easy_web_application/show.xml +8 -0
  29. data/spec/fixtures/files/easy_web_hook/index.xml +26 -0
  30. data/spec/fixtures/files/easy_web_hook/show.xml +11 -0
  31. data/spec/fixtures/files/time_entry/invalid_update.xml +4 -0
  32. data/spec/models/easy-resources/redmine/custom_field_spec.rb +31 -0
  33. data/spec/models/easy-resources/redmine/easy_attendance_spec.rb +0 -1
  34. data/spec/models/easy-resources/redmine/easy_contact_spec.rb +0 -1
  35. data/spec/models/easy-resources/redmine/easy_crm_case_spec.rb +0 -2
  36. data/spec/models/easy-resources/redmine/easy_server_spec.rb +0 -1
  37. data/spec/models/easy-resources/redmine/easy_web_application_activity_spec.rb +0 -1
  38. data/spec/models/easy-resources/redmine/easy_web_application_spec.rb +14 -2
  39. data/spec/models/easy-resources/redmine/easy_web_hook_spec.rb +9 -0
  40. data/spec/models/easy-resources/redmine/errors_spec.rb +14 -0
  41. data/spec/models/easy-resources/redmine/issue_spec.rb +0 -2
  42. data/spec/models/easy-resources/redmine/project_spec.rb +0 -2
  43. data/spec/models/easy-resources/redmine/redmine_base_spec.rb +0 -2
  44. data/spec/models/easy-resources/redmine/time_entry_spec.rb +0 -1
  45. data/spec/models/easy-resources/redmine/user_spec.rb +0 -2
  46. data/spec/models/easy-resources/resource_spec.rb +2 -2
  47. data/spec/spec_helper.rb +4 -4
  48. data/spec/support/active_resource.rb +3 -3
  49. data/spec/support/redmine_active_resource.rb +3 -3
  50. metadata +79 -35
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3848905fec923b2461ca35dab3f43d13f9e690c36a43dafe03e0cfa37ab39775
4
- data.tar.gz: db2a4779b7c4774ee382e21cc79366f510f4af2c4cb23caec61c9f70748ae200
3
+ metadata.gz: f316fd1fcb39517044518b60cfb7253f9b93f91fb297311efb5cf6cb0722e9ed
4
+ data.tar.gz: 8740c5ef4d6501f79440fff6f4d76b4657be60441d6be95c4abe4ae82340b82f
5
5
  SHA512:
6
- metadata.gz: 3b613b8e5910f904790aeee7bdce6bfb2245e46ccc7a9f07ff98c534f93b1c42b22dbfb37a8bfabcb0b0204f64d4edcc26572b7d13ad82cc332ee6aaa57f4ba1
7
- data.tar.gz: 42e293bf5b410c0b2b7917bb3c2311a34e030c6a791f6268d776b2f1dfb430fcf17cea2385d53b9497541656aa3163da3a9c5e0da7a6ec8f2af262a43117e5ed
6
+ metadata.gz: f2e146b48259157762bfd9d2151bb8cce5b330e6fce9e1fd8c75f353aaa01c3068492c079e57623504acc28b485f08fbb5782932277ed0e3db045c5c4e84366b
7
+ data.tar.gz: 4a3b27c1c1ef0ed61ff62b159613fea8609cdc2fbdbd978b1aea2c87822ef5fb7e68a0c1d065bf559f3737d83a21bc99dfb91996845f5e2809d28e561d5ac5da
data/CHANGELOG.md ADDED
@@ -0,0 +1,64 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+ ## [0.9.1] - 2021-08-24
9
+ ### Fixed
10
+ - adjusted EWA schema
11
+
12
+ ## [0.9.0] - 2021-06-08
13
+ ### Added
14
+ - CustomField resource
15
+ - rubocop linter
16
+ - improve gemspec metadata
17
+ ### Changed
18
+ - dummy upgrade to rails 6
19
+ - update dev dependencies
20
+
21
+ ## [0.8.2] - 2021-03-05
22
+ ### Added
23
+ - ruby 3 compatibility
24
+
25
+ ## [0.8.1] - 2020-06-08
26
+ ### Fixed
27
+ - Retrieve (Easy)Redmine total entities from response if headers missing
28
+ - Validation error messages parser from XML
29
+
30
+ ## [0.8.0] - 2020-04-28
31
+ ### Added
32
+ - TimeEntry
33
+ - EasyAttendance
34
+ ## [0.7.5] - 2020-03-06
35
+ ### Added
36
+ - EasyServer `status` alias for `server_status`
37
+ ## [0.7.5] - 2020-01-17
38
+ ### Added
39
+ - aasm_event into EasyWebApplication scheme
40
+ - notes into EasyWebApplication scheme
41
+ ## [0.7.4] - 2019-09-02
42
+ ### Added
43
+ - Easy Web Application add belongs_to Issue
44
+ ## [0.7.2] - 2019-08-29
45
+ ### Added
46
+ - Easy Web Hook model
47
+ ## [0.7.1] - 2019-07-11
48
+ ### Added
49
+ - configuration from Oauth2 token
50
+ ### Fixed
51
+ - api_key is changed to class_attribute
52
+ ## [0.6.3] - 2019-07-08
53
+ ### Fixed
54
+ - cached headers
55
+ ## [0.6.2] - 2019-05-14
56
+ ### Added
57
+ - alias url in server resource
58
+ ## [0.6.1] - 2019-04-03
59
+ ### Added
60
+ - this file
61
+ - User resource in Redmine
62
+ - 100% code coverage :)
63
+ ### Changed
64
+ - README
data/lib/easy/resource.rb CHANGED
@@ -2,26 +2,29 @@ module Easy
2
2
  class Resource < ActiveResource::Base
3
3
 
4
4
  def self.configure(conf)
5
- if conf.is_a?(::Hash)
5
+ case conf
6
+ when ::Hash
6
7
  if conf[:url].present? && conf[:token].present?
7
8
  configure_bearer(conf[:url], conf[:token])
8
9
  elsif conf[:url].present?
9
10
  self.site = conf[:url]
10
11
  end
11
- elsif conf.is_a?(::OAuth2::AccessToken)
12
+ when ::OAuth2::AccessToken
12
13
  configure_bearer(conf.client.site, conf.token)
14
+ else
15
+ # do nothing, unknown configuration
13
16
  end
14
17
  end
15
18
 
16
19
  def self.configure_bearer(url, token)
17
- self.site = url
18
- self.connection.auth_type = :bearer
19
- self.connection.bearer_token = token
20
+ self.site = url
21
+ connection.auth_type = :bearer
22
+ connection.bearer_token = token
20
23
  end
21
24
 
22
25
  def becomes(entity_class)
23
- model = entity_class.new
24
- model.attributes = self.attributes
26
+ model = entity_class.new
27
+ model.attributes = attributes
25
28
  model
26
29
  end
27
30
 
@@ -0,0 +1,36 @@
1
+ module Easy
2
+ module Resources
3
+ module Redmine
4
+ class CustomField < RedmineBase
5
+ self.element_name = 'custom_field'
6
+
7
+ self.schema = {
8
+ id: :integer,
9
+ name: :string,
10
+ internal_name: :string,
11
+ value: :string,
12
+ field_format: :string,
13
+ }
14
+
15
+ # @return formatted value based on **field_format**
16
+ def cast_value
17
+ case field_format
18
+ when "bool"
19
+ value.to_s =~ /1|true/i ? true : false
20
+ when "float", "amount"
21
+ value.to_f
22
+ when "int"
23
+ value.to_i
24
+ when "date"
25
+ Date.parse value
26
+ when "datetime"
27
+ DateTime.parse value
28
+ else
29
+ value
30
+ end
31
+ end
32
+
33
+ end
34
+ end
35
+ end
36
+ end
@@ -2,7 +2,6 @@ module Easy
2
2
  module Resources
3
3
  module Redmine
4
4
  class EasyAttendance < RedmineBase
5
-
6
5
  self.element_name = 'easy_attendance'
7
6
 
8
7
  belongs_to :user, class_name: 'Easy::Resources::Redmine::User'
@@ -2,7 +2,6 @@ module Easy
2
2
  module Resources
3
3
  module Redmine
4
4
  class EasyContact < RedmineBase
5
-
6
5
  self.element_name = 'easy_contact'
7
6
 
8
7
  def name
@@ -2,7 +2,6 @@ module Easy
2
2
  module Resources
3
3
  module Redmine
4
4
  class EasyCrmCase < RedmineBase
5
-
6
5
  self.element_name = 'easy_crm_case'
7
6
 
8
7
  belongs_to :project, class_name: 'Easy::Resources::Redmine::Project'
@@ -2,7 +2,6 @@ module Easy
2
2
  module Resources
3
3
  module Redmine
4
4
  class EasyServer < RedmineBase
5
-
6
5
  self.element_name = 'easy_server'
7
6
 
8
7
  has_many :easy_web_applications, class_name: 'Easy::Resources::Redmine::EasyWebApplication'
@@ -12,6 +11,7 @@ module Easy
12
11
  server_type: :string,
13
12
  server_status: :string
14
13
  }
14
+
15
15
  # Alias for +host_name+ attribute
16
16
  # @return [String]
17
17
  def url
@@ -2,18 +2,22 @@ module Easy
2
2
  module Resources
3
3
  module Redmine
4
4
  class EasyWebApplication < RedmineBase
5
-
6
5
  self.element_name = 'easy_web_application'
7
6
 
8
7
  self.schema = {
9
8
  url: :string,
10
9
  git_repository: :string,
11
10
  git_branch: :string,
11
+ db_url: :string,
12
+ files_url: :string,
12
13
  issue_id: :integer,
13
14
  easy_crm_case_id: :integer,
14
15
  easy_contact_id: :integer,
15
16
  aasm_event: :string,
16
- notes: :string
17
+ notes: :string,
18
+ expire_at: :date,
19
+ custom_repository: :boolean,
20
+ custom_domain: :boolean,
17
21
  }
18
22
 
19
23
  belongs_to :easy_contact, class_name: 'Easy::Resources::Redmine::EasyContact'
@@ -21,6 +25,7 @@ module Easy
21
25
  belongs_to :easy_server, class_name: 'Easy::Resources::Redmine::EasyServer'
22
26
  belongs_to :issue, class_name: 'Easy::Resources::Redmine::Issue'
23
27
 
28
+ has_many :custom_fields, class_name: 'Easy::Resources::Redmine::CustomField'
24
29
  has_many :easy_web_application_activities, class_name: 'Easy::Resources::Redmine::EasyWebApplicationActivity'
25
30
  has_one :easy_web_application_activity, class_name: 'Easy::Resources::Redmine::EasyWebApplicationActivity'
26
31
 
@@ -28,6 +33,18 @@ module Easy
28
33
  url
29
34
  end
30
35
 
36
+ # @!group ESko specific custom_fields
37
+
38
+ # @return [Boolean,nil]
39
+ def application_moves_on_request?
40
+ custom_fields.find { |cf| cf.internal_name == "application_move_on_request" }&.cast_value
41
+ end
42
+
43
+ # @return [Boolean,nil]
44
+ def application_updates_on_request?
45
+ custom_fields.find { |cf| cf.internal_name == "application_updates_on_request" }&.cast_value
46
+ end
47
+
31
48
  end
32
49
  end
33
50
  end
@@ -2,7 +2,6 @@ module Easy
2
2
  module Resources
3
3
  module Redmine
4
4
  class EasyWebApplicationActivity < RedmineBase
5
-
6
5
  self.element_name = 'easy_web_application_activity'
7
6
 
8
7
  belongs_to :easy_web_application, class_name: 'Easy::Resources::Redmine::EasyWebApplication'
@@ -2,7 +2,6 @@ module Easy
2
2
  module Resources
3
3
  module Redmine
4
4
  class EasyWebHook < RedmineBase
5
-
6
5
  self.element_name = 'easy_web_hook'
7
6
 
8
7
  end
@@ -0,0 +1,20 @@
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 = begin
10
+ Array.wrap(Hash.from_xml(xml)["errors"])
11
+ rescue StandardError
12
+ []
13
+ end
14
+ from_array array, save_cache
15
+ end
16
+
17
+ end
18
+ end
19
+ end
20
+ end
@@ -2,7 +2,6 @@ module Easy
2
2
  module Resources
3
3
  module Redmine
4
4
  class Issue < RedmineBase
5
-
6
5
  self.element_name = 'issue'
7
6
 
8
7
  belongs_to :project, class_name: 'Easy::Resources::Redmine::Project'
@@ -2,7 +2,6 @@ module Easy
2
2
  module Resources
3
3
  module Redmine
4
4
  class Project < RedmineBase
5
-
6
5
  self.element_name = 'project'
7
6
 
8
7
  end
@@ -2,10 +2,9 @@ module Easy
2
2
  module Resources
3
3
  module Redmine
4
4
  class RedmineBase < ::Easy::Resource
5
-
6
5
  self.include_root_in_json = true
7
6
  self.format = :xml
8
- self.add_response_method :http_response
7
+ add_response_method :http_response
9
8
 
10
9
  class_attribute :api_key
11
10
 
@@ -26,10 +25,16 @@ module Easy
26
25
  h
27
26
  end
28
27
 
28
+ # Parse value of TOTAL amount of entities from headers or response
29
+ # @return [Integer]
30
+ def retrieve_total(response)
31
+ (response['Total'] || response.body[/total_count[:="]+(\d+)/] && Regexp.last_match(1)).to_i
32
+ end
33
+
29
34
  def get_all(**params, &block)
30
35
  records = results = all(params: params)
31
36
  response = results.http_response
32
- total = response['Total'].to_i
37
+ total = retrieve_total(response)
33
38
  current_page = 1
34
39
 
35
40
  while records.any?
@@ -46,6 +51,11 @@ module Easy
46
51
  end
47
52
 
48
53
  end
54
+
55
+ def errors
56
+ @errors ||= Errors.new(self)
57
+ end
58
+
49
59
  end
50
60
  end
51
61
  end
@@ -2,7 +2,6 @@ module Easy
2
2
  module Resources
3
3
  module Redmine
4
4
  class TimeEntry < RedmineBase
5
-
6
5
  self.element_name = 'time_entry'
7
6
 
8
7
  belongs_to :project, class_name: 'Easy::Resources::Redmine::Project'
@@ -2,7 +2,6 @@ module Easy
2
2
  module Resources
3
3
  module Redmine
4
4
  class User < RedmineBase
5
-
6
5
  self.element_name = 'user'
7
6
 
8
7
  def name
@@ -1,2 +1,2 @@
1
- x = File.expand_path('../../../../', __FILE__)
2
- Dir["#{x}/spec/support/**/*.rb"].sort.each { |f| require f }
1
+ gem_dir = File.expand_path('../../..', __dir__)
2
+ Dir["#{gem_dir}/spec/support/**/*.rb"].sort.each { |f| require f }
@@ -1,5 +1,7 @@
1
1
  module Easy
2
2
  module Resources
3
- VERSION = '0.8.0'
3
+
4
+ VERSION = '0.9.1'
5
+
4
6
  end
5
7
  end
@@ -4,11 +4,15 @@ require "activeresource-response"
4
4
  require "easy/resources/railtie"
5
5
 
6
6
  module Easy
7
+
7
8
  autoload :Resource, "easy/resource"
8
9
 
9
10
  module Resources
10
11
  module Redmine
11
12
 
13
+ autoload :Errors, "easy/resources/redmine/errors"
14
+
15
+ autoload :CustomField, "easy/resources/redmine/custom_field"
12
16
  autoload :RedmineBase, "easy/resources/redmine/redmine_base"
13
17
  autoload :EasyAttendance, "easy/resources/redmine/easy_attendance"
14
18
  autoload :EasyContact, "easy/resources/redmine/easy_contact"
@@ -24,4 +28,5 @@ module Easy
24
28
 
25
29
  end
26
30
  end
31
+
27
32
  end
@@ -6,7 +6,6 @@ RSpec.describe Easy::Resources do
6
6
  end
7
7
 
8
8
  describe '.configure' do
9
-
10
9
  context "Easy::Resources::Redmine::RedmineBase" do
11
10
  it "Easy::Resources::Redmine::RedmineBase" do
12
11
  expect(Easy::Resources::Redmine::RedmineBase).to receive(:api_key=).with("xx1")
@@ -14,7 +13,5 @@ RSpec.describe Easy::Resources do
14
13
  Easy::Resources::Redmine::RedmineBase.configure api_key: "xx1", url: "https://test.dummy"
15
14
  end
16
15
  end
17
-
18
16
  end
19
-
20
17
  end
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <custom_field id="1" name="Move on-request" internal_name="application_move_on_request" field_format="bool">
3
+ <value>1</value>
4
+ </custom_field>
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <custom_field id="1" name="Next action" field_format="date">
3
+ <value>2020-06-24</value>
4
+ </custom_field>
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <custom_field id="1" name="Next action" field_format="datetime">
3
+ <value>2020-06-24 22:00:00</value>
4
+ <local_datetime>2020-06-25T00:00:00+02:00</local_datetime>
5
+ </custom_field>
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <custom_field id="1" name="Next action" field_format="float">
3
+ <value>24</value>
4
+ </custom_field>
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <custom_field id="1" name="Next action" field_format="int">
3
+ <value></value>
4
+ </custom_field>
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <custom_field id="1" name="Next action" field_format="text">
3
+ <value>word</value>
4
+ </custom_field>
@@ -11,6 +11,14 @@
11
11
  <author id="14" name="Anonymní"/>
12
12
  <internal_user_limit>0</internal_user_limit>
13
13
  <git_repository type="string">git@git.easy.cz:package.git</git_repository>
14
+ <custom_fields type="array">
15
+ <custom_field id="695" name="Move on-request" internal_name="application_move_on_request" field_format="bool">
16
+ <value>1</value>
17
+ </custom_field>
18
+ <custom_field id="463" name="Updates on-request" internal_name="application_updates_on_request" field_format="bool">
19
+ <value>0</value>
20
+ </custom_field>
21
+ </custom_fields>
14
22
  <created_at>2018-03-22T09:10:47Z</created_at>
15
23
  <updated_at>2018-05-24T10:55:28Z</updated_at>
16
24
  </easy_web_application>
@@ -0,0 +1,26 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <easy_web_hooks total_count="12" offset="0" limit="25" type="array">
3
+ <easy_web_hook>
4
+ <id>1</id>
5
+ <url>https://hooks.integromat.com/super-secret-hash</url>
6
+ <status>inactive</status>
7
+ <entity_type>Issue</entity_type>
8
+ <action>create</action>
9
+ <author id="1" name="Manager"/>
10
+ <api_includes>[]</api_includes>
11
+ <created_at>2017-08-18T11:56:53Z</created_at>
12
+ <updated_at>2019-08-29T07:44:16Z</updated_at>
13
+ </easy_web_hook>
14
+ <easy_web_hook>
15
+ <id>3</id>
16
+ <url>https://hooks.zapier.com/hooks/catch/hookID/hookSecret/</url>
17
+ <status>inactive</status>
18
+ <entity_type>Project</entity_type>
19
+ <action>destroy</action>
20
+ <author id="5" name="Admin"/>
21
+ <project id="7" name="Reporting"/>
22
+ <api_includes>[issue_categories]</api_includes>
23
+ <created_at>2019-06-19T11:41:22Z</created_at>
24
+ <updated_at>2019-06-19T11:41:22Z</updated_at>
25
+ </easy_web_hook>
26
+ </easy_web_hooks>
@@ -0,0 +1,11 @@
1
+ <easy_web_hook>
2
+ <id>1</id>
3
+ <url>https://hooks.integromat.com/super-secret-hash</url>
4
+ <status>inactive</status>
5
+ <entity_type>Issue</entity_type>
6
+ <action>create</action>
7
+ <author id="1" name="Manager"/>
8
+ <api_includes>[]</api_includes>
9
+ <created_at>2017-08-18T11:56:53Z</created_at>
10
+ <updated_at>2019-08-29T07:44:16Z</updated_at>
11
+ </easy_web_hook>
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <errors type="array">
3
+ <error>Projekt je neplatné</error>
4
+ </errors>
@@ -0,0 +1,31 @@
1
+ RSpec.describe Easy::Resources::Redmine::CustomField do
2
+ include_context "redmine active resource shares" do
3
+ let(:entity_name) { 'custom_field' }
4
+ end
5
+
6
+ let(:entity) { find_entity }
7
+
8
+ describe "#cast_value" do
9
+ subject { entity.cast_value }
10
+ context "with datetime" do
11
+ let(:entity) { find_entity "datetime" }
12
+ it { is_expected.to be_a DateTime }
13
+ end
14
+ context "with date" do
15
+ let(:entity) { find_entity "date" }
16
+ it { is_expected.to be_a Date }
17
+ end
18
+ context "with int" do
19
+ let(:entity) { find_entity "int" }
20
+ it { is_expected.to eq 0 }
21
+ end
22
+ context "with float" do
23
+ let(:entity) { find_entity "float" }
24
+ it { is_expected.to eq 24.0 }
25
+ end
26
+ context "with text" do
27
+ let(:entity) { find_entity "string" }
28
+ it { is_expected.not_to be_blank }
29
+ end
30
+ end
31
+ end
@@ -10,5 +10,4 @@ RSpec.describe Easy::Resources::Redmine::EasyAttendance do
10
10
  it 'has user' do
11
11
  expect(find_entity.user).to be_a Easy::Resources::Redmine::User
12
12
  end
13
-
14
13
  end
@@ -22,5 +22,4 @@ RSpec.describe Easy::Resources::Redmine::EasyContact do
22
22
  # it '#demo?' do
23
23
  # expect(find_entity.demo?).to be_falsey
24
24
  # end
25
-
26
25
  end
@@ -3,7 +3,6 @@ RSpec.describe Easy::Resources::Redmine::EasyCrmCase do
3
3
  let(:entity_name) { 'easy_crm_case' }
4
4
  end
5
5
 
6
-
7
6
  it 'get crm case' do
8
7
  expect(find_entity.name).not_to be_empty
9
8
  end
@@ -15,5 +14,4 @@ RSpec.describe Easy::Resources::Redmine::EasyCrmCase do
15
14
  it 'crm case has customer' do
16
15
  expect(find_entity.customer).to be_a Easy::Resources::Redmine::EasyContact
17
16
  end
18
-
19
17
  end
@@ -12,5 +12,4 @@ RSpec.describe Easy::Resources::Redmine::EasyServer do
12
12
  subject.status = "stopped"
13
13
  expect(subject.server_status).to eq "stopped"
14
14
  end
15
-
16
15
  end
@@ -2,5 +2,4 @@ RSpec.describe Easy::Resources::Redmine::EasyWebApplicationActivity do
2
2
  include_context "redmine active resource shares" do
3
3
  let(:entity_name) { 'easy_web_application_activity' }
4
4
  end
5
-
6
5
  end
@@ -16,7 +16,7 @@ RSpec.describe Easy::Resources::Redmine::EasyWebApplication do
16
16
  end
17
17
 
18
18
  it 'get ewa' do
19
- expect(find_entity.attributes).to include *%w[id url git_repository version application_type created_at]
19
+ expect(find_entity.attributes).to include(*%w[id url git_repository version application_type created_at])
20
20
  expect(find_entity.git_branch).to be_nil
21
21
  expect(find_entity.name).not_to be_empty
22
22
  end
@@ -29,7 +29,6 @@ RSpec.describe Easy::Resources::Redmine::EasyWebApplication do
29
29
  include_examples "optional reference", :easy_contact
30
30
 
31
31
  describe ".get_all" do
32
-
33
32
  it "with block" do
34
33
  stub_xml(path: "easy_web_applications.xml", source_file: "index", response_headers: { 'Total' => '4' })
35
34
  stub_xml(path: "easy_web_applications.xml?page=2", source_file: "index")
@@ -53,7 +52,20 @@ RSpec.describe Easy::Resources::Redmine::EasyWebApplication do
53
52
  subject.easy_web_application_activities_attributes = { activities_count_in_day: 13 }
54
53
  subject.save
55
54
  end
55
+ end
56
56
 
57
+ describe "application_moves_on_request?" do
58
+ subject { find_entity.application_moves_on_request? }
59
+ it "should be true" do
60
+ is_expected.to be_truthy
61
+ end
57
62
  end
58
63
 
64
+ describe "application_updates_on_request?" do
65
+ subject { find_entity.application_updates_on_request? }
66
+ it "should be false" do
67
+ is_expected.to be_falsey
68
+ end
69
+ end
70
+
59
71
  end
@@ -0,0 +1,9 @@
1
+ RSpec.describe Easy::Resources::Redmine::EasyWebHook do
2
+ include_context "redmine active resource shares" do
3
+ let(:entity_name) { 'easy_web_hook' }
4
+ end
5
+
6
+ it "#status" do
7
+ expect(find_entity.status).to eq "inactive"
8
+ end
9
+ end
@@ -0,0 +1,14 @@
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
+ end
@@ -3,7 +3,6 @@ RSpec.describe Easy::Resources::Redmine::Issue do
3
3
  let(:entity_name) { 'issue' }
4
4
  end
5
5
 
6
-
7
6
  it 'get issue' do
8
7
  expect(find_entity.subject).not_to be_empty
9
8
  end
@@ -11,5 +10,4 @@ RSpec.describe Easy::Resources::Redmine::Issue do
11
10
  it 'issue has project' do
12
11
  expect(find_entity.project).to be_a Easy::Resources::Redmine::Project
13
12
  end
14
-
15
13
  end
@@ -3,9 +3,7 @@ RSpec.describe Easy::Resources::Redmine::Project do
3
3
  let(:entity_name) { 'project' }
4
4
  end
5
5
 
6
-
7
6
  it 'get project' do
8
7
  expect(find_entity.name).not_to be_empty
9
8
  end
10
-
11
9
  end
@@ -1,5 +1,4 @@
1
1
  RSpec.describe Easy::Resources::Redmine::RedmineBase do
2
-
3
2
  it 'no configuration specify' do
4
3
  described_class.site = nil
5
4
  described_class.api_key = nil
@@ -15,5 +14,4 @@ RSpec.describe Easy::Resources::Redmine::RedmineBase do
15
14
  expect(described_class.headers).to include "X-Redmine-API-Key" => "xxxx"
16
15
  end
17
16
  end
18
-
19
17
  end
@@ -10,5 +10,4 @@ RSpec.describe Easy::Resources::Redmine::TimeEntry do
10
10
  it 'has project' do
11
11
  expect(find_entity.project).to be_a Easy::Resources::Redmine::Project
12
12
  end
13
-
14
13
  end
@@ -3,7 +3,6 @@ RSpec.describe Easy::Resources::Redmine::User do
3
3
  let(:entity_name) { 'user' }
4
4
  end
5
5
 
6
-
7
6
  it 'get user' do
8
7
  expect(find_entity.mail).not_to be_empty
9
8
  end
@@ -15,5 +14,4 @@ RSpec.describe Easy::Resources::Redmine::User do
15
14
  # it 'issue has project' do
16
15
  # expect(find_entity.project).to be_a Easy::Resources::Redmine::Project
17
16
  # end
18
-
19
17
  end
@@ -1,6 +1,7 @@
1
1
  class DummyResource < Easy::Resource
2
2
  self.site = "easyredmine.com"
3
3
  self.format = :json
4
+
4
5
  end
5
6
  RSpec.describe Easy::Resource do
6
7
  subject { DummyResource.new({ id: 1 }, true) }
@@ -22,7 +23,6 @@ RSpec.describe Easy::Resource do
22
23
  expect(subject).to receive(:patch).with nil, {}, value.to_xml(root: "dummy-resource")
23
24
  subject.update_column :att, 1
24
25
  end
25
-
26
26
  end
27
27
 
28
28
  describe "#patch" do
@@ -39,4 +39,4 @@ RSpec.describe Easy::Resource do
39
39
  subject.patch "deployed"
40
40
  end
41
41
  end
42
- end
42
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,8 +1,10 @@
1
1
  ENV["RAILS_ENV"] = "test"
2
2
  require "simplecov"
3
3
  SimpleCov.start 'rails' do
4
- add_filter 'lib/easy/resources/spec_helper'
5
- add_filter 'lib/easy/resources/version'
4
+ add_filter '/bin'
5
+ add_filter '/lib/easy/resources/spec_helper'
6
+ add_filter '/lib/easy/resources/version'
7
+ add_filter '/vendor'
6
8
  end
7
9
 
8
10
  require "bundler/setup"
@@ -16,7 +18,6 @@ require "active_resource_response/http_mock"
16
18
  Dir["./spec/support/**/*.rb"].sort.each { |f| require f }
17
19
 
18
20
  RSpec.configure do |config|
19
-
20
21
  # Disable RSpec exposing methods globally on `Module` and `main`
21
22
  config.disable_monkey_patching!
22
23
 
@@ -24,4 +25,3 @@ RSpec.configure do |config|
24
25
  c.syntax = :expect
25
26
  end
26
27
  end
27
-
@@ -2,7 +2,7 @@ RSpec.shared_context "active resource shares", shared_context: :metadata do
2
2
  let(:site) { 'https://test.dummy' }
3
3
  let(:api_key) { 'secret' }
4
4
 
5
- let(:entity_name) {}
5
+ let(:entity_name) { "" }
6
6
 
7
7
  before(:each) do
8
8
  ActiveResource::HttpMock.reset!
@@ -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)
@@ -25,4 +25,4 @@ RSpec.shared_context "redmine active resource shares", shared_context: :metadata
25
25
  options[:path] = path
26
26
  stub_resource_request options
27
27
  end
28
- end
28
+ end
metadata CHANGED
@@ -1,57 +1,58 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy-resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
- - petr
8
- autorequire:
7
+ - Petr
8
+ - Lukáš
9
+ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2020-04-29 00:00:00.000000000 Z
12
+ date: 2021-08-24 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
- name: railties
15
+ name: activeresource
15
16
  requirement: !ruby/object:Gem::Requirement
16
17
  requirements:
17
- - - ">="
18
+ - - "~>"
18
19
  - !ruby/object:Gem::Version
19
- version: '0'
20
+ version: '5.1'
20
21
  type: :runtime
21
22
  prerelease: false
22
23
  version_requirements: !ruby/object:Gem::Requirement
23
24
  requirements:
24
- - - ">="
25
+ - - "~>"
25
26
  - !ruby/object:Gem::Version
26
- version: '0'
27
+ version: '5.1'
27
28
  - !ruby/object:Gem::Dependency
28
- name: activeresource
29
+ name: activeresource-response
29
30
  requirement: !ruby/object:Gem::Requirement
30
31
  requirements:
31
32
  - - "~>"
32
33
  - !ruby/object:Gem::Version
33
- version: '5.0'
34
+ version: '1.2'
34
35
  type: :runtime
35
36
  prerelease: false
36
37
  version_requirements: !ruby/object:Gem::Requirement
37
38
  requirements:
38
39
  - - "~>"
39
40
  - !ruby/object:Gem::Version
40
- version: '5.0'
41
+ version: '1.2'
41
42
  - !ruby/object:Gem::Dependency
42
- name: activeresource-response
43
+ name: railties
43
44
  requirement: !ruby/object:Gem::Requirement
44
45
  requirements:
45
- - - "~>"
46
+ - - ">="
46
47
  - !ruby/object:Gem::Version
47
- version: '1.2'
48
+ version: '0'
48
49
  type: :runtime
49
50
  prerelease: false
50
51
  version_requirements: !ruby/object:Gem::Requirement
51
52
  requirements:
52
- - - "~>"
53
+ - - ">="
53
54
  - !ruby/object:Gem::Version
54
- version: '1.2'
55
+ version: '0'
55
56
  - !ruby/object:Gem::Dependency
56
57
  name: easy-configuration
57
58
  requirement: !ruby/object:Gem::Requirement
@@ -66,75 +67,93 @@ dependencies:
66
67
  - - ">="
67
68
  - !ruby/object:Gem::Version
68
69
  version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: easy_style
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
69
84
  - !ruby/object:Gem::Dependency
70
85
  name: rails
71
86
  requirement: !ruby/object:Gem::Requirement
72
87
  requirements:
73
88
  - - "~>"
74
89
  - !ruby/object:Gem::Version
75
- version: '5.2'
90
+ version: '6.1'
76
91
  type: :development
77
92
  prerelease: false
78
93
  version_requirements: !ruby/object:Gem::Requirement
79
94
  requirements:
80
95
  - - "~>"
81
96
  - !ruby/object:Gem::Version
82
- version: '5.2'
97
+ version: '6.1'
83
98
  - !ruby/object:Gem::Dependency
84
99
  name: rspec-rails
85
100
  requirement: !ruby/object:Gem::Requirement
86
101
  requirements:
87
102
  - - "~>"
88
103
  - !ruby/object:Gem::Version
89
- version: '3.8'
104
+ version: '4.0'
90
105
  type: :development
91
106
  prerelease: false
92
107
  version_requirements: !ruby/object:Gem::Requirement
93
108
  requirements:
94
109
  - - "~>"
95
110
  - !ruby/object:Gem::Version
96
- version: '3.8'
111
+ version: '4.0'
97
112
  - !ruby/object:Gem::Dependency
98
- name: webmock
113
+ name: sqlite3
99
114
  requirement: !ruby/object:Gem::Requirement
100
115
  requirements:
101
116
  - - "~>"
102
117
  - !ruby/object:Gem::Version
103
- version: '3.4'
118
+ version: 1.4.2
104
119
  type: :development
105
120
  prerelease: false
106
121
  version_requirements: !ruby/object:Gem::Requirement
107
122
  requirements:
108
123
  - - "~>"
109
124
  - !ruby/object:Gem::Version
110
- version: '3.4'
125
+ version: 1.4.2
111
126
  - !ruby/object:Gem::Dependency
112
- name: sqlite3
127
+ name: webmock
113
128
  requirement: !ruby/object:Gem::Requirement
114
129
  requirements:
115
130
  - - "~>"
116
131
  - !ruby/object:Gem::Version
117
- version: 1.3.6
132
+ version: '3.13'
118
133
  type: :development
119
134
  prerelease: false
120
135
  version_requirements: !ruby/object:Gem::Requirement
121
136
  requirements:
122
137
  - - "~>"
123
138
  - !ruby/object:Gem::Version
124
- version: 1.3.6
125
- description: Description of Easy::Resources.
139
+ version: '3.13'
140
+ description: Define common Active::Resources for Redmine / Easy Redmine and Easy Project
141
+ entities.
126
142
  email:
127
143
  - petr@easy.cz
144
+ - lukas@easy.cz
128
145
  executables: []
129
146
  extensions: []
130
147
  extra_rdoc_files: []
131
148
  files:
149
+ - CHANGELOG.md
132
150
  - MIT-LICENSE
133
151
  - README.md
134
152
  - Rakefile
135
153
  - lib/easy/resource.rb
136
154
  - lib/easy/resources.rb
137
155
  - lib/easy/resources/railtie.rb
156
+ - lib/easy/resources/redmine/custom_field.rb
138
157
  - lib/easy/resources/redmine/easy_attendance.rb
139
158
  - lib/easy/resources/redmine/easy_contact.rb
140
159
  - lib/easy/resources/redmine/easy_crm_case.rb
@@ -142,6 +161,7 @@ files:
142
161
  - lib/easy/resources/redmine/easy_web_application.rb
143
162
  - lib/easy/resources/redmine/easy_web_application_activity.rb
144
163
  - lib/easy/resources/redmine/easy_web_hook.rb
164
+ - lib/easy/resources/redmine/errors.rb
145
165
  - lib/easy/resources/redmine/issue.rb
146
166
  - lib/easy/resources/redmine/project.rb
147
167
  - lib/easy/resources/redmine/redmine_base.rb
@@ -150,6 +170,12 @@ files:
150
170
  - lib/easy/resources/spec_helper.rb
151
171
  - lib/easy/resources/version.rb
152
172
  - spec/easy_resources_spec.rb
173
+ - spec/fixtures/files/custom_field/bool.xml
174
+ - spec/fixtures/files/custom_field/date.xml
175
+ - spec/fixtures/files/custom_field/datetime.xml
176
+ - spec/fixtures/files/custom_field/float.xml
177
+ - spec/fixtures/files/custom_field/int.xml
178
+ - spec/fixtures/files/custom_field/string.xml
153
179
  - spec/fixtures/files/easy_attendance/show.xml
154
180
  - spec/fixtures/files/easy_contact.json
155
181
  - spec/fixtures/files/easy_contact/show.xml
@@ -164,18 +190,24 @@ files:
164
190
  - spec/fixtures/files/easy_web_application/with_easy_contact.xml
165
191
  - spec/fixtures/files/easy_web_application/with_easy_crm_case.xml
166
192
  - spec/fixtures/files/easy_web_application/with_ewaa.xml
193
+ - spec/fixtures/files/easy_web_hook/index.xml
194
+ - spec/fixtures/files/easy_web_hook/show.xml
167
195
  - spec/fixtures/files/issue.json
168
196
  - spec/fixtures/files/issue/show.xml
169
197
  - spec/fixtures/files/project.json
170
198
  - spec/fixtures/files/project/show.xml
199
+ - spec/fixtures/files/time_entry/invalid_update.xml
171
200
  - spec/fixtures/files/time_entry/show.xml
172
201
  - spec/fixtures/files/user/show.xml
202
+ - spec/models/easy-resources/redmine/custom_field_spec.rb
173
203
  - spec/models/easy-resources/redmine/easy_attendance_spec.rb
174
204
  - spec/models/easy-resources/redmine/easy_contact_spec.rb
175
205
  - spec/models/easy-resources/redmine/easy_crm_case_spec.rb
176
206
  - spec/models/easy-resources/redmine/easy_server_spec.rb
177
207
  - spec/models/easy-resources/redmine/easy_web_application_activity_spec.rb
178
208
  - spec/models/easy-resources/redmine/easy_web_application_spec.rb
209
+ - spec/models/easy-resources/redmine/easy_web_hook_spec.rb
210
+ - spec/models/easy-resources/redmine/errors_spec.rb
179
211
  - spec/models/easy-resources/redmine/issue_spec.rb
180
212
  - spec/models/easy-resources/redmine/project_spec.rb
181
213
  - spec/models/easy-resources/redmine/redmine_base_spec.rb
@@ -186,41 +218,44 @@ files:
186
218
  - spec/support/active_resource.rb
187
219
  - spec/support/fixtures.rb
188
220
  - spec/support/redmine_active_resource.rb
189
- homepage: https://www.easysoftware.com
221
+ homepage: https://git.easy.cz/easy/resources
190
222
  licenses:
191
223
  - MIT
192
224
  metadata:
193
225
  allowed_push_host: https://rubygems.org
194
- post_install_message:
226
+ post_install_message:
195
227
  rdoc_options: []
196
228
  require_paths:
197
229
  - lib
198
230
  required_ruby_version: !ruby/object:Gem::Requirement
199
231
  requirements:
200
- - - ">="
232
+ - - "~>"
201
233
  - !ruby/object:Gem::Version
202
- version: '0'
234
+ version: '2.5'
203
235
  required_rubygems_version: !ruby/object:Gem::Requirement
204
236
  requirements:
205
237
  - - ">="
206
238
  - !ruby/object:Gem::Version
207
239
  version: '0'
208
240
  requirements: []
209
- rubygems_version: 3.0.8
210
- signing_key:
241
+ rubygems_version: 3.2.16
242
+ signing_key:
211
243
  specification_version: 4
212
- summary: Summary of Easy::Resources.
244
+ summary: ActiveResources connectors for Easy Project / Easy Redmine
213
245
  test_files:
214
246
  - spec/spec_helper.rb
247
+ - spec/models/easy-resources/redmine/custom_field_spec.rb
215
248
  - spec/models/easy-resources/redmine/project_spec.rb
216
249
  - spec/models/easy-resources/redmine/easy_crm_case_spec.rb
217
250
  - spec/models/easy-resources/redmine/easy_contact_spec.rb
218
251
  - spec/models/easy-resources/redmine/issue_spec.rb
219
252
  - spec/models/easy-resources/redmine/time_entry_spec.rb
220
253
  - spec/models/easy-resources/redmine/redmine_base_spec.rb
254
+ - spec/models/easy-resources/redmine/easy_web_hook_spec.rb
221
255
  - spec/models/easy-resources/redmine/easy_web_application_activity_spec.rb
222
256
  - spec/models/easy-resources/redmine/easy_web_application_spec.rb
223
257
  - spec/models/easy-resources/redmine/easy_server_spec.rb
258
+ - spec/models/easy-resources/redmine/errors_spec.rb
224
259
  - spec/models/easy-resources/redmine/user_spec.rb
225
260
  - spec/models/easy-resources/redmine/easy_attendance_spec.rb
226
261
  - spec/models/easy-resources/resource_spec.rb
@@ -228,8 +263,17 @@ test_files:
228
263
  - spec/support/fixtures.rb
229
264
  - spec/support/redmine_active_resource.rb
230
265
  - spec/easy_resources_spec.rb
266
+ - spec/fixtures/files/easy_web_hook/index.xml
267
+ - spec/fixtures/files/easy_web_hook/show.xml
231
268
  - spec/fixtures/files/easy_contact/show.xml
232
269
  - spec/fixtures/files/time_entry/show.xml
270
+ - spec/fixtures/files/time_entry/invalid_update.xml
271
+ - spec/fixtures/files/custom_field/datetime.xml
272
+ - spec/fixtures/files/custom_field/bool.xml
273
+ - spec/fixtures/files/custom_field/float.xml
274
+ - spec/fixtures/files/custom_field/date.xml
275
+ - spec/fixtures/files/custom_field/int.xml
276
+ - spec/fixtures/files/custom_field/string.xml
233
277
  - spec/fixtures/files/easy_crm_case.json
234
278
  - spec/fixtures/files/easy_crm_case/show.xml
235
279
  - spec/fixtures/files/project.json