summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/issues_controller_test.rb74
-rw-r--r--test/helpers/application_helper_test.rb11
-rw-r--r--test/unit/member_test.rb33
3 files changed, 83 insertions, 35 deletions
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb
index 2ed9ac9ea..1eff9b5d1 100644
--- a/test/functional/issues_controller_test.rb
+++ b/test/functional/issues_controller_test.rb
@@ -2642,18 +2642,47 @@ class IssuesControllerTest < Redmine::ControllerTest
end
def test_show_should_not_display_prev_next_links_for_issue_not_in_query_results
- @request.session[:issue_query] =
- {
- :filters => {
- 'status_id' => {:values => [''], :operator => 'c'}
- },
- :project_id => 1,
- :sort => [['id', 'asc']]
+ @request.session[:issue_query] = {
+ filters: {
+ 'status_id' => {operator: 'o', values: ['']}
+ },
+ project_id: 1,
+ sort: [['id', 'asc']]
+ }
+ get(:show, params: {id: 8})
+
+ assert_response :success
+ assert_select 'a', text: /Previous/, count: 0
+ assert_select 'a', text: /Next/, count: 0
+ end
+
+ def test_show_should_display_prev_next_links_for_issue_not_in_query_when_flash_contains_previous_and_next_issue_ids
+ @request.session[:issue_query] = {
+ filters: {
+ 'status_id' => {operator: 'o', values: ['']}
+ },
+ project_id: 1,
+ sort: [['id', 'asc']]
+ }
+ get(
+ :show,
+ params: { id: 8 }, # The issue#8 is closed
+ flash: {
+ previous_and_next_issue_ids: {
+ prev_issue_id: 7,
+ next_issue_id: 9,
+ issue_position: 7,
+ issue_count: 10
+ }
}
- get(:show, :params => {:id => 1})
+ )
+
assert_response :success
- assert_select 'a', :text => /Previous/, :count => 0
- assert_select 'a', :text => /Next/, :count => 0
+ assert_select 'div.next-prev-links' do
+ assert_select 'a[href="/issues/7"]', text: /Previous/
+ assert_select 'a[href="/issues/9"]', text: /Next/
+ assert_select 'span.position', text: "7 of 10"
+ end
end
def test_show_show_should_display_prev_next_links_with_query_sort_by_user_custom_field
@@ -2684,25 +2713,6 @@ class IssuesControllerTest < Redmine::ControllerTest
end
end
- def test_show_should_display_prev_next_links_when_request_has_previous_and_next_issue_ids_params
- get(
- :show,
- :params => {
- :id => 1,
- :prev_issue_id => 1,
- :next_issue_id => 3,
- :issue_position => 2,
- :issue_count => 4
- }
- )
- assert_response :success
- assert_select 'div.next-prev-links' do
- assert_select 'a[href="/issues/1"]', :text => /Previous/
- assert_select 'a[href="/issues/3"]', :text => /Next/
- assert_select 'span.position', :text => "2 of 4"
- end
- end
-
def test_show_should_display_category_field_if_categories_are_defined
Issue.update_all :category_id => nil
get(:show, :params => {:id => 1})
@@ -6903,7 +6913,11 @@ class IssuesControllerTest < Redmine::ControllerTest
:issue_count => 3
}
)
- assert_redirected_to '/issues/11?issue_count=3&issue_position=2&next_issue_id=12&prev_issue_id=8'
+ assert_redirected_to '/issues/11'
+ assert_equal(
+ { issue_count: '3', issue_position: '2', next_issue_id: '12', prev_issue_id: '8' },
+ flash[:previous_and_next_issue_ids]
+ )
end
def test_update_with_permission_on_tracker_should_be_allowed
diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb
index 31c87daea..573eda42b 100644
--- a/test/helpers/application_helper_test.rb
+++ b/test/helpers/application_helper_test.rb
@@ -1918,11 +1918,12 @@ class ApplicationHelperTest < Redmine::HelperTest
end
def test_thumbnail_tag
- a = Attachment.find(3)
- assert_select_in(
- thumbnail_tag(a),
- 'a[href=?] img[title=?][src=?][loading="lazy"]',
- "/attachments/3", "logo.gif", "/attachments/thumbnail/3/200")
+ attachment = Attachment.find(3)
+ assert_select_in thumbnail_tag(attachment), 'div.thumbnail[title=?]', 'logo.gif' do
+ assert_select 'a[href=?]', '/attachments/3' do
+ assert_select 'img[alt=?][src=?][loading="lazy"]', "logo.gif", "/attachments/thumbnail/3/200"
+ end
+ end
end
def test_link_to_project
diff --git a/test/unit/member_test.rb b/test/unit/member_test.rb
index a7b1843dc..f92841b76 100644
--- a/test/unit/member_test.rb
+++ b/test/unit/member_test.rb
@@ -58,6 +58,39 @@ class MemberTest < ActiveSupport::TestCase
assert_equal 2, @jsmith.reload.roles.size
end
+ def test_update_roles_with_inherited_roles
+ User.current = User.find(1)
+
+ project = Project.find(1)
+ group_a = Group.generate!
+ group_b = Group.generate!
+ test_user = User.generate!
+ group_a.users << test_user
+ group_b.users << test_user
+
+ # Verify that inherited roles are correctly assigned
+ group_a_member = Member.new(project: project, user_id: group_a.id)
+ group_a_member.set_editable_role_ids([1]) # Add Manager role to Group A
+ group_b_member = Member.new(project: project, user_id: group_b.id)
+ group_b_member.set_editable_role_ids([1, 2]) # Add Manager and Developer roles to Group B
+ project.members << [group_a_member, group_b_member]
+ test_user_member = test_user.members.find_by(project_id: project.id)
+ assert_equal [ # [role_id, inherited_from]
+ [1, group_a_member.member_roles.find_by(role_id: 1).id],
+ [1, group_b_member.member_roles.find_by(role_id: 1).id],
+ [2, group_b_member.member_roles.find_by(role_id: 2).id],
+ ], test_user_member.member_roles.map{|r| [r.role_id, r.inherited_from]}
+
+ # Verify that a new non-inherited role is added and inherited roles are maintained
+ test_user_member.set_editable_role_ids([3]) # Add Reporter role to test_user
+ assert_equal [ # [role_id, inherited_from]
+ [1, group_a_member.member_roles.find_by(role_id: 1).id],
+ [1, group_b_member.member_roles.find_by(role_id: 1).id],
+ [2, group_b_member.member_roles.find_by(role_id: 2).id],
+ [3, nil]
+ ], test_user_member.member_roles.map{|r| [r.role_id, r.inherited_from]}
+ end
+
def test_validate
member = Member.new(:project_id => 1, :user_id => 2, :role_ids => [2])
# same use cannot have more than one membership for a project