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 20, 2024
1 parent 77ae6b4 commit 783b94a
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 29 deletions.
2 changes: 1 addition & 1 deletion app/models/issues_organization.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class IssuesOrganization < ActiveRecord::Base
class IssuesOrganization < ApplicationRecord

belongs_to :issue
belongs_to :organization
Expand Down
2 changes: 1 addition & 1 deletion app/models/organization.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Organization < ActiveRecord::Base
class Organization < ApplicationRecord
include Redmine::SafeAttributes

acts_as_nested_set
Expand Down
2 changes: 1 addition & 1 deletion app/models/organization_manager.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class OrganizationManager < ActiveRecord::Base
class OrganizationManager < ApplicationRecord

belongs_to :user
belongs_to :organization
Expand Down
2 changes: 1 addition & 1 deletion app/models/organization_non_member_role.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class OrganizationNonMemberRole < ActiveRecord::Base
class OrganizationNonMemberRole < ApplicationRecord
include Redmine::SafeAttributes

belongs_to :project
Expand Down
2 changes: 1 addition & 1 deletion app/models/organization_notification.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class OrganizationNotification < ActiveRecord::Base
class OrganizationNotification < ApplicationRecord
belongs_to :project
belongs_to :organization
end
2 changes: 1 addition & 1 deletion app/models/organization_role.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class OrganizationRole < ActiveRecord::Base
class OrganizationRole < ApplicationRecord
include Redmine::SafeAttributes

belongs_to :project
Expand Down
2 changes: 1 addition & 1 deletion app/models/organization_team_leader.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class OrganizationTeamLeader < ActiveRecord::Base
class OrganizationTeamLeader < ApplicationRecord

belongs_to :user
belongs_to :organization
Expand Down
2 changes: 1 addition & 1 deletion lib/redmine_organizations/patches/field_format_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ def possible_values_records(custom_field, object = nil)

Redmine::FieldFormat.include RedmineOrganizations::Patches::FieldFormatPatch

class CustomField < ActiveRecord::Base
class CustomField
safe_attributes('direction_only')
end
2 changes: 1 addition & 1 deletion lib/redmine_organizations/patches/issue_patch.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require_dependency "issue"

class Issue < ActiveRecord::Base
class Issue

has_many :issues_organizations, dependent: :destroy
has_many :organizations, through: :issues_organizations
Expand Down
2 changes: 1 addition & 1 deletion lib/redmine_organizations/patches/project_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require_dependency 'principal'
require_dependency 'user'

class Project < ActiveRecord::Base
class Project

has_many :organization_roles, :dependent => :destroy
has_many :organization_notifications
Expand Down
2 changes: 1 addition & 1 deletion lib/redmine_organizations/patches/role_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module RedmineOrganizations::Patches::RolePatch

end

class Role < ActiveRecord::Base
class Role
has_many :organization_roles, :dependent => :destroy
has_many :organization_non_member_roles, :dependent => :destroy
end
2 changes: 0 additions & 2 deletions spec/controllers/admin_menu_patch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

before do
@controller = AdminController.new
@request = ActionDispatch::TestRequest.create
@response = ActionDispatch::TestResponse.new
User.current = nil
@request.session[:user_id] = 1 # admin
end
Expand Down
2 changes: 0 additions & 2 deletions spec/controllers/users_admin_patch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
render_views
before do
@controller = UsersController.new
@request = ActionDispatch::TestRequest.create
@response = ActionDispatch::TestResponse.new
User.current = nil
@request.session[:user_id] = 1 # admin
end
Expand Down
4 changes: 2 additions & 2 deletions spec/models/files_checksums_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ def assert_checksum(expected, filename)
end

it "should ensure project patch file is up to date" do
# 5.1.3 & 4.2.9 checksum (the self.allowed_to_condition method is completely overridden and should be reviewed if this test breaks)
assert_checksum %w(d3b53e9654bfdd6969c69d7ea7852cf8 b8ce67efe695bc2381e56db07a0a889e a11cce5462e20a51064f9a72834ac527), "app/models/project.rb"
# 6.0.1 & 5.1.4 checksum (the self.allowed_to_condition method is completely overridden and should be reviewed if this test breaks)
assert_checksum %w(40b18f67d953eda5041ac5c20233b784 d3b53e9654bfdd6969c69d7ea7852cf8 b8ce67efe695bc2381e56db07a0a889e a11cce5462e20a51064f9a72834ac527), "app/models/project.rb"
end

end
26 changes: 14 additions & 12 deletions spec/models/issue_query_patch_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require "spec_helper"
require "rails_helper"

describe "IssueQueryPatch" do
fixtures :organizations, :users, :roles, :projects, :members, :trackers
Expand All @@ -7,13 +7,15 @@
before do
@org = Organization.create(:name => "Team C")
@user = User.generate!
expect(@user).to be_present
@user.update_attribute(:organization_id, @org.id)
User.current = User.anonymous
end

def find_issues_with_query(query)
def find_issues_ids_with_query(query)
Issue.joins(:status, :tracker, :project, :priority).where(
query.statement
).to_a
).order(:id).pluck(:id)
end

it "Should have updated_by_organization in available_filters" do
Expand All @@ -31,7 +33,7 @@ def find_issues_with_query(query)

query.filters = { filter_name => { :operator => '=', :values => [@org.id.to_s] } }

expect(find_issues_with_query(query).map(&:id).sort).to include(2, 3)
expect(find_issues_ids_with_query(query)).to include(2, 3)
end

it "operator equal ! , one organization" do
Expand All @@ -43,7 +45,7 @@ def find_issues_with_query(query)
filter_name = "updated_by_organization"
query.filters = { filter_name => { :operator => '!', :values => [@org.id.to_s] } }

expect(find_issues_with_query(query).map(&:id).sort).to_not include(2, 3)
expect(find_issues_ids_with_query(query)).to_not include(2, 3)
end

it "operator equal = , multi organizations" do
Expand All @@ -59,7 +61,7 @@ def find_issues_with_query(query)
filter_name = "updated_by_organization"
query.filters = { filter_name => { :operator => '=', :values => [@org.id.to_s, org_test.id.to_s] } }

expect(find_issues_with_query(query).map(&:id).sort).to include(2, 3, 4)
expect(find_issues_ids_with_query(query)).to include(2, 3, 4)
end

it "operator equal ! , multi organizations" do
Expand All @@ -75,23 +77,23 @@ def find_issues_with_query(query)
filter_name = "updated_by_organization"
query.filters = { filter_name => { :operator => '=', :values => [@org.id.to_s, org_test.id.to_s] } }

expect(find_issues_with_query(query).map(&:id).sort).to_not include([2, 3, 4])
expect(find_issues_ids_with_query(query)).to_not include([2, 3, 4])
end

it "Should ignore private notes that are not visible" do
it "ignores private notes that are not visible" do
Journal.create!(:user_id => @user.id, :journalized => Issue.find(2), :notes => 'Notes', :private_notes => true)
Journal.create!(:user_id => @user.id, :journalized => Issue.find(3), :notes => 'Notes')

query = IssueQuery.new(:name => '_')
filter_name = "updated_by_organization"
query.filters = { filter_name => { :operator => '=', :values => [@org.id.to_s] } }

expect(find_issues_with_query(query).map(&:id).sort).to eq([2, 3])
User.current = @user
query.filters = { filter_name => { :operator => '=', :values => [@org.id.to_s] } }
expect(find_issues_ids_with_query(query)).to eq([2, 3])

User.current = User.anonymous
query.filters = { filter_name => { :operator => '=', :values => [@org.id.to_s] } }

expect(find_issues_with_query(query).map(&:id).sort).to eq([3])
expect(find_issues_ids_with_query(query)).to eq([3])
end
end

Expand Down

0 comments on commit 783b94a

Please sign in to comment.