easy-resources 0.8.1 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +70 -0
  3. data/lib/easy/resource.rb +12 -9
  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 +7 -2
  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 +3 -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 +3 -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/models/easy-resources/redmine/custom_field_spec.rb +31 -0
  32. data/spec/models/easy-resources/redmine/easy_attendance_spec.rb +0 -1
  33. data/spec/models/easy-resources/redmine/easy_contact_spec.rb +0 -1
  34. data/spec/models/easy-resources/redmine/easy_crm_case_spec.rb +0 -2
  35. data/spec/models/easy-resources/redmine/easy_server_spec.rb +0 -1
  36. data/spec/models/easy-resources/redmine/easy_web_application_activity_spec.rb +0 -1
  37. data/spec/models/easy-resources/redmine/easy_web_application_spec.rb +14 -2
  38. data/spec/models/easy-resources/redmine/easy_web_hook_spec.rb +9 -0
  39. data/spec/models/easy-resources/redmine/errors_spec.rb +0 -1
  40. data/spec/models/easy-resources/redmine/issue_spec.rb +0 -2
  41. data/spec/models/easy-resources/redmine/project_spec.rb +0 -2
  42. data/spec/models/easy-resources/redmine/redmine_base_spec.rb +0 -2
  43. data/spec/models/easy-resources/redmine/time_entry_spec.rb +0 -1
  44. data/spec/models/easy-resources/redmine/user_spec.rb +0 -2
  45. data/spec/models/easy-resources/resource_spec.rb +2 -2
  46. data/spec/spec_helper.rb +4 -4
  47. data/spec/support/active_resource.rb +3 -3
  48. data/spec/support/redmine_active_resource.rb +4 -4
  49. metadata +73 -34
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fdaa3a94f0e1549a33bfe6e3c9401824ed0ae9937b8be66e75efb2c1bb64c89e
4
- data.tar.gz: bda0af2d019e2e28ea1236344d038b3fd59a2459da0b0bb83bbcd73a204ed8ee
3
+ metadata.gz: 78e3ee85bb308efe3d49df5e230984860f8be924ee8f5dabcb89db87691c8736
4
+ data.tar.gz: 550563403efc65b6927927af2c8542794497a629057d25964f8a3d04b06ad0bf
5
5
  SHA512:
6
- metadata.gz: d02e7009079481c7b40730e126826f0288fec9f2abd454e05ab5ed1268c5c794802095fc63ed077be184ae7a0894f682b64aea716c30e31dccf4a2766fb7dc00
7
- data.tar.gz: cbd2cc87d9d53f70367fb2b6604b67cda4c73becd7dbecebae5fc5c6a48f78bdf4637fcf679fe3be92531883146afb13af231f859967b9cd11f3db6a368a01a0
6
+ metadata.gz: 35679557ec16ff9a221fd9ad59b36c723a52a3d7ead9fe2834be5c558c354dedd12f5f9d417c0efa063b85f4c6ddc2d528adc393eddd4011bcbe1d1bdc3bc28c
7
+ data.tar.gz: db430c848f60389dadf4e818e15c2e0fdbac0f0a7cc359d68decc4da45e65f3dea01b9e67ce5f95c0508b10f8d5f48f872bc19a9e0c6aed8964cfc975fab431c
data/CHANGELOG.md ADDED
@@ -0,0 +1,70 @@
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.10.0] - 2021-09-01
9
+ ### Added
10
+ - support ruby3.0
11
+ ### Removed
12
+ - support ruby2.5
13
+
14
+ ## [0.9.1] - 2021-08-24
15
+ ### Fixed
16
+ - adjusted EWA schema
17
+
18
+ ## [0.9.0] - 2021-06-08
19
+ ### Added
20
+ - CustomField resource
21
+ - rubocop linter
22
+ - improve gemspec metadata
23
+ ### Changed
24
+ - dummy upgrade to rails 6
25
+ - update dev dependencies
26
+
27
+ ## [0.8.2] - 2021-03-05
28
+ ### Added
29
+ - ruby 3 compatibility
30
+
31
+ ## [0.8.1] - 2020-06-08
32
+ ### Fixed
33
+ - Retrieve (Easy)Redmine total entities from response if headers missing
34
+ - Validation error messages parser from XML
35
+
36
+ ## [0.8.0] - 2020-04-28
37
+ ### Added
38
+ - TimeEntry
39
+ - EasyAttendance
40
+ ## [0.7.5] - 2020-03-06
41
+ ### Added
42
+ - EasyServer `status` alias for `server_status`
43
+ ## [0.7.5] - 2020-01-17
44
+ ### Added
45
+ - aasm_event into EasyWebApplication scheme
46
+ - notes into EasyWebApplication scheme
47
+ ## [0.7.4] - 2019-09-02
48
+ ### Added
49
+ - Easy Web Application add belongs_to Issue
50
+ ## [0.7.2] - 2019-08-29
51
+ ### Added
52
+ - Easy Web Hook model
53
+ ## [0.7.1] - 2019-07-11
54
+ ### Added
55
+ - configuration from Oauth2 token
56
+ ### Fixed
57
+ - api_key is changed to class_attribute
58
+ ## [0.6.3] - 2019-07-08
59
+ ### Fixed
60
+ - cached headers
61
+ ## [0.6.2] - 2019-05-14
62
+ ### Added
63
+ - alias url in server resource
64
+ ## [0.6.1] - 2019-04-03
65
+ ### Added
66
+ - this file
67
+ - User resource in Redmine
68
+ - 100% code coverage :)
69
+ ### Changed
70
+ - 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
 
@@ -37,13 +40,13 @@ module Easy
37
40
  update_columns(attribute.to_sym => value)
38
41
  end
39
42
 
40
- def update_columns(**attributes)
43
+ def update_columns(attributes)
41
44
  patch(nil, {}, encode_attributes(attributes))
42
45
  end
43
46
 
44
47
  protected
45
48
 
46
- def encode_attributes(**attributes)
49
+ def encode_attributes(attributes)
47
50
  case self.class.format.extension
48
51
  when "json"
49
52
  attributes.to_json(include_root_in_json ? { root: self.class.element_name } : {})
@@ -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
@@ -6,10 +6,15 @@ module Easy
6
6
  # Redmine in XML responses specify type="array" on Errors
7
7
  # It cause that `Hash.from_xml` already parsed errors as a Array
8
8
  def from_xml(xml, save_cache = false)
9
- array = Array.wrap(Hash.from_xml(xml)["errors"]) rescue []
9
+ array = begin
10
+ Array.wrap(Hash.from_xml(xml)["errors"])
11
+ rescue StandardError
12
+ []
13
+ end
10
14
  from_array array, save_cache
11
15
  end
16
+
12
17
  end
13
18
  end
14
19
  end
15
- 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
 
@@ -29,7 +28,7 @@ module Easy
29
28
  # Parse value of TOTAL amount of entities from headers or response
30
29
  # @return [Integer]
31
30
  def retrieve_total(response)
32
- (response['Total'] || response.body[/total_count[:="]+(\d+)/] && $1).to_i
31
+ (response['Total'] || response.body[/total_count[:="]+(\d+)/] && Regexp.last_match(1)).to_i
33
32
  end
34
33
 
35
34
  def get_all(**params, &block)
@@ -56,6 +55,7 @@ module Easy
56
55
  def errors
57
56
  @errors ||= Errors.new(self)
58
57
  end
58
+
59
59
  end
60
60
  end
61
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.1'
3
+
4
+ VERSION = '0.10.0'
5
+
4
6
  end
5
7
  end
@@ -4,6 +4,7 @@ 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
@@ -11,6 +12,7 @@ module Easy
11
12
 
12
13
  autoload :Errors, "easy/resources/redmine/errors"
13
14
 
15
+ autoload :CustomField, "easy/resources/redmine/custom_field"
14
16
  autoload :RedmineBase, "easy/resources/redmine/redmine_base"
15
17
  autoload :EasyAttendance, "easy/resources/redmine/easy_attendance"
16
18
  autoload :EasyContact, "easy/resources/redmine/easy_contact"
@@ -26,4 +28,5 @@ module Easy
26
28
 
27
29
  end
28
30
  end
31
+
29
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,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
@@ -11,5 +11,4 @@ RSpec.describe Easy::Resources::Redmine::Errors do
11
11
  expect(time_entry.errors).to be_a described_class
12
12
  expect(time_entry.errors.full_messages).to eq ["Projekt je neplatné"]
13
13
  end
14
-
15
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)
@@ -23,6 +23,6 @@ RSpec.shared_context "redmine active resource shares", shared_context: :metadata
23
23
  options[:request_headers]["X-Redmine-API-Key"] = api_key
24
24
  options[:format] = format
25
25
  options[:path] = path
26
- stub_resource_request options
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.1
4
+ version: 0.10.0
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-06-04 00:00:00.000000000 Z
12
+ date: 2021-09-01 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
@@ -151,6 +170,12 @@ files:
151
170
  - lib/easy/resources/spec_helper.rb
152
171
  - lib/easy/resources/version.rb
153
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
154
179
  - spec/fixtures/files/easy_attendance/show.xml
155
180
  - spec/fixtures/files/easy_contact.json
156
181
  - spec/fixtures/files/easy_contact/show.xml
@@ -165,6 +190,8 @@ files:
165
190
  - spec/fixtures/files/easy_web_application/with_easy_contact.xml
166
191
  - spec/fixtures/files/easy_web_application/with_easy_crm_case.xml
167
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
168
195
  - spec/fixtures/files/issue.json
169
196
  - spec/fixtures/files/issue/show.xml
170
197
  - spec/fixtures/files/project.json
@@ -172,12 +199,14 @@ files:
172
199
  - spec/fixtures/files/time_entry/invalid_update.xml
173
200
  - spec/fixtures/files/time_entry/show.xml
174
201
  - spec/fixtures/files/user/show.xml
202
+ - spec/models/easy-resources/redmine/custom_field_spec.rb
175
203
  - spec/models/easy-resources/redmine/easy_attendance_spec.rb
176
204
  - spec/models/easy-resources/redmine/easy_contact_spec.rb
177
205
  - spec/models/easy-resources/redmine/easy_crm_case_spec.rb
178
206
  - spec/models/easy-resources/redmine/easy_server_spec.rb
179
207
  - spec/models/easy-resources/redmine/easy_web_application_activity_spec.rb
180
208
  - spec/models/easy-resources/redmine/easy_web_application_spec.rb
209
+ - spec/models/easy-resources/redmine/easy_web_hook_spec.rb
181
210
  - spec/models/easy-resources/redmine/errors_spec.rb
182
211
  - spec/models/easy-resources/redmine/issue_spec.rb
183
212
  - spec/models/easy-resources/redmine/project_spec.rb
@@ -189,12 +218,12 @@ files:
189
218
  - spec/support/active_resource.rb
190
219
  - spec/support/fixtures.rb
191
220
  - spec/support/redmine_active_resource.rb
192
- homepage: https://www.easysoftware.com
221
+ homepage: https://git.easy.cz/easy/resources
193
222
  licenses:
194
223
  - MIT
195
224
  metadata:
196
225
  allowed_push_host: https://rubygems.org
197
- post_install_message:
226
+ post_install_message:
198
227
  rdoc_options: []
199
228
  require_paths:
200
229
  - lib
@@ -202,25 +231,27 @@ required_ruby_version: !ruby/object:Gem::Requirement
202
231
  requirements:
203
232
  - - ">="
204
233
  - !ruby/object:Gem::Version
205
- version: '0'
234
+ version: '2.6'
206
235
  required_rubygems_version: !ruby/object:Gem::Requirement
207
236
  requirements:
208
237
  - - ">="
209
238
  - !ruby/object:Gem::Version
210
239
  version: '0'
211
240
  requirements: []
212
- rubygems_version: 3.0.6
213
- signing_key:
241
+ rubygems_version: 3.2.16
242
+ signing_key:
214
243
  specification_version: 4
215
- summary: Summary of Easy::Resources.
244
+ summary: ActiveResources connectors for Easy Project / Easy Redmine
216
245
  test_files:
217
246
  - spec/spec_helper.rb
247
+ - spec/models/easy-resources/redmine/custom_field_spec.rb
218
248
  - spec/models/easy-resources/redmine/project_spec.rb
219
249
  - spec/models/easy-resources/redmine/easy_crm_case_spec.rb
220
250
  - spec/models/easy-resources/redmine/easy_contact_spec.rb
221
251
  - spec/models/easy-resources/redmine/issue_spec.rb
222
252
  - spec/models/easy-resources/redmine/time_entry_spec.rb
223
253
  - spec/models/easy-resources/redmine/redmine_base_spec.rb
254
+ - spec/models/easy-resources/redmine/easy_web_hook_spec.rb
224
255
  - spec/models/easy-resources/redmine/easy_web_application_activity_spec.rb
225
256
  - spec/models/easy-resources/redmine/easy_web_application_spec.rb
226
257
  - spec/models/easy-resources/redmine/easy_server_spec.rb
@@ -232,9 +263,17 @@ test_files:
232
263
  - spec/support/fixtures.rb
233
264
  - spec/support/redmine_active_resource.rb
234
265
  - spec/easy_resources_spec.rb
266
+ - spec/fixtures/files/easy_web_hook/index.xml
267
+ - spec/fixtures/files/easy_web_hook/show.xml
235
268
  - spec/fixtures/files/easy_contact/show.xml
236
269
  - spec/fixtures/files/time_entry/show.xml
237
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
238
277
  - spec/fixtures/files/easy_crm_case.json
239
278
  - spec/fixtures/files/easy_crm_case/show.xml
240
279
  - spec/fixtures/files/project.json