redmine_remotes 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b65843d810df106f89cfab8c6da6beef03d5421263f21a7b7730e9dab08ce13
4
- data.tar.gz: ec23913f8340a42f5c69f28e0f24f72baacf3b59b38adb9d8f32dadeca9fc06c
3
+ metadata.gz: bd846a3cc1a788360a4b120472ea5fe1d8f8d55835a95a3af3e842fe77e1d898
4
+ data.tar.gz: d4c1a544d79c5cedd5db4030df30d61cb021813a2b96457d039c77e1c35d5821
5
5
  SHA512:
6
- metadata.gz: 886781f236327ed6e0d30d26f3950e80a07629c3c2905c8bf98a50cb8c9ed10daa9be495c804059d2ac195816894c77ee2af43e87d3c253ccb20a568bcd0bb5d
7
- data.tar.gz: 41578f7e2bfa7a6c97bdad8cc9bff55c1a8e26f8099d5ba824c0b0e420ed746ee46f8058b6d9cfb8069de6fc6dda8c4b16b5ed566bce325abada1043e1b268dd
6
+ metadata.gz: 429c14c070e2c1d8fe18aa45d08eeb2561fc144397811e45c6f0b6571fc85e8fce06dd3c01798c47aa78b9b7ecef313e43d6352c2dd4615dd1d87e588085a2b0
7
+ data.tar.gz: 87dbdb0ddf2fb97b7db523512c5687e38c8982abf08cc1d4013c3bcd708162a9b240b93a2b39b002b078c9db883068367df158e646cf8bb5bfafecd2323b697f
@@ -6,11 +6,36 @@ module RedmineRemotes
6
6
  class Base < ::EacRailsUtils::TablelessModel
7
7
  private
8
8
 
9
+ def save_local_issue
10
+ save_local_issue_except_create_on && save_local_issue_created_on
11
+ end
12
+
13
+ def save_local_issue_created_on
14
+ local_issue_provider_attributes[:created_on].if_present do |created_on|
15
+ if created_on.present? && local_issue.created_on != created_on
16
+ local_issue.update_column( # rubocop:disable Rails/SkipsModelValidations
17
+ :created_on, created_on
18
+ )
19
+ end
20
+ end
21
+
22
+ true
23
+ end
24
+
25
+ def save_local_issue_except_create_on
26
+ local_issue_provider_attributes.except(:created_on)
27
+ .each { |attr, value| local_issue.send("#{attr}=", value) }
28
+ return true if local_issue.save
29
+
30
+ fetch_record_errors(local_issue, default_column: default_error_column)
31
+ false
32
+ end
33
+
9
34
  def local_issue_provider_attributes
10
35
  {
11
36
  subject: local_issue_subject, author: local_issue_author, status: local_issue_status,
12
37
  description: local_issue_description,
13
- created_on: provider_issue.created_on, updated_on: provider_issue.updated_on
38
+ created_on: provider_issue.created_on
14
39
  }
15
40
  end
16
41
 
@@ -22,7 +22,7 @@ module RedmineRemotes
22
22
  def create
23
23
  ::Issue.transaction do
24
24
  return false unless valid?
25
- return false unless create_local_issue
25
+ return false unless save_local_issue
26
26
  return false unless create_remote_issue
27
27
  end
28
28
  true
@@ -6,20 +6,14 @@ module RedmineRemotes
6
6
  class Create < ::RedmineRemotes::Tableless::RemoteIssueFetch::Base
7
7
  private
8
8
 
9
- def create_local_issue
10
- return true if local_issue.save
11
-
12
- fetch_record_errors(local_issue, default_column: default_error_column)
13
- false
9
+ def local_issue_provider_attributes
10
+ super.merge(
11
+ project: project, tracker: local_tracker, priority: local_issue_priority
12
+ )
14
13
  end
15
14
 
16
15
  def local_issue_uncached
17
- remote_issue_by_remote_code.if_present { |v| return v.local_issue }
18
- ::Issue.new(
19
- local_issue_provider_attributes.merge(
20
- project: project, tracker: local_tracker, priority: local_issue_priority
21
- )
22
- )
16
+ remote_issue_by_remote_code.if_present(&:local_issue) || ::Issue.new
23
17
  end
24
18
 
25
19
  def local_issue_priority
@@ -20,7 +20,7 @@ module RedmineRemotes
20
20
 
21
21
  def save
22
22
  return false unless valid?
23
- return false unless update_local_issue_with_remote_data
23
+ return false unless save_local_issue
24
24
 
25
25
  true
26
26
  end
@@ -13,13 +13,6 @@ module RedmineRemotes
13
13
  def local_tracker
14
14
  local_issue.if_present(&:tracker)
15
15
  end
16
-
17
- def update_local_issue_with_remote_data
18
- return true if local_issue.update(local_issue_provider_attributes)
19
-
20
- fetch_record_errors(local_issue, default_column: default_error_column)
21
- false
22
- end
23
16
  end
24
17
  end
25
18
  end
@@ -30,10 +30,6 @@ module RedmineRemotes
30
30
  fields.fetch('status').fetch('name')
31
31
  end
32
32
 
33
- def updated_on
34
- fields.fetch('updated')
35
- end
36
-
37
33
  def author_login
38
34
  fields.try(:fetch, 'reporter').try(:fetch, 'key')
39
35
  end
@@ -3,7 +3,7 @@
3
3
  module RedmineRemotes
4
4
  SLUG = 'redmine_remotes'
5
5
  NAME = 'Redmine Remotes'
6
- VERSION = '0.8.1'
6
+ VERSION = '0.8.2'
7
7
  AUTHOR = 'Eduardo Henrique Bogoni'
8
8
  SUMMARY = 'Integração do Redmine com trackers diversos.'
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redmine_remotes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo Henrique Bogoni