redmineup 1.0.11 → 1.0.12

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e598cbcf77d2b144b190a8c7640115025f9d09e10831e48357d38bb8f40f869
4
- data.tar.gz: 2e07a723c8ec404883353f83777c95094d21d5f4a8a6a3f44ecea264d175aee1
3
+ metadata.gz: 9b6a7c941dfeb0f6331943c83eb73c7a42f4c05f7037a356eed48bf56eb34a39
4
+ data.tar.gz: b1cea3cb3fc3a4939f81c6b2c6dcabd95af9d07a7e98ae9678333562f4ec5f5d
5
5
  SHA512:
6
- metadata.gz: 0a765e2cd45f2725f88f739bec80508bf7dfc7bdde5ee37825c16583c7fbaef8e89486daab5ae4003fb2472621630bb3045c10e2c5452069ecb46089ea5a66d0
7
- data.tar.gz: 49b3819f6aa2f322d2157366956c8139a4da1922c67d7ea7d804e567d2df3ce41726ac0096df4a986681f2961ff4b03a858437c991ae9d4f8511c13792448ecc
6
+ metadata.gz: 166f403c0e9ce2c0bf4610ebc351d3a9960745570370130af4834691af152cb38b84f6d0c1b6cee9df2df6d193e82ff7495e61ff717fdc5ada2ce45de4c7a306
7
+ data.tar.gz: 205aa1afc05ee67941348dcf4db70b49c80129dbf8d41c2a104a68d2fdaf1dcfff7ac5962ad811304074a4796378706d50d9692222145c12c85ea3b40a1c165d
data/doc/CHANGELOG CHANGED
@@ -4,6 +4,10 @@ Redmine UP gem - general functions for plugins (tags, vote, viewing, currency)
4
4
  Copyright (C) 2011-2025 Kirill Bezrukov (RedmineUP)
5
5
  https://www.redmineup.com/
6
6
 
7
+ == 2025-07-08 v1.0.12
8
+
9
+ * Added color to Tag
10
+
7
11
  == 2025-02-04 v1.0.11
8
12
 
9
13
  * Fixed bug with Redmine language settings
@@ -68,7 +68,13 @@ module Redmineup
68
68
  group_by = "#{Tag.table_name}.id, #{Tag.table_name}.name"
69
69
  # group_by << " AND #{having}" unless having.blank?
70
70
 
