additional_tags 1.0.5 → 1.0.6

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: 74f23c86bdd928603d2740edb89fbecf6061fa559bbd1a030b3221929c81ec70
4
- data.tar.gz: fb2c25b2a00e1ee5530cf677fcd3474280075c0c60d028209240ec933631f71b
3
+ metadata.gz: 05656ef90d3c7c796b1bd3d510f6a349fc77c8b1adbf43ca6135af8e48ca705e
4
+ data.tar.gz: a22552cd9d096d6963dd9349c207da4755b1e3ba1d8dec560d404b3207ee1458
5
5
  SHA512:
6
- metadata.gz: 8a86b18dbebc7599d1afcb2b63edbea742e32825de1693254c5f066c7a12067aee4dec0649d5c5768480b13e830102e380784e0025f91b4a1da690f085b1b3fe
7
- data.tar.gz: 2ccee9443f19a4a5b193cb63dc1a2d0ae6f965a2f2c11c937e3c2066149baa56272329b8ffa087f5f55d1446440da85a3c9e3d5b69b03ea6b5c99c78d72a3885
6
+ metadata.gz: 2eb18bdccf79be5d1f1b4327c11c3c838e434c8737edcfa096d62d61925170e53be4a6ae45fb486e0c5b3a008933dc30e3bd2c36de9db929fe1fb1e71225adf2
7
+ data.tar.gz: 97fd974a51bcdf337c0246cd95c0313639d43aa73f19ac9a81f0f9efa87da0e3c02736970b5c8148566ded5bb3e670a2fb332a03f99d85f59caed219d12410be
@@ -8,7 +8,7 @@ jobs:
8
8
  runs-on: ubuntu-latest
9
9
 
10
10
  steps:
11
- - uses: actions/checkout@v1
11
+ - uses: actions/checkout@v2
12
12
 
13
13
  - name: Install package dependencies
14
14
  run: >
@@ -22,7 +22,7 @@ jobs:
22
22
  - name: Setup Ruby
23
23
  uses: ruby/setup-ruby@v1
24
24
  with:
25
- ruby-version: 3.0
25
+ ruby-version: 3.1
26
26
  bundler-cache: true
27
27
 
28
28
  - name: Setup gems
data/.gitignore CHANGED
@@ -8,3 +8,4 @@ Gemfile.lock
8
8
  .enable_*
9
9
  ._*
10
10
  *.gem
11
+ rails_best_practices_output.html
data/.rubocop.yml CHANGED
@@ -7,6 +7,7 @@ AllCops:
7
7
  TargetRubyVersion: 2.7
8
8
  TargetRailsVersion: 6.1
9
9
  NewCops: enable
10
+ ActiveSupportExtensionsEnabled: true
10
11
 
11
12
  Rails:
12
13
  Enabled: true
@@ -118,17 +119,14 @@ Style/MethodCallWithArgsParentheses:
118
119
  AllowParenthesesInChaining: true
119
120
  EnforcedStyle: omit_parentheses
120
121
 
121
- Style/HashTransformKeys:
122
- Enabled: false
123
-
124
- Style/HashTransformValues:
125
- Enabled: false
126
-
127
122
  Naming/VariableNumber:
128
123
  Enabled: true
129
124
  Exclude:
130
125
  - 'test/**/*'
131
126
 
127
+ Layout/LineContinuationLeadingSpace:
128
+ Enabled: false
129
+
132
130
  # see https://github.com/rubocop/rubocop-rails/issues/578
133
131
  # redmine does not use load_defaults: https://rails.rubystyle.guide/#config-defaults
134
132
  Rails/RedundantPresenceValidationOnBelongsTo:
data/README.md CHANGED
@@ -71,14 +71,14 @@ git clone https://github.com/alphanodes/additionals.git plugins/additionals
71
71
  git clone https://github.com/alphanodes/additional_tags.git plugins/additional_tags
72
72
  ```
73
73
 
74
- ### 2. Install dependencies and migrate database.
74
+ ### 2. Install dependencies and migrate database
75
75
 
76
76
  ```shell
77
77
  bundle install
78
78
  bundle exec rake redmine:plugins:migrate RAILS_ENV=production
79
79
  ```
80
80
 
81
- ### 3. Restart your Redmine web server.
81
+ ### 3. Restart your Redmine web server
82
82
 
83
83
  ## Running tests
84
84
 
@@ -35,8 +35,8 @@ class AdditionalTagsController < ApplicationController
35
35
 
36
36
  def destroy
37
37
  @tags.each do |tag|
38
- tag.reload.destroy
39
- rescue ::ActiveRecord::RecordNotFound
38
+ tag.reload.destroy!
39
+ rescue ::ActiveRecord::RecordNotFound, ::ActiveRecord::RecordNotDestroyed
40
40
  Rails.logger.warn "Tag #{tag} could not be deleted"
41
41
  end
42
42
  redirect_back_or_default @tag_list_path
@@ -54,7 +54,7 @@ class AdditionalTagsController < ApplicationController
54
54
  end
55
55
  else
56
56
  respond_to do |format|
57
- format.html { render action: 'edit' }
57
+ format.html { render :edit }
58
58
  end
59
59
  end
60
60
  end
@@ -18,18 +18,23 @@ module AdditionalTagsWikiHelper
18
18
  render_tags_list sidebar_tags, **options
19
19
  end
20
20
 
21
- def render_wiki_index_title(project, tag = nil)
21
+ def render_wiki_index_title(project: nil, name: nil, tag: nil, title: :label_wiki)
22
22
  if tag.present?
23
- if project.nil?
24
- title = [link_to(l(:label_wiki), wiki_index_path)]
23
+ if project
24
+ t :label_wiki_index_for_tag_html, tag: tag
25
+ else
26
+ title = [link_to(l(title), wiki_index_path)]
25
27
  title << Additionals::LIST_SEPARATOR
26
28
  title << t(:label_wiki_index_for_tag_html, tag: tag)
27
29
  safe_join title, ' '
28
- else
29
- t :label_wiki_index_for_tag_html, tag: tag
30
30
  end
31
+ elsif name.present?
32
+ title = [link_to(l(title), wiki_index_path)]
33
+ title << Additionals::LIST_SEPARATOR
34
+ title << name
35
+ safe_join title, ' '
31
36
  else
32
- l :label_wiki
37
+ l title
33
38
  end
34
39
  end
35
40
  end
@@ -2,11 +2,16 @@
2
2
 
3
3
  class AdditionalTagsRemoveUnusedTagJob < AdditionalTagsJob
4
4
  def perform
5
- # only once a minute to reduce load
6
- cache_key = self.class.to_s
7
- return if Rails.cache.read(cache_key) && !Rails.env.test?
8
-
9
- Rails.cache.write cache_key, true, expires_in: 60
10
- AdditionalTags::Tags.remove_unused_tags
5
+ if Rails.env.test?
6
+ # no cache for testing
7
+ AdditionalTags::Tags.remove_unused_tags
8
+ else
9
+ # only once a minute to reduce load
10
+ cache = ActiveSupport::Cache::MemoryStore.new expires_in: 1.minute
11
+ cache.fetch self.class.to_s do
12
+ AdditionalTags::Tags.remove_unused_tags
13
+ true
14
+ end
15
+ end
11
16
  end
12
17
  end
@@ -20,8 +20,8 @@
20
20
 
21
21
  #edit_tags_form.hidden
22
22
  = form_tag update_url, method: :put do
23
- = render partial: defined?(tags_form) ? tags_form : 'tags_form',
24
- locals: { css_id: defined?(css_id) ? css_id : nil }
23
+ = render defined?(tags_form) ? tags_form : 'tags_form',
24
+ css_id: defined?(css_id) ? css_id : nil
25
25
  '
26
26
  = submit_tag l(:button_save), class: 'button-small'
27
27
  '
@@ -7,12 +7,12 @@ h3 = block_definition[:label]
7
7
  statuses: { true => :closed, false => :open },
8
8
  group_id_is_bool: true
9
9
 
10
- = render partial: 'common/tag_summary_block',
11
- locals: { tags: tags,
12
- entities_label: l(:label_issue_plural),
13
- totals_link: link_to_issue_tags_totals(entries: counts,
14
- project: @project,
15
- open_issues_only: open_issues_only) }
10
+ = render 'common/tag_summary_block',
11
+ tags: tags,
12
+ entities_label: l(:label_issue_plural),
13
+ totals_link: link_to_issue_tags_totals(entries: counts,
14
+ project: @project,
15
+ open_issues_only: open_issues_only)
16
16
 
17
17
  - if RedminePluginKit.true? settings[:with_table_of_values]
18
18
  - if tags.present?
@@ -1,2 +1,2 @@
1
- $('#ajax-modal').html('<%= escape_javascript(render partial: 'issue_tags/edit_modal') %>');
1
+ $('#ajax-modal').html("<%= escape_javascript(render 'issue_tags/edit_modal') %>");
2
2
  showModal('ajax-modal', '600px');
@@ -1,8 +1,8 @@
1
1
  - if AdditionalTags.setting?(:active_issue_tags) && User.current.allowed_to?(:view_issue_tags, issue.project)
2
- = render partial: 'additional_tags/tag_list',
3
- locals: { entry: issue,
4
- show_always: true,
5
- editable: issue.editable?(User.current),
6
- css_id: 'issue_tag_list_show',
7
- update_url: issue_path(issue),
8
- use_colors: AdditionalTags.setting?(:use_colors) }
2
+ = render 'additional_tags/tag_list',
3
+ entry: issue,
4
+ show_always: true,
5
+ editable: issue.editable?(User.current),
6
+ css_id: 'issue_tag_list_show',
7
+ update_url: issue_path(issue),
8
+ use_colors: AdditionalTags.setting?(:use_colors)
@@ -3,5 +3,4 @@
3
3
  div
4
4
  p#issue_tags
5
5
  = label_tag l(:field_tag_list)
6
- = render partial: tags_form,
7
- locals: { project: project }
6
+ = render tags_form, project: project
@@ -1,5 +1,4 @@
1
1
  - if AdditionalTags.setting?(:active_wiki_tags) && User.current.allowed_to?(:add_wiki_tags, @project)
2
2
  p#wiki_tags
3
3
  = label_tag l(:field_tag_list)
4
- = render partial: 'wiki/tags_form',
5
- locals: { project: project, page: page }
4
+ = render 'wiki/tags_form', project: project, page: page
@@ -1,9 +1,9 @@
1
1
  - if AdditionalTags.setting? :active_wiki_tags
2
2
  .wiki-attributes
3
- = render partial: 'additional_tags/tag_list',
4
- locals: { entry: page,
5
- show_always: true,
6
- link_wiki_tag: true,
7
- editable: User.current.allowed_to?(:add_wiki_tags, @project),
8
- update_url: update_tags_project_wiki_page_path(@project, page.title),
9
- use_colors: AdditionalTags.setting?(:use_colors) }
3
+ = render 'additional_tags/tag_list',
4
+ entry: page,
5
+ show_always: true,
6
+ link_wiki_tag: true,
7
+ editable: User.current.allowed_to?(:add_wiki_tags, @project),
8
+ update_url: update_tags_project_wiki_page_path(@project, page.title),
9
+ use_colors: AdditionalTags.setting?(:use_colors)
@@ -2,7 +2,7 @@
2
2
  - if User.current.allowed_to? :edit_wiki_pages, @project
3
3
  = link_to l(:label_wiki_page_new), new_project_wiki_page_path(@project), remote: true, class: 'icon icon-add'
4
4
 
5
- h2 = render_wiki_index_title @project, @tag
5
+ h2 = render_wiki_index_title project: @project, tag: @tag
6
6
 
7
7
  - if @pages.empty?
8
8
  p.nodata = l :label_no_data
@@ -18,4 +18,4 @@ h2 = render_wiki_index_title @project, @tag
18
18
  = link_to page.parent.pretty_title, project_wiki_page_path(@project, page.parent.title)
19
19
 
20
20
  - content_for :sidebar do
21
- = render partial: 'sidebar'
21
+ = render 'sidebar'
@@ -44,7 +44,7 @@ module AdditionalTags
44
44
  subsql = ActsAsTaggableOn::Tagging.joins("INNER JOIN #{quoted_joined_table}" \
45
45
  " ON additional_taggings.taggable_id = #{quoted_joined_table}.#{quoted_target_field}")
46
46
  .where(taggable_type: klass.name)
47
- .where("#{self.class.connection.quote_table_name queried_table_name}.#{quoted_source_field} ="\
47
+ .where("#{self.class.connection.quote_table_name queried_table_name}.#{quoted_source_field} =" \
48
48
  " #{quoted_joined_table}.#{quoted_joined_field}")
49
49
  .select(1)
50
50
 
@@ -41,10 +41,11 @@ module AdditionalTags
41
41
  scope
42
42
  end
43
43
 
44
- def with_tags(tag, project: nil, order: 'title_asc', max_entries: nil)
44
+ def with_tags(tag, project: nil, order: 'title_asc', max_entries: nil, exclude_page: nil)
45
45
  wiki = project&.wiki
46
46
 
47
47
  scope = with_tags_scope wiki: wiki, project: project
48
+ scope = scope.where.not id: exclude_page.id if exclude_page
48
49
  scope = scope.limit max_entries if max_entries
49
50
 
50
51
  tags = Array tag
@@ -2,6 +2,6 @@
2
2
 
3
3
  module AdditionalTags
4
4
  module PluginVersion
5
- VERSION = '1.0.5' unless defined? VERSION
5
+ VERSION = '1.0.6' unless defined? VERSION
6
6
  end
7
7
  end
@@ -49,8 +49,7 @@ module AdditionalTags
49
49
  end
50
50
 
51
51
  def remove_unused_tags
52
- ActsAsTaggableOn::Tag.left_outer_joins(:taggings)
53
- .where(taggings: { id: nil })
52
+ ActsAsTaggableOn::Tag.where.missing(:taggings)
54
53
  .each(&:destroy)
55
54
  end
56
55
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: additional_tags
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - AlphaNodes
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-25 00:00:00.000000000 Z
11
+ date: 2022-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: acts-as-taggable-on