Skip to content

Commit

Permalink
Make the plugin compatible with Redmine 6
Browse files Browse the repository at this point in the history
  • Loading branch information
nanego committed Dec 18, 2024
1 parent 6d1b24f commit 2fa3951
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 34 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/5_1_3.yml → .github/workflows/5_1_5.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Tests 5.1.3
name: Tests 5.1.5

env:
PLUGIN_NAME: redmine_comments
REDMINE_VERSION: 5.1.3
REDMINE_VERSION: 5.1.5
RAILS_ENV: test

on:
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/4_2_11.yml → .github/workflows/6_0_2.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Tests 4.2.11
name: Tests 6.0.2

env:
PLUGIN_NAME: redmine_comments
REDMINE_VERSION: 4.2.11
REDMINE_VERSION: 6.0.2
RAILS_ENV: test

on:
Expand All @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
ruby: ['2.7']
ruby: ['3.3']
db: ['postgres']
fail-fast: false

Expand Down Expand Up @@ -88,12 +88,9 @@ jobs:
- name: Prepare Redmine source
working-directory: redmine
run: |
# TODO Remove the following line when https://www.redmine.org/issues/40551 is fixed
sed -i -e 's/.*mocha.*/ gem "mocha", "2.1.0"/' Gemfile # Fix core tests not compatible with Mocha 2.2.0
sed -i '/rubocop/d' Gemfile
rm -f .rubocop*
cp plugins/redmine_base_rspec/spec/support/database-${{ matrix.db }}.yml config/database.yml
echo 'gem "builder", "~> 3.2.4"' >> Gemfile
- name: Install Ruby dependencies
working-directory: redmine
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
ruby: ['3.2']
ruby: ['3.3']
db: ['postgres']
fail-fast: false

Expand Down Expand Up @@ -88,8 +88,6 @@ jobs:
- name: Prepare Redmine source
working-directory: redmine
run: |
# TODO Remove the following line when https://www.redmine.org/issues/40551 is fixed
sed -i -e 's/.*mocha.*/ gem "mocha", "2.1.0"/' Gemfile # Fix core tests not compatible with Mocha 2.2.0
sed -i '/rubocop/d' Gemfile
rm -f .rubocop*
cp plugins/redmine_base_rspec/spec/support/database-${{ matrix.db }}.yml config/database.yml
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Redmine Comments plugin

This plugin improves private notes in Redmine issues.
You can manage private notes visibility through roles and permissions.
A typical usage for an tech organization is to allow staff users to see/edit comments, but not lambda users.
A typical usage for a tech organization is to allow staff users to see/edit comments, but not lambda users.

The plugin requires Redmine version 2.5.0 or higher.

Expand All @@ -21,11 +21,11 @@ Test status

|Plugin branch| Redmine Version | Test Status |
|-------------|-----------------|-------------------|
|master | 4.2.11 | [![4.2.11][1]][5] |
|master | 5.1.3 | [![5.1.3][2]][5] |
|master | 6.0.2 | [![6.0.2][1]][5] |
|master | 5.1.5 | [![5.1.5][2]][5] |
|master | master | [![master][4]][5] |

[1]: https://github.com/jbbarth/redmine_comments/actions/workflows/4_2_11.yml/badge.svg
[2]: https://github.com/jbbarth/redmine_comments/actions/workflows/5_1_3.yml/badge.svg
[1]: https://github.com/jbbarth/redmine_comments/actions/workflows/6_0_2.yml/badge.svg
[2]: https://github.com/jbbarth/redmine_comments/actions/workflows/5_1_5.yml/badge.svg
[4]: https://github.com/jbbarth/redmine_comments/actions/workflows/master.yml/badge.svg
[5]: https://github.com/jbbarth/redmine_comments/actions
9 changes: 8 additions & 1 deletion init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
description 'Better private notes in issues for staff users'
author 'Jean-Baptiste BARTH'
author_url 'mailto:[email protected]'
version '0.0.2'
version '6.0.2'
url 'https://github.com/jbbarth/redmine_comments'
requires_redmine :version_or_higher => '2.5.0'
requires_redmine_plugin :redmine_base_deface, :version_or_higher => '0.0.1'
Expand All @@ -16,3 +16,10 @@
permission :view_private_notes_from_role_or_function, {}, :read => true, :require => :member
end
end

# Support for Redmine 5
if Redmine::VERSION::MAJOR < 6
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
end
5 changes: 3 additions & 2 deletions lib/redmine_comments/issue_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ module RedmineComments::IssuePatch
# Returns the journals that are visible to user with their index
# Used to display the issue history
def visible_journals_with_index(user = User.current)
result = journals.
includes(:functions, :roles).
result = journals
result = result.includes(:functions) if Redmine::Plugin.installed?(:redmine_limited_visibility)
result = result.includes(:roles).
preload(:details).
preload(:user => :email_address).
reorder(:created_on, :id).to_a
Expand Down
2 changes: 1 addition & 1 deletion lib/redmine_comments/journal_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module RedmineComments::JournalPatch

end

class Journal < ActiveRecord::Base
class Journal < ApplicationRecord
include RedmineComments::JournalPatch

acts_as_attachable
Expand Down
34 changes: 20 additions & 14 deletions spec/system/comments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def log_user(login, password)
fill_in 'password', with: password
find('input[name=login]').click
end
expect(current_path).to eq '/my/page'
expect(page).to have_current_path('/my/page', wait: true)
end

describe "creating new comments", type: :system do
Expand Down Expand Up @@ -48,15 +48,19 @@ def log_user(login, password)
expect {
visit '/issues/1'
click_on "Comment", match: :first

expect(page).to have_css('form#add_issue_comment_form') # Waiting for the form to disappear

within 'form#add_issue_comment_form' do
expect(page).to have_selector(".info", text: "Private comments are only visible with specific roles.")
expect(page).to_not have_selector(".comment_role")
fill_in 'journal[notes]', with: 'Here is a quick note'
click_on 'Add'
end
}.to change(issue.journals, :size).by(1)
expect(page).to have_no_css('form#add_issue_comment_form') # Waiting for the form to disappear
}.to change { issue.journals.reload.size }.by(1)

journal = issue.journals.last
journal = issue.journals.reload.last
expect(journal.private_notes).to be_truthy
expect(journal.notes).to eq 'Here is a quick note'
expect(journal.roles).to be_empty if Redmine::Plugin.installed?(:redmine_limited_visibility)
Expand All @@ -82,7 +86,7 @@ def log_user(login, password)
page.find('.comment_role', text: 'function2').click
click_on 'Add'
end
}.to change(issue.journals, :size).by(1)
}.to change { issue.journals.reload.size }.by(1)

journal = issue.journals.last
expect(journal.private_notes).to be_truthy
Expand All @@ -99,9 +103,9 @@ def log_user(login, password)
journal_ids = []
3.times do |i|
journal = Journal.create(:journalized => issue,
:user => user_jsmith,
:notes => "test#{i + 1}",
:private_notes => true)
:user => user_jsmith,
:notes => "test#{i + 1}",
:private_notes => true)

# set for journal[0] (function1), journal[1] (function2), journal[2] (function3)
journal.function_ids = [i + 1]
Expand All @@ -111,7 +115,7 @@ def log_user(login, password)
visit '/issues/1?tab=notes'

3.times do |i|
click_link('Edit', :href =>"/journals/#{journal_ids.reverse[i]}/edit")
click_link('Edit', :href => "/journals/#{journal_ids.reverse[i]}/edit")
end

# set for the third journal (function1,function2), set for the second journal (function3), set for the first journal (function3, function4)
Expand Down Expand Up @@ -140,28 +144,30 @@ def log_user(login, password)
end
end

it "should add new comment by right click on the comment link to open the form in a new tab" do

it "allows to add a new comment from the form in a new tab" do
expect {
visit 'issue_comments/new?issue_id=1'
fill_in 'journal[notes]', with: 'test comment in a new tab'

click_button 'commit'
}.to change(issue.journals, :size).by(1)

expect(page).to have_current_path('/issues/1', wait: true)
}.to change { issue.journals.reload.size }.by(1)
end

it "Should edit comment by rigth click on the comment link to open the form in a new tab" do
it "allows to right click on the comment link to open the form in a new tab" do
Role.find(1).add_permission!(:edit_issue_notes)
editnote_text = 'test edit comme'
editnote_text = 'test edit comment'

visit 'journals/1/edit'
within 'form#journal-1-form' do
fill_in 'journal[notes]', with: editnote_text
end
click_button 'commit'

expect(journals.find(1).first.notes).to eq editnote_text
expect(page).to have_current_path('/issues/1', wait: true)

expect(Journal.find(1).notes).to eq editnote_text
end

end

0 comments on commit 2fa3951

Please sign in to comment.