71
- { :select => "#{Tag.table_name}.id, #{Tag.table_name}.name, COUNT(*) AS count",
71
+ select_condition = if self.column_names.include?('color')
72
+ "#{Tag.table_name}.id, #{Tag.table_name}.name, #{Tag.table_name}.color, COUNT(*) AS count"
73
+ else
74
+ "#{Tag.table_name}.id, #{Tag.table_name}.name, COUNT(*) AS count"
75
+ end
76
+
77
+ { :select => select_condition,
72
78
  :joins => joins.join(" "),
73
79
  :conditions => conditions,
74
80
  :group => group_by,
@@ -44,7 +44,7 @@ module Redmineup
44
44
 
45
45
  # Create the taggable tables
46
46
  # === Options hash:
47
- # * <tt>:table_name</tt> - use a table name other than viewings
47
+ # * <tt>:table_name</tt> - use a table name other than tags
48
48
  # To be used during migration, but can also be used in other places
49
49
  def create_taggable_table(options = {})
50
50
  tag_name_table = options[:tags] || :tags
@@ -73,6 +73,42 @@ module Redmineup
73
73
  end
74
74
  end
75
75
 
76
+ # Create the needed column for up_acts_as_taggable.
77
+ # To be used during migration, but can also be used in other places.
78
+ #
79
+ # Options :name, :type, :default are required
80
+ #
81
+ # By default, a :color: column will be created
82
+ #
83
+ # E.g.: ActiveRecord::Base.add_tags_column(:tags, name: :color, type: :string, default: nil)
84
+ def add_tags_column(table_name = :tags, **options)
85
+ tag_column = options || { name: :color, type: :string, default: nil }
86
+ tag_column.assert_valid_keys(:name, :type, :default)
87
+
88
+ raise ArgumentError, "Table `#{table_name}' not found" unless self.connection.table_exists?(table_name)
89
+
90
+ unless self.connection.column_exists?(table_name, tag_column[:name])
91
+ self.connection.add_column table_name, tag_column[:name], tag_column[:type], default: tag_column[:default]
92
+ self.reset_column_information
93
+ end
94
+ end
95
+
96
+ # Remove the up_acts_as_taggable specific columns
97
+ # To be used during migration, but can also be used in other places
98
+ #
99
+ # E.g.: ActiveRecord::Base.remove_tags_columns(:tags, :color, :color1)
100
+ def remove_tags_columns(table_name = :tags, *columns)
101
+ raise ArgumentError, "Table `#{table_name}' not found" unless self.connection.table_exists?(table_name)
102
+ return if columns.blank?
103
+
104
+ columns.each do |column|
105
+ if self.connection.column_exists?(table_name, column)
106
+ self.connection.remove_column table_name, column
107
+ self.reset_column_information
108
+ end
109
+ end
110
+ end
111
+
76
112
  def drop_taggable_table(options = {})
77
113
  tag_name_table = options[:tags] || :tags
78
114
  if self.connection.table_exists?(tag_name_table)
@@ -1,3 +1,3 @@
1
1
  module Redmineup
2
- VERSION = '1.0.11'
2
+ VERSION = '1.0.12'
3
3
  end
@@ -33,6 +33,16 @@ class TagTest < ActiveSupport::TestCase
33
33
  assert_equal tags(:error).name, tags(:error).to_s
34
34
  end
35
35
 
36
+ def test_color
37
+ tags.each do |tag|
38
+ if ['New feature', 'bug'].include?(tag.name)
39
+ assert_not_nil tag.color
40
+ else
41
+ assert_nil tag.color
42
+ end
43
+ end
44
+ end
45
+
36
46
  def test_tag_is_equal_to_itself
37
47
  tag = tags(:error)
38
48
  assert_equal tag, tag
@@ -3,9 +3,11 @@ error:
3
3
 
4
4
  feature:
5
5
  name: New feature
6
+ color: '#00ff00'
6
7
 
7
8
  bug:
8
9
  name: bug
10
+ color: '#ff0000'
9
11
 
10
12
  question:
11
13
  name: question
@@ -15,7 +15,9 @@ module Redmineup
15
15
  attachments = [attachment]
16
16
  @issue_drop.define_singleton_method(:attachments) { attachments }
17
17
  Attachment.stub(:latest_attach, attachment) do
18
- assert_equal '<p>description with image <img src="mock_url" title="attach_image" alt="attach_image" loading="lazy" /></p>', @strainer.parse_inline_attachments(text, @issue_drop)
18
+ expected_string = '<p>description with image ' \
19
+ '<img src=\'data:image/content_type;base64,to_base64_string\' title="attach_image" alt="attach_image" /></p>'
20
+ assert_equal expected_string, @strainer.parse_inline_attachments(text, @issue_drop)
19
21
  end
20
22
  end
21
23
 
@@ -25,6 +27,8 @@ module Redmineup
25
27
  attachment = Minitest::Mock.new
26
28
  attachment.expect(:url, 'mock_url')
27
29
  attachment.expect(:description, "attach_image")
30
+ attachment.expect(:content_type, "content_type")
31
+ attachment.expect(:to_base64_string, "to_base64_string")
28
32
  attachment
29
33
  end
30
34
  end
data/test/schema.rb CHANGED
@@ -36,6 +36,7 @@ ActiveRecord::Schema.define version: 0 do
36
36
 
37
37
  create_table :tags, force: true do |t|
38
38
  t.string :name
39
+ t.string :color
39
40
  end
40
41
 
41
42
  create_table :taggings, force: true do |t|
@@ -50,6 +51,10 @@ ActiveRecord::Schema.define version: 0 do
50
51
  t.string :language
51
52
  end
52
53
 
54
+ create_table :categories, force: true do |t|
55
+ t.string :name
56
+ end
57
+
53
58
  create_table :issue_relations, force: true do |t|
54
59
  t.integer :issue_from_id
55
60
  t.integer :issue_to_id
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redmineup
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.11
4
+ version: 1.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - RedmineUP
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-30 00:00:00.000000000 Z
11
+ date: 2025-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails