Skip to content

Commit

Permalink
Enhance compatibility with Redmine 6
Browse files Browse the repository at this point in the history
  • Loading branch information
nanego committed Nov 14, 2024
1 parent 967d254 commit 0eabf12
Show file tree
Hide file tree
Showing 32 changed files with 63 additions and 40 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/5_1_2.yml → .github/workflows/5_1_4.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Tests 5.1.2
name: Tests 5.1.4

env:
PLUGIN_NAME: redmine_admin_activity
REDMINE_VERSION: 5.1.2
REDMINE_VERSION: 5.1.4
RAILS_ENV: test

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

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

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

env:
PLUGIN_NAME: redmine_admin_activity
REDMINE_VERSION: 4.2.11
REDMINE_VERSION: 6.0.1
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
2 changes: 1 addition & 1 deletion .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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ To run tests, install the redmine_base_rspec plugin (https://github.com/jbbarth/

|Plugin branch| Redmine Version | Test Status |
|-------------|-----------------|-------------------|
|master | 5.1.2 | [![5.1.2][1]][5] |
|master | 4.2.11 | [![4.2.11][2]][5] |
|master | 5.1.4 | [![5.1.4][1]][5] |
|master | 6.0.1 | [![6.0.1][2]][5] |
|master | master | [![master][4]][5] |

[1]: https://github.com/nanego/redmine_admin_activity/actions/workflows/5_1_2.yml/badge.svg
[2]: https://github.com/nanego/redmine_admin_activity/actions/workflows/4_2_11.yml/badge.svg
[1]: https://github.com/nanego/redmine_admin_activity/actions/workflows/5_1_4.yml/badge.svg
[2]: https://github.com/nanego/redmine_admin_activity/actions/workflows/6_0_1.yml/badge.svg
[4]: https://github.com/nanego/redmine_admin_activity/actions/workflows/master.yml/badge.svg
[5]: https://github.com/nanego/redmine_admin_activity/actions
3 changes: 2 additions & 1 deletion app/models/journal_setting.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class JournalSetting < ActiveRecord::Base
class JournalSetting < ApplicationRecord

belongs_to :user, :optional => false
belongs_to :journalized, :polymorphic => true, :optional => true

Expand Down
7 changes: 7 additions & 0 deletions init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@
# requires_redmine_plugin :redmine_base_rspec, :version_or_higher => '0.0.4' if Rails.env.test?
# requires_redmine_plugin :redmine_base_deface, :version_or_higher => '0.0.1'
end

# Support for Redmine 5
if Redmine::VERSION::MAJOR < 6
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
end
2 changes: 1 addition & 1 deletion lib/redmine_admin_activity/models/custom_field_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def to_s
end
end

class CustomField < ActiveRecord::Base
class CustomField < ApplicationRecord
prepend RedmineAdminActivity::Models::CustomFieldPatch

def self.representative_columns
Expand Down
2 changes: 1 addition & 1 deletion lib/redmine_admin_activity/models/issue_template_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def journalized_deactivation_template(project)
end
end

class IssueTemplate < ActiveRecord::Base
class IssueTemplate < ApplicationRecord
prepend RedmineAdminActivity::Models::IssueTemplatePatch

has_many :template_projects, through: :issue_template_projects, source: :project, before_remove: :journalized_deactivation_template, after_add: :journalized_activation_template
Expand Down
2 changes: 1 addition & 1 deletion lib/redmine_admin_activity/models/member_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def update_project_journal
end
end

class Member < ActiveRecord::Base
class Member < ApplicationRecord
prepend RedmineAdminActivity::Models::MemberPatch

attr_reader :project_journal
Expand Down
2 changes: 1 addition & 1 deletion lib/redmine_admin_activity/models/organization_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def journalize_creation(user)
end
end

class Organization < ActiveRecord::Base
class Organization < ApplicationRecord
prepend RedmineAdminActivity::Models::OrganizationPatch

def self.representative_columns
Expand Down
2 changes: 1 addition & 1 deletion lib/redmine_admin_activity/models/project_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def create_journal
end
end

class Project < ActiveRecord::Base
class Project < ApplicationRecord
prepend RedmineAdminActivity::Models::ProjectPatch

acts_as_watchable
Expand Down
2 changes: 1 addition & 1 deletion lib/redmine_admin_activity/models/version_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def save_previous_version
end
end

class Version < ActiveRecord::Base
class Version < ApplicationRecord
prepend RedmineAdminActivity::Models::VersionPatch

before_update :save_previous_version
Expand Down
5 changes: 3 additions & 2 deletions spec/controllers/custom_field_enumerations_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'spec_helper'
require 'rails_helper'

describe CustomFieldEnumerationsController, type: :controller do
render_views
Expand All @@ -12,7 +12,8 @@
@controller = CustomFieldEnumerationsController.new
@request = ActionDispatch::TestRequest.create
@response = ActionDispatch::TestResponse.new
User.current = nil
User.current = User.find(1)
@request.session = ActionController::TestSession.new
@request.session[:user_id] = 1 #permissions are hard
ProjectCustomField.create(:name => 'field test', field_format: "enumeration")
end
Expand Down
3 changes: 2 additions & 1 deletion spec/controllers/custom_fields_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'spec_helper'
require 'rails_helper'

describe CustomFieldsController, type: :controller do
render_views
Expand All @@ -15,6 +15,7 @@
@request = ActionDispatch::TestRequest.create
@response = ActionDispatch::TestResponse.new
User.current = nil
@request.session = ActionController::TestSession.new
@request.session[:user_id] = 1 #permissions are hard
end

Expand Down
3 changes: 2 additions & 1 deletion spec/controllers/issue_categories_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'spec_helper'
require 'rails_helper'

describe IssueCategoriesController, type: :controller do
render_views
Expand All @@ -12,6 +12,7 @@

before do
User.current = nil
@request.session = ActionController::TestSession.new
@request.session[:user_id] = 2 #permissions are hard
end

Expand Down
3 changes: 2 additions & 1 deletion spec/controllers/issue_templates_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'spec_helper'
require 'rails_helper'

if Redmine::Plugin.installed?(:redmine_templates)
describe IssueTemplatesController, type: :controller do
Expand All @@ -9,6 +9,7 @@

before do
User.current = nil
@request.session = ActionController::TestSession.new
@request.session[:user_id] = 1
end

Expand Down
3 changes: 2 additions & 1 deletion spec/controllers/members_controller_patch_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'spec_helper'
require 'rails_helper'

describe MembersController, type: :controller do
render_views
Expand All @@ -15,6 +15,7 @@
include Redmine::I18n

before do
@request.session = ActionController::TestSession.new
@request.session[:user_id] = 1 #permissions are hard
if Redmine::Plugin.installed?(:redmine_limited_visibility)
member.function_ids = [Function.first.id]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'spec_helper'
require 'rails_helper'

if Redmine::Plugin.installed?(:redmine_organizations)
describe Organizations::MembershipsController, type: :controller do
Expand All @@ -23,6 +23,7 @@

before do
User.current = nil
@request.session = ActionController::TestSession.new
@request.session[:user_id] = 1 # permissions are hard
user.update_attribute(:organization, organization)
new_user.update_attribute(:organization, organization)
Expand Down
3 changes: 2 additions & 1 deletion spec/controllers/organizations_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'spec_helper'
require 'rails_helper'

if Redmine::Plugin.installed?(:redmine_organizations)
describe OrganizationsController, type: :controller do
Expand All @@ -13,6 +13,7 @@
@request = ActionDispatch::TestRequest.create
@response = ActionDispatch::TestResponse.new
User.current = nil
@request.session = ActionController::TestSession.new
@request.session[:user_id] = 1
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'spec_helper'
require 'rails_helper'

describe PrincipalMembershipsController, type: :controller do
render_views
Expand All @@ -15,6 +15,7 @@
include Redmine::I18n

before do
@request.session = ActionController::TestSession.new
@request.session[:user_id] = 1 #permissions are hard
end

Expand Down
3 changes: 2 additions & 1 deletion spec/controllers/projects_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'spec_helper'
require 'rails_helper'

describe ProjectsController, type: :controller do

Expand All @@ -17,6 +17,7 @@
@request = ActionDispatch::TestRequest.create
@response = ActionDispatch::TestResponse.new
User.current = nil
@request.session = ActionController::TestSession.new
@request.session[:user_id] = 2 # permissions are hard
end

Expand Down
3 changes: 2 additions & 1 deletion spec/controllers/settings_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'spec_helper'
require 'rails_helper'

describe SettingsController, type: :controller do

Expand All @@ -11,6 +11,7 @@
@request = ActionDispatch::TestRequest.create
@response = ActionDispatch::TestResponse.new
User.current = nil
@request.session = ActionController::TestSession.new
@request.session[:user_id] = 1 #permissions are hard
end

Expand Down
3 changes: 2 additions & 1 deletion spec/controllers/trackers_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'spec_helper'
require 'rails_helper'

describe TrackersController, type: :controller do
render_views
Expand All @@ -15,6 +15,7 @@
@request = ActionDispatch::TestRequest.create
@response = ActionDispatch::TestResponse.new
User.current = nil
@request.session = ActionController::TestSession.new
@request.session[:user_id] = 1 #permissions are hard
end

Expand Down
3 changes: 2 additions & 1 deletion spec/controllers/users_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'spec_helper'
require 'rails_helper'

describe UsersController, type: :controller do

Expand All @@ -13,6 +13,7 @@
@request = ActionDispatch::TestRequest.create
@response = ActionDispatch::TestResponse.new
User.current = nil
@request.session = ActionController::TestSession.new
@request.session[:user_id] = 1 # permissions admin
end

Expand Down
3 changes: 2 additions & 1 deletion spec/controllers/versions_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'spec_helper'
require 'rails_helper'

describe VersionsController, type: :controller do
render_views
Expand All @@ -15,6 +15,7 @@
@request = ActionDispatch::TestRequest.create
@response = ActionDispatch::TestResponse.new
User.current = nil
@request.session = ActionController::TestSession.new
@request.session[:user_id] = 1 #permissions are hard
end

Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/wiki_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'spec_helper'
require 'rails_helper'

describe WikiController, type: :controller do

Expand All @@ -12,7 +12,7 @@
@controller = WikiController.new
@request = ActionDispatch::TestRequest.create
@response = ActionDispatch::TestResponse.new
User.current = nil
@request.session = ActionController::TestSession.new
@request.session[:user_id] = 1 #permissions are hard
end

Expand Down
2 changes: 1 addition & 1 deletion spec/helpers/issues_helper_patch_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require "spec_helper"
require "rails_helper"

describe "IssuesHelperPatch" do
include ApplicationHelper
Expand Down
2 changes: 1 addition & 1 deletion spec/helpers/journal_settings_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require "spec_helper"
require "rails_helper"

describe "JournalSettingsHelper" do
include ApplicationHelper
Expand Down
3 changes: 2 additions & 1 deletion spec/helpers/projects_helper_patch_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require "spec_helper"
require "rails_helper"

describe ProjectsHelper, :type => :controller do

Expand All @@ -12,6 +12,7 @@
@request = ActionDispatch::TestRequest.create
@response = ActionDispatch::TestResponse.new
User.current = nil
@request.session = ActionController::TestSession.new
@request.session[:user_id] = 3
end

Expand Down
3 changes: 2 additions & 1 deletion spec/helpers/settings_helper_patch_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require "spec_helper"
require "rails_helper"

describe SettingsHelper, :type => :controller do

Expand All @@ -9,6 +9,7 @@
@request = ActionDispatch::TestRequest.create
@response = ActionDispatch::TestResponse.new
User.current = nil
@request.session = ActionController::TestSession.new
@request.session[:user_id] = 1
end

Expand Down
2 changes: 1 addition & 1 deletion spec/models/journal_setting_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require "spec_helper"
require "rails_helper"

RSpec.describe JournalSetting, type: :model do

Expand Down
2 changes: 1 addition & 1 deletion spec/system/activities_system_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require "spec_helper"
require "rails_helper"

RSpec.describe "activities", type: :system do
fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles,
Expand Down

0 comments on commit 0eabf12

Please sign in to comment.