summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/application_system_test_case.rb2
-rw-r--r--test/functional/issues_controller_test.rb4
-rw-r--r--test/helpers/avatars_helper_test.rb12
-rw-r--r--test/helpers/reactions_helper_test.rb12
-rw-r--r--test/unit/lib/redmine/reaction_test.rb20
-rw-r--r--test/unit/reaction_test.rb2
-rw-r--r--test/unit/user_test.rb21
7 files changed, 50 insertions, 23 deletions
diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb
index 040667c39..38d69e7c8 100644
--- a/test/application_system_test_case.rb
+++ b/test/application_system_test_case.rb
@@ -72,8 +72,8 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
# Should not depend on locale since Redmine displays login page
# using default browser locale which depend on system locale for "real" browsers drivers
def log_user(login, password)
+ visit '/my/page'
assert_current_path '/login', :ignore_query => true
- assert_equal '/login', current_path
within('#login-form form') do
fill_in 'username', :with => login
fill_in 'password', :with => password
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb
index b7e0321d4..1230ec1eb 100644
--- a/test/functional/issues_controller_test.rb
+++ b/test/functional/issues_controller_test.rb
@@ -3347,8 +3347,8 @@ class IssuesControllerTest < Redmine::ControllerTest
# The current_user can only see members who belong to projects that the current_user has access to.
# Since the Redmine Admin user does not belong to any projects visible to the current_user,
# the Redmine Admin user's name is not displayed in the reaction user list. Instead, "1 other" is shown.
- assert_select 'a.reaction-button[title=?]', 'Dave Lopper, John Smith, and 1 other' do
- assert_select 'span.icon-label', '3'
+ assert_select 'a.reaction-button[title=?]', 'Dave Lopper and John Smith' do
+ assert_select 'span.icon-label', '2'
end
end
diff --git a/test/helpers/avatars_helper_test.rb b/test/helpers/avatars_helper_test.rb
index f407ae09e..baa64a653 100644
--- a/test/helpers/avatars_helper_test.rb
+++ b/test/helpers/avatars_helper_test.rb
@@ -68,6 +68,18 @@ class AvatarsHelperTest < Redmine::HelperTest
assert_include 'class="gravatar picture"', avatar('jsmith <jsmith@somenet.foo>', :class => 'picture')
end
+ def test_avatar_with_initials
+ with_settings :gravatar_default => 'initials' do
+ assert_include 'initials="RA"', avatar(User.find(1))
+ end
+ end
+
+ def test_avatar_should_reject_initials_if_default_is_not_initials
+ with_settings :gravatar_default => 'identicon' do
+ assert_not_include 'initials="RA"', avatar(User.find(1))
+ end
+ end
+
def test_avatar_disabled
with_settings :gravatar_enabled => '0' do
assert_equal '', avatar(User.find_by_mail('jsmith@somenet.foo'))
diff --git a/test/helpers/reactions_helper_test.rb b/test/helpers/reactions_helper_test.rb
index f3a4e38d8..ab722e3ca 100644
--- a/test/helpers/reactions_helper_test.rb
+++ b/test/helpers/reactions_helper_test.rb
@@ -106,12 +106,10 @@ class ReactionsHelperTest < ActionView::TestCase
assert_select_in result, 'a.reaction-button[title=?]', expected_tooltip
end
- test 'reaction_button displays non-visible users as "X other" in the tooltip' do
+ test 'reaction_button should not count and display non-visible users' do
issue2 = issues(:issues_002)
issue2.reaction_detail = Reaction::Detail.new(
- # The remaining 3 users are non-visible users
- reaction_count: 5,
visible_users: users(:users_002, :users_003)
)
@@ -119,11 +117,10 @@ class ReactionsHelperTest < ActionView::TestCase
reaction_button(issue2)
end
- assert_select_in result, 'a.reaction-button[title=?]', 'John Smith, Dave Lopper, and 3 others'
+ assert_select_in result, 'a.reaction-button[title=?]', 'John Smith and Dave Lopper'
# When all users are non-visible users
issue2.reaction_detail = Reaction::Detail.new(
- reaction_count: 2,
visible_users: []
)
@@ -131,7 +128,10 @@ class ReactionsHelperTest < ActionView::TestCase
reaction_button(issue2)
end
- assert_select_in result, 'a.reaction-button[title=?]', '2 others'
+ assert_select_in result, 'a.reaction-button[title]', false
+ assert_select_in result, 'a.reaction-button' do
+ assert_select 'span.icon-label', '0'
+ end
end
test 'reaction_button formats the tooltip content based on the support.array settings of each locale' do
diff --git a/test/unit/lib/redmine/reaction_test.rb b/test/unit/lib/redmine/reaction_test.rb
index bed4600d0..f3228a3bd 100644
--- a/test/unit/lib/redmine/reaction_test.rb
+++ b/test/unit/lib/redmine/reaction_test.rb
@@ -42,7 +42,6 @@ class Redmine::ReactionTest < ActiveSupport::TestCase
Issue.preload_reaction_details([issue1, issue2])
expected_issue1_reaction_detail = Reaction::Detail.new(
- reaction_count: 3,
visible_users: [users(:users_003), users(:users_002), users(:users_001)],
user_reaction: reactions(:reaction_002)
)
@@ -53,7 +52,6 @@ class Redmine::ReactionTest < ActiveSupport::TestCase
# Even when an object has no reactions, an empty ReactionDetail is set.
assert_equal Reaction::Detail.new(
- reaction_count: 0,
visible_users: [],
user_reaction: nil
), issue2.reaction_detail
@@ -107,7 +105,6 @@ class Redmine::ReactionTest < ActiveSupport::TestCase
assert_nil message7.instance_variable_get(:@reaction_detail)
assert_equal Reaction::Detail.new(
- reaction_count: 1,
visible_users: [users(:users_002)],
user_reaction: reactions(:reaction_009)
), message7.reaction_detail
@@ -122,7 +119,6 @@ class Redmine::ReactionTest < ActiveSupport::TestCase
comment1.load_reaction_detail
assert_equal Reaction::Detail.new(
- reaction_count: 1,
visible_users: [users(:users_002)],
user_reaction: nil
), comment1.reaction_detail
@@ -153,7 +149,7 @@ class Redmine::ReactionTest < ActiveSupport::TestCase
assert_not Redmine::Reaction.visible?(object, user)
end
- test 'writable? returns true for various reactable objects when user is logged in, object is visible, and project is active' do
+ test 'editable? returns true for various reactable objects when user is logged in, object is visible, and project is active' do
reactable_objects = {
issue: issues(:issues_007),
message: messages(:messages_001),
@@ -164,30 +160,30 @@ class Redmine::ReactionTest < ActiveSupport::TestCase
user = users(:users_002)
reactable_objects.each do |type, object|
- assert Redmine::Reaction.writable?(object, user), "Expected writable? to return true for #{type}"
+ assert Redmine::Reaction.editable?(object, user), "Expected editable? to return true for #{type}"
end
end
- test 'writable? returns false when user is not logged in' do
+ test 'editable? returns false when user is not logged in' do
object = issues(:issues_007)
user = User.anonymous
- assert_not Redmine::Reaction.writable?(object, user)
+ assert_not Redmine::Reaction.editable?(object, user)
end
- test 'writable? returns false when project is inactive' do
+ test 'editable? returns false when project is inactive' do
object = issues(:issues_007)
user = users(:users_002)
object.project.update!(status: Project::STATUS_ARCHIVED)
- assert_not Redmine::Reaction.writable?(object, user)
+ assert_not Redmine::Reaction.editable?(object, user)
end
- test 'writable? returns false when project is closed' do
+ test 'editable? returns false when project is closed' do
object = issues(:issues_007)
user = users(:users_002)
object.project.update!(status: Project::STATUS_CLOSED)
- assert_not Redmine::Reaction.writable?(object, user)
+ assert_not Redmine::Reaction.editable?(object, user)
end
end
diff --git a/test/unit/reaction_test.rb b/test/unit/reaction_test.rb
index 2690da351..9b3da0738 100644
--- a/test/unit/reaction_test.rb
+++ b/test/unit/reaction_test.rb
@@ -75,12 +75,10 @@ class ReactionTest < ActiveSupport::TestCase
expected = {
1 => Reaction::Detail.new(
- reaction_count: 3,
visible_users: [users(:users_003), users(:users_002), users(:users_001)],
user_reaction: reactions(:reaction_003)
),
6 => Reaction::Detail.new(
- reaction_count: 1,
visible_users: [users(:users_002)],
user_reaction: nil
)
diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb
index aeae62df8..8474e174b 100644
--- a/test/unit/user_test.rb
+++ b/test/unit/user_test.rb
@@ -589,6 +589,27 @@ class UserTest < ActiveSupport::TestCase
end
end
+ def test_initials_format
+ assert_equal 'JS', @jsmith.initials(:firstname_lastinitial)
+ assert_equal 'SJ', @jsmith.initials(:lastname_comma_firstname)
+ assert_equal 'SJ', @jsmith.initials(:lastname_firstname)
+ assert_equal 'JS', @jsmith.initials(:firstinitial_lastname)
+ assert_equal 'JL', User.new(:firstname => 'Jean-Philippe', :lastname => 'Lang').initials(:firstinitial_lastname)
+ assert_equal 'JS', @jsmith.initials(:undefined_format)
+ end
+
+ def test_initials_should_use_setting_as_default_format
+ with_settings :user_format => :firstname_lastname do
+ assert_equal 'JS', @jsmith.reload.initials
+ end
+ with_settings :user_format => :username do
+ assert_equal 'JS', @jsmith.reload.initials
+ end
+ with_settings :user_format => :lastname do
+ assert_equal 'SM', @jsmith.reload.initials
+ end
+ end
+
def test_lastname_should_accept_255_characters
u = User.first
u.lastname = 'a' * 255