redmine_remotes 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/remote_trackers_controller.rb +2 -1
- data/app/models/remote_issue_status.rb +15 -0
- data/app/models/remote_tracker.rb +4 -1
- data/app/models/remote_user.rb +17 -0
- data/db/migrate/20190913195930_add_default_local_user_id_to_remote_trackers.rb +9 -0
- data/lib/redmine_remotes/patches/user.rb +3 -0
- data/lib/redmine_remotes/sanitizer.rb +33 -0
- data/lib/redmine_remotes/version.rb +1 -1
- data/lib/tasks/redmine_remotes.rake +11 -0
- metadata +25 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7ec7641f2a0fa365011119971dbe87875bd2d89a0b1a309f4849498810eb4c2
|
4
|
+
data.tar.gz: 2b5877691f690622b098bbea6551e77b415e4a10727573f4cb9b8d490e78963d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8afb48ab0775f253e431a024e518fa466e6881768e50c47418a15db4e488dd660f3f478973fb373c7ca624aaca1daaeab20cbf60071619a797a5771c07e03d24
|
7
|
+
data.tar.gz: 70c63885ccb1fb9c6273586688128f76b4f1dba485016a1a58d9692caa121b42a465ce7a83d63c4ac4245e0f3e941a919c38d48ff799387bbdacb07111a354e7
|
@@ -10,9 +10,10 @@ class RemoteTrackersController < ApplicationController
|
|
10
10
|
require_permission PERMISSIONS
|
11
11
|
|
12
12
|
active_scaffold :remote_tracker do |conf|
|
13
|
-
conf.columns = %i[profile root_url username password]
|
13
|
+
conf.columns = %i[profile root_url username password default_local_user]
|
14
14
|
conf.columns[:password].form_ui = :password
|
15
15
|
conf.columns[:profile].form_ui = :select
|
16
|
+
conf.columns[:default_local_user].form_ui = :select
|
16
17
|
%w[list show].each { |action| conf.send(action).columns.exclude :password }
|
17
18
|
end
|
18
19
|
|
@@ -1,6 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class RemoteIssueStatus < ActiveRecord::Base
|
4
|
+
include ::RedmineRemotes::Sanitizer
|
5
|
+
|
6
|
+
downcase_columns :remote_name
|
7
|
+
|
4
8
|
belongs_to :remote_tracker
|
5
9
|
belongs_to :local_tracker, class_name: 'Tracker'
|
6
10
|
belongs_to :local_issue_status, class_name: 'IssueStatus'
|
@@ -9,4 +13,15 @@ class RemoteIssueStatus < ActiveRecord::Base
|
|
9
13
|
validates :remote_tracker, presence: true
|
10
14
|
validates :local_tracker, presence: true
|
11
15
|
validates :local_issue_status, presence: true
|
16
|
+
|
17
|
+
class << self
|
18
|
+
def find_local_issue_status(remote_name, remote_tracker, local_tracker)
|
19
|
+
record = ::RemoteIssueStatus.where(
|
20
|
+
remote_name: remote_name_sanitize(remote_name),
|
21
|
+
remote_tracker: remote_tracker,
|
22
|
+
local_tracker: local_tracker
|
23
|
+
).first
|
24
|
+
record ? record.local_issue_status : nil
|
25
|
+
end
|
26
|
+
end
|
12
27
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'eac_ruby_utils/listable'
|
4
|
+
require 'validate_url'
|
4
5
|
|
5
6
|
class RemoteTracker < ActiveRecord::Base
|
6
7
|
include ::EacRubyUtils::Listable
|
@@ -11,11 +12,13 @@ class RemoteTracker < ActiveRecord::Base
|
|
11
12
|
dependent: :destroy
|
12
13
|
has_many :remote_users, class_name: 'RemoteUser', inverse_of: :remote_tracker,
|
13
14
|
dependent: :restrict_with_error
|
15
|
+
belongs_to :default_local_user, class_name: 'User', inverse_of: :remote_trackers_as_default
|
14
16
|
|
15
17
|
validates :profile, presence: true, inclusion: { in: lists.profile.values }
|
16
|
-
validates :root_url, presence: true, uniqueness: { scope: [:username] }
|
18
|
+
validates :root_url, presence: true, uniqueness: { scope: [:username] }, url: true
|
17
19
|
validates :username, presence: true
|
18
20
|
validates :password, presence: true
|
21
|
+
validates :default_local_user, presence: true
|
19
22
|
|
20
23
|
def to_s
|
21
24
|
"#{root_url} [#{profile_label}, #{username}]"
|
data/app/models/remote_user.rb
CHANGED
@@ -1,9 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class RemoteUser < ActiveRecord::Base
|
4
|
+
include ::RedmineRemotes::Sanitizer
|
5
|
+
|
6
|
+
downcase_columns :remote_login
|
7
|
+
|
4
8
|
belongs_to :remote_tracker, class_name: 'RemoteTracker', inverse_of: :remote_users
|
5
9
|
belongs_to :local_user, class_name: 'User', inverse_of: :remote_users
|
6
10
|
|
7
11
|
validates :remote_login, presence: true, uniqueness: { scope: [:remote_tracker] }
|
8
12
|
validates :local_user, presence: true
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def find_local_user(remote_login, tracker = nil)
|
16
|
+
[tracker, nil].each do |tracker|
|
17
|
+
remote_user = ::RemoteUser.where(
|
18
|
+
remote_tracker: tracker,
|
19
|
+
remote_login: remote_login_sanitize(remote_login)
|
20
|
+
).first
|
21
|
+
return remote_user.local_user if remote_user
|
22
|
+
end
|
23
|
+
nil
|
24
|
+
end
|
25
|
+
end
|
9
26
|
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class AddDefaultLocalUserIdToRemoteTrackers < ActiveRecord::Migration
|
4
|
+
def change
|
5
|
+
add_reference :remote_trackers, :default_local_user, index: true
|
6
|
+
|
7
|
+
add_foreign_key :remote_trackers, :users, column: :default_local_user_id
|
8
|
+
end
|
9
|
+
end
|
@@ -8,6 +8,9 @@ module EacRedmineUsability
|
|
8
8
|
included do
|
9
9
|
has_many :remote_users, class_name: 'RemoteUser', inverse_of: :local_user,
|
10
10
|
dependent: :destroy
|
11
|
+
has_many :remote_trackers_as_default,
|
12
|
+
class_name: 'RemoteTracker', inverse_of: :default_local_user,
|
13
|
+
dependent: :restrict_with_error
|
11
14
|
end
|
12
15
|
end
|
13
16
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RedmineRemotes
|
4
|
+
module Sanitizer
|
5
|
+
extend ::ActiveSupport::Concern
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def downcase_sanitize(value)
|
9
|
+
value.to_s.downcase.strip if value.present?
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
included do
|
14
|
+
extend ClassMethods
|
15
|
+
end
|
16
|
+
|
17
|
+
module ClassMethods
|
18
|
+
def downcase_columns(*columns)
|
19
|
+
columns.each { |column| downcase_column(column) }
|
20
|
+
end
|
21
|
+
|
22
|
+
def downcase_column(column)
|
23
|
+
sanitize_method = "#{column}_sanitize"
|
24
|
+
define_singleton_method sanitize_method do |column_value|
|
25
|
+
::RedmineRemotes::Sanitizer.downcase_sanitize(column_value)
|
26
|
+
end
|
27
|
+
define_method "#{column}=" do |column_value|
|
28
|
+
self[column] = self.class.send(sanitize_method, column_value)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
namespace :redmine_remotes do
|
2
|
+
Rake::TestTask.new(test: 'db:test:prepare') do |t|
|
3
|
+
plugin_root = ::File.dirname(::File.dirname(__dir__))
|
4
|
+
|
5
|
+
t.description = 'Run plugin redmine_remotes\'s tests.'
|
6
|
+
t.libs << 'test'
|
7
|
+
t.test_files = FileList["#{plugin_root}/test/**/*_test.rb"]
|
8
|
+
t.verbose = false
|
9
|
+
t.warning = false
|
10
|
+
end
|
11
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redmine_remotes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eduardo Henrique Bogoni
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eac_ruby_utils
|
@@ -30,6 +30,26 @@ dependencies:
|
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 0.10.1
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: validate_url
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.0'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 1.0.8
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '1.0'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 1.0.8
|
33
53
|
description:
|
34
54
|
email:
|
35
55
|
executables: []
|
@@ -52,12 +72,15 @@ files:
|
|
52
72
|
- db/migrate/20190910182842_create_remote_users.rb
|
53
73
|
- db/migrate/20190910203552_create_remote_issue_statuses.rb
|
54
74
|
- db/migrate/20190911165556_rename_issue_status_id_to_local_issue_status_id_in_remote_issue_statuses.rb
|
75
|
+
- db/migrate/20190913195930_add_default_local_user_id_to_remote_trackers.rb
|
55
76
|
- init.rb
|
56
77
|
- lib/redmine_remotes.rb
|
57
78
|
- lib/redmine_remotes/patches/issue_status.rb
|
58
79
|
- lib/redmine_remotes/patches/tracker.rb
|
59
80
|
- lib/redmine_remotes/patches/user.rb
|
81
|
+
- lib/redmine_remotes/sanitizer.rb
|
60
82
|
- lib/redmine_remotes/version.rb
|
83
|
+
- lib/tasks/redmine_remotes.rake
|
61
84
|
homepage:
|
62
85
|
licenses: []
|
63
86
|
metadata: {}
|