source 'https://rubygems.org'
-gem "rails", "4.1.8"
+gem "rails", "4.2.0"
gem "jquery-rails", "~> 3.1.1"
gem "coderay", "~> 1.1.0"
gem "builder", ">= 3.0.4"
group :test do
gem "minitest"
- gem "mocha", "~> 1.0.0", :require => 'mocha/api'
+ gem "rails-dom-testing"
+ gem "mocha", "~> 1.0.0"
gem "simplecov", "~> 0.9.1", :require => false
# For running UI tests
gem "capybara"
end
end
only_path = options[:only_path].nil? ? true : options[:only_path]
- s = link_to(text, issue_path(issue, :only_path => only_path),
+ s = link_to(text, issue_url(issue, :only_path => only_path),
:class => issue.css_classes, :title => title)
s << h(": #{subject}") if subject
s = h("#{issue.project} - ") + s if options[:project]
# * :download - Force download (default: false)
def link_to_attachment(attachment, options={})
text = options.delete(:text) || attachment.filename
- route_method = options.delete(:download) ? :download_named_attachment_path : :named_attachment_path
+ route_method = options.delete(:download) ? :download_named_attachment_url : :named_attachment_url
html_options = options.slice!(:only_path)
+ options[:only_path] = true unless options.key?(:only_path)
url = send(route_method, attachment, attachment.filename, options)
link_to text, url, html_options
end
def link_to_message(message, options={}, html_options = nil)
link_to(
message.subject.truncate(60),
- board_message_path(message.board_id, message.parent_id || message.id, {
+ board_message_url(message.board_id, message.parent_id || message.id, {
:r => (message.parent_id && message.id),
- :anchor => (message.parent_id ? "message-#{message.id}" : nil)
+ :anchor => (message.parent_id ? "message-#{message.id}" : nil),
+ :only_path => true
}.merge(options)),
html_options
)
if project.archived?
h(project.name)
else
- link_to project.name, project_path(project, options), html_options
+ link_to project.name,
+ project_url(project, {:only_path => true}.merge(options)),
+ html_options
end
end
filename, ext, alt, alttext = $1.downcase, $2, $3, $4
# search for the picture in attachments
if found = Attachment.latest_attach(attachments, filename)
- image_url = download_named_attachment_path(found, found.filename, :only_path => only_path)
+ image_url = download_named_attachment_url(found, found.filename, :only_path => only_path)
desc = found.description.to_s.gsub('"', '')
if !desc.blank? && alttext.blank?
alt = " title=\"#{desc}\" alt=\"#{desc}\""
issue = Issue.visible.find_by_id(oid)
anchor = comment_id ? "note-#{comment_id}" : nil
link = link_to("##{oid}#{comment_suffix}",
- issue_path(issue, :only_path => only_path, :anchor => anchor),
+ issue_url(issue, :only_path => only_path, :anchor => anchor),
:class => issue.css_classes,
:title => "#{issue.subject.truncate(100)} (#{issue.status.name})")
end
when 'document'
if document = Document.visible.find_by_id(oid)
- link = link_to(document.title, document_path(document, :only_path => only_path), :class => 'document')
+ link = link_to(document.title, document_url(document, :only_path => only_path), :class => 'document')
end
when 'version'
if version = Version.visible.find_by_id(oid)
- link = link_to(version.name, version_path(version, :only_path => only_path), :class => 'version')
+ link = link_to(version.name, version_url(version, :only_path => only_path), :class => 'version')
end
when 'message'
if message = Message.visible.find_by_id(oid)
end
when 'forum'
if board = Board.visible.find_by_id(oid)
- link = link_to(board.name, project_board_path(board.project, board, :only_path => only_path), :class => 'board')
+ link = link_to(board.name, project_board_url(board.project, board, :only_path => only_path), :class => 'board')
end
when 'news'
if news = News.visible.find_by_id(oid)
- link = link_to(news.title, news_path(news, :only_path => only_path), :class => 'news')
+ link = link_to(news.title, news_url(news, :only_path => only_path), :class => 'news')
end
when 'project'
if p = Project.visible.find_by_id(oid)
case prefix
when 'document'
if project && document = project.documents.visible.find_by_title(name)
- link = link_to(document.title, document_path(document, :only_path => only_path), :class => 'document')
+ link = link_to(document.title, document_url(document, :only_path => only_path), :class => 'document')
end
when 'version'
if project && version = project.versions.visible.find_by_name(name)
- link = link_to(version.name, version_path(version, :only_path => only_path), :class => 'version')
+ link = link_to(version.name, version_url(version, :only_path => only_path), :class => 'version')
end
when 'forum'
if project && board = project.boards.visible.find_by_name(name)
- link = link_to(board.name, project_board_path(board.project, board, :only_path => only_path), :class => 'board')
+ link = link_to(board.name, project_board_url(board.project, board, :only_path => only_path), :class => 'board')
end
when 'news'
if project && news = project.news.visible.find_by_title(name)
- link = link_to(news.title, news_path(news, :only_path => only_path), :class => 'news')
+ link = link_to(news.title, news_url(news, :only_path => only_path), :class => 'news')
end
when 'commit', 'source', 'export'
if project
attr_protected :id
scope :visible, lambda {|*args|
- includes(:project).
- references(:project).
+ joins(:project).
where(Issue.visible_condition(args.shift || User.current, *args))
}
class JournalDetail < ActiveRecord::Base
belongs_to :journal
- before_save :normalize_values
attr_protected :id
def custom_field
end
end
- private
+ def value=(arg)
+ write_attribute :value, normalize(arg)
+ end
- def normalize_values
- self.value = normalize(value)
- self.old_value = normalize(old_value)
+ def old_value=(arg)
+ write_attribute :old_value, normalize(arg)
end
+ private
+
def normalize(v)
case v
when true
<td class="last_login_on"><%= format_time(user.last_login_on) unless user.last_login_on.nil? %></td>
<td class="buttons">
<%= change_status_link(user) %>
- <%= delete_link user_path(user, :back_url => users_path(params)) unless User.current == user %>
+ <%= delete_link user_path(user, :back_url => request.original_fullpath) unless User.current == user %>
</td>
</tr>
<% end -%>
# Print deprecation notices to stderr and the Rails logger.
config.active_support.deprecation = [:stderr, :log]
- config.secret_token = 'a secret token for running the tests'
+ config.secret_key_base = 'a secret token for running the tests'
+
+ config.active_support.test_order = :random
end
end
end
+# #deliver is deprecated in Rails 4.2
+# Prevents massive deprecation warnings
+module ActionMailer
+ class MessageDelivery < Delegator
+ def deliver
+ deliver_now
+ end
+ end
+end
+
module ActionController
module MimeResponds
class Collector
# TODO: remove it in a later version
def self.session=(*args)
$stderr.puts "Please remove config/initializers/session_store.rb and run `rake generate_secret_token`.\n" +
- "Setting the session secret with ActionController.session= is no longer supported in Rails 3."
+ "Setting the session secret with ActionController.session= is no longer supported."
exit 1
end
end
end
-
-if Rails::VERSION::MAJOR < 4 && RUBY_VERSION >= "2.1"
- module ActiveSupport
- class HashWithIndifferentAccess
- def select(*args, &block)
- dup.tap { |hash| hash.select!(*args, &block) }
- end
-
- def reject(*args, &block)
- dup.tap { |hash| hash.reject!(*args, &block) }
- end
- end
-
- class OrderedHash
- def select(*args, &block)
- dup.tap { |hash| hash.select!(*args, &block) }
- end
-
- def reject(*args, &block)
- dup.tap { |hash| hash.reject!(*args, &block) }
- end
- end
- end
-end
get 'projects/:id/repository/:repository_id/statistics', :to => 'repositories#stats'
get 'projects/:id/repository/:repository_id/graph', :to => 'repositories#graph'
- get 'projects/:id/repository/:repository_id/changes(/*path(.:ext))',
- :to => 'repositories#changes'
+ get 'projects/:id/repository/:repository_id/changes(/*path)',
+ :to => 'repositories#changes',
+ :format => false
get 'projects/:id/repository/:repository_id/revisions/:rev', :to => 'repositories#revision'
get 'projects/:id/repository/:repository_id/revision', :to => 'repositories#revision'
post 'projects/:id/repository/:repository_id/revisions/:rev/issues', :to => 'repositories#add_related_issue'
delete 'projects/:id/repository/:repository_id/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue'
get 'projects/:id/repository/:repository_id/revisions', :to => 'repositories#revisions'
- get 'projects/:id/repository/:repository_id/revisions/:rev/:action(/*path(.:ext))',
+ get 'projects/:id/repository/:repository_id/revisions/:rev/:action(/*path)',
:controller => 'repositories',
:format => false,
:constraints => {
get 'projects/:id/repository/statistics', :to => 'repositories#stats'
get 'projects/:id/repository/graph', :to => 'repositories#graph'
- get 'projects/:id/repository/changes(/*path(.:ext))',
- :to => 'repositories#changes'
+ get 'projects/:id/repository/changes(/*path)',
+ :to => 'repositories#changes',
+ :format => false
get 'projects/:id/repository/revisions', :to => 'repositories#revisions'
get 'projects/:id/repository/revisions/:rev', :to => 'repositories#revision'
get 'projects/:id/repository/revision', :to => 'repositories#revision'
post 'projects/:id/repository/revisions/:rev/issues', :to => 'repositories#add_related_issue'
delete 'projects/:id/repository/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue'
- get 'projects/:id/repository/revisions/:rev/:action(/*path(.:ext))',
+ get 'projects/:id/repository/revisions/:rev/:action(/*path)',
:controller => 'repositories',
:format => false,
:constraints => {
:action => /(browse|show|entry|raw|annotate|diff)/,
:rev => /[a-z0-9\.\-_]+/
}
- get 'projects/:id/repository/:repository_id/:action(/*path(.:ext))',
+ get 'projects/:id/repository/:repository_id/:action(/*path)',
:controller => 'repositories',
- :action => /(browse|show|entry|raw|changes|annotate|diff)/
- get 'projects/:id/repository/:action(/*path(.:ext))',
+ :action => /(browse|show|entry|raw|changes|annotate|diff)/,
+ :format => false
+ get 'projects/:id/repository/:action(/*path)',
:controller => 'repositories',
- :action => /(browse|show|entry|raw|changes|annotate|diff)/
+ :action => /(browse|show|entry|raw|changes|annotate|diff)/,
+ :format => false
get 'projects/:id/repository/:repository_id', :to => 'repositories#show', :path => nil
get 'projects/:id/repository', :to => 'repositories#show', :path => nil
# change this key, all old sessions will become invalid! Make sure the
# secret is at least 30 characters and all random, no regular words or
# you'll be exposed to dictionary attacks.
-RedmineApp::Application.config.secret_token = '#{secret}'
+RedmineApp::Application.config.secret_key_base = '#{secret}'
EOF
end
end
Rake::TestTask.new(:ui => "db:test:prepare") do |t|
t.libs << "test"
t.verbose = true
- t.test_files = FileList['test/ui/**/*_test.rb']
+ t.test_files = FileList['test/ui/**/*_test_ui.rb']
end
Rake::Task['test:ui'].comment = "Run the UI tests with Capybara (PhantomJS listening on port 4444 is required)"
end
+++ /dev/null
-# Redmine - project management software
-# Copyright (C) 2006-2015 Jean-Philippe Lang
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-require File.expand_path('../test_case', __FILE__)
-require 'tmpdir'
-
-class RedminePmTest::RepositoryGitTest < RedminePmTest::TestCase
- fixtures :projects, :users, :members, :roles, :member_roles
-
- GIT_BIN = Redmine::Configuration['scm_git_command'] || "git"
-
- def test_anonymous_read_on_public_repo_with_permission_should_succeed
- assert_success "ls-remote", git_url
- end
-
- def test_anonymous_read_on_public_repo_without_permission_should_fail
- Role.anonymous.remove_permission! :browse_repository
- assert_failure "ls-remote", git_url
- end
-
- def test_invalid_credentials_should_fail
- Project.find(1).update_attribute :is_public, false
- with_credentials "dlopper", "foo" do
- assert_success "ls-remote", git_url
- end
- with_credentials "dlopper", "wrong" do
- assert_failure "ls-remote", git_url
- end
- end
-
- def test_clone
- Dir.mktmpdir do |dir|
- Dir.chdir(dir) do
- assert_success "clone", git_url
- end
- end
- end
-
- def test_write_commands
- Role.find(2).add_permission! :commit_access
- filename = random_filename
-
- Dir.mktmpdir do |dir|
- assert_success "clone", git_url, dir
- Dir.chdir(dir) do
- f = File.new(File.join(dir, filename), "w")
- f.write "test file content"
- f.close
-
- with_credentials "dlopper", "foo" do
- assert_success "add", filename
- assert_success "commit -a --message Committing_a_file"
- assert_success "push", git_url, "--all"
- end
- end
- end
-
- Dir.mktmpdir do |dir|
- assert_success "clone", git_url, dir
- Dir.chdir(dir) do
- assert File.exists?(File.join(dir, "#{filename}"))
- end
- end
- end
-
- protected
-
- def execute(*args)
- a = [GIT_BIN]
- super a, *args
- end
-
- def git_url(path=nil)
- host = ENV['REDMINE_TEST_DAV_SERVER'] || '127.0.0.1'
- credentials = nil
- if username && password
- credentials = "#{username}:#{password}"
- end
- url = "http://#{credentials}@#{host}/git/ecookbook"
- url << "/#{path}" if path
- url
- end
-end
--- /dev/null
+# Redmine - project management software
+# Copyright (C) 2006-2015 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.expand_path('../test_case', __FILE__)
+require 'tmpdir'
+
+class RedminePmTest::RepositoryGitTest < RedminePmTest::TestCase
+ fixtures :projects, :users, :members, :roles, :member_roles
+
+ GIT_BIN = Redmine::Configuration['scm_git_command'] || "git"
+
+ def test_anonymous_read_on_public_repo_with_permission_should_succeed
+ assert_success "ls-remote", git_url
+ end
+
+ def test_anonymous_read_on_public_repo_without_permission_should_fail
+ Role.anonymous.remove_permission! :browse_repository
+ assert_failure "ls-remote", git_url
+ end
+
+ def test_invalid_credentials_should_fail
+ Project.find(1).update_attribute :is_public, false
+ with_credentials "dlopper", "foo" do
+ assert_success "ls-remote", git_url
+ end
+ with_credentials "dlopper", "wrong" do
+ assert_failure "ls-remote", git_url
+ end
+ end
+
+ def test_clone
+ Dir.mktmpdir do |dir|
+ Dir.chdir(dir) do
+ assert_success "clone", git_url
+ end
+ end
+ end
+
+ def test_write_commands
+ Role.find(2).add_permission! :commit_access
+ filename = random_filename
+
+ Dir.mktmpdir do |dir|
+ assert_success "clone", git_url, dir
+ Dir.chdir(dir) do
+ f = File.new(File.join(dir, filename), "w")
+ f.write "test file content"
+ f.close
+
+ with_credentials "dlopper", "foo" do
+ assert_success "add", filename
+ assert_success "commit -a --message Committing_a_file"
+ assert_success "push", git_url, "--all"
+ end
+ end
+ end
+
+ Dir.mktmpdir do |dir|
+ assert_success "clone", git_url, dir
+ Dir.chdir(dir) do
+ assert File.exists?(File.join(dir, "#{filename}"))
+ end
+ end
+ end
+
+ protected
+
+ def execute(*args)
+ a = [GIT_BIN]
+ super a, *args
+ end
+
+ def git_url(path=nil)
+ host = ENV['REDMINE_TEST_DAV_SERVER'] || '127.0.0.1'
+ credentials = nil
+ if username && password
+ credentials = "#{username}:#{password}"
+ end
+ url = "http://#{credentials}@#{host}/git/ecookbook"
+ url << "/#{path}" if path
+ url
+ end
+end
+++ /dev/null
-# Redmine - project management software
-# Copyright (C) 2006-2015 Jean-Philippe Lang
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-require File.expand_path('../test_case', __FILE__)
-require 'tmpdir'
-
-class RedminePmTest::RepositorySubversionTest < RedminePmTest::TestCase
- fixtures :projects, :users, :members, :roles, :member_roles, :auth_sources
-
- SVN_BIN = Redmine::Configuration['scm_subversion_command'] || "svn"
-
- def test_anonymous_read_on_public_repo_with_permission_should_succeed
- assert_success "ls", svn_url
- end
-
- def test_anonymous_read_on_public_repo_with_anonymous_group_permission_should_succeed
- Role.anonymous.remove_permission! :browse_repository
- Member.create!(:project_id => 1, :principal => Group.anonymous, :role_ids => [2])
- assert_success "ls", svn_url
- end
-
- def test_anonymous_read_on_public_repo_without_permission_should_fail
- Role.anonymous.remove_permission! :browse_repository
- assert_failure "ls", svn_url
- end
-
- def test_anonymous_read_on_private_repo_should_fail
- Project.find(1).update_attribute :is_public, false
- assert_failure "ls", svn_url
- end
-
- def test_anonymous_commit_on_public_repo_should_fail
- Role.anonymous.add_permission! :commit_access
- assert_failure "mkdir --message Creating_a_directory", svn_url(random_filename)
- end
-
- def test_anonymous_commit_on_private_repo_should_fail
- Role.anonymous.add_permission! :commit_access
- Project.find(1).update_attribute :is_public, false
- assert_failure "mkdir --message Creating_a_directory", svn_url(random_filename)
- end
-
- def test_non_member_read_on_public_repo_with_permission_should_succeed
- Role.anonymous.remove_permission! :browse_repository
- with_credentials "miscuser8", "foo" do
- assert_success "ls", svn_url
- end
- end
-
- def test_non_member_read_on_public_repo_with_non_member_group_permission_should_succeed
- Role.anonymous.remove_permission! :browse_repository
- Role.non_member.remove_permission! :browse_repository
- Member.create!(:project_id => 1, :principal => Group.non_member, :role_ids => [2])
- with_credentials "miscuser8", "foo" do
- assert_success "ls", svn_url
- end
- end
-
- def test_non_member_read_on_public_repo_without_permission_should_fail
- Role.anonymous.remove_permission! :browse_repository
- Role.non_member.remove_permission! :browse_repository
- with_credentials "miscuser8", "foo" do
- assert_failure "ls", svn_url
- end
- end
-
- def test_non_member_read_on_private_repo_should_fail
- Project.find(1).update_attribute :is_public, false
- with_credentials "miscuser8", "foo" do
- assert_failure "ls", svn_url
- end
- end
-
- def test_non_member_commit_on_public_repo_should_fail
- Role.non_member.add_permission! :commit_access
- assert_failure "mkdir --message Creating_a_directory", svn_url(random_filename)
- end
-
- def test_non_member_commit_on_private_repo_should_fail
- Role.non_member.add_permission! :commit_access
- Project.find(1).update_attribute :is_public, false
- assert_failure "mkdir --message Creating_a_directory", svn_url(random_filename)
- end
-
- def test_member_read_on_public_repo_with_permission_should_succeed
- Role.anonymous.remove_permission! :browse_repository
- Role.non_member.remove_permission! :browse_repository
- with_credentials "dlopper", "foo" do
- assert_success "ls", svn_url
- end
- end
-
- def test_member_read_on_public_repo_without_permission_should_fail
- Role.anonymous.remove_permission! :browse_repository
- Role.non_member.remove_permission! :browse_repository
- Role.find(2).remove_permission! :browse_repository
- with_credentials "dlopper", "foo" do
- assert_failure "ls", svn_url
- end
- end
-
- def test_member_read_on_private_repo_with_permission_should_succeed
- Project.find(1).update_attribute :is_public, false
- with_credentials "dlopper", "foo" do
- assert_success "ls", svn_url
- end
- end
-
- def test_member_read_on_private_repo_without_permission_should_fail
- Role.find(2).remove_permission! :browse_repository
- Project.find(1).update_attribute :is_public, false
- with_credentials "dlopper", "foo" do
- assert_failure "ls", svn_url
- end
- end
-
- def test_member_commit_on_public_repo_with_permission_should_succeed
- Role.find(2).add_permission! :commit_access
- with_credentials "dlopper", "foo" do
- assert_success "mkdir --message Creating_a_directory", svn_url(random_filename)
- end
- end
-
- def test_member_commit_on_public_repo_without_permission_should_fail
- Role.find(2).remove_permission! :commit_access
- with_credentials "dlopper", "foo" do
- assert_failure "mkdir --message Creating_a_directory", svn_url(random_filename)
- end
- end
-
- def test_member_commit_on_private_repo_with_permission_should_succeed
- Role.find(2).add_permission! :commit_access
- Project.find(1).update_attribute :is_public, false
- with_credentials "dlopper", "foo" do
- assert_success "mkdir --message Creating_a_directory", svn_url(random_filename)
- end
- end
-
- def test_member_commit_on_private_repo_without_permission_should_fail
- Role.find(2).remove_permission! :commit_access
- Project.find(1).update_attribute :is_public, false
- with_credentials "dlopper", "foo" do
- assert_failure "mkdir --message Creating_a_directory", svn_url(random_filename)
- end
- end
-
- def test_invalid_credentials_should_fail
- Project.find(1).update_attribute :is_public, false
- with_credentials "dlopper", "foo" do
- assert_success "ls", svn_url
- end
- with_credentials "dlopper", "wrong" do
- assert_failure "ls", svn_url
- end
- end
-
- def test_anonymous_read_should_fail_with_login_required
- assert_success "ls", svn_url
- with_settings :login_required => '1' do
- assert_failure "ls", svn_url
- end
- end
-
- def test_authenticated_read_should_succeed_with_login_required
- with_settings :login_required => '1' do
- with_credentials "miscuser8", "foo" do
- assert_success "ls", svn_url
- end
- end
- end
-
- def test_read_on_archived_projects_should_fail
- Project.find(1).update_attribute :status, Project::STATUS_ARCHIVED
- assert_failure "ls", svn_url
- end
-
- def test_read_on_archived_private_projects_should_fail
- Project.find(1).update_attribute :status, Project::STATUS_ARCHIVED
- Project.find(1).update_attribute :is_public, false
- with_credentials "dlopper", "foo" do
- assert_failure "ls", svn_url
- end
- end
-
- def test_read_on_closed_projects_should_succeed
- Project.find(1).update_attribute :status, Project::STATUS_CLOSED
- assert_success "ls", svn_url
- end
-
- def test_read_on_closed_private_projects_should_succeed
- Project.find(1).update_attribute :status, Project::STATUS_CLOSED
- Project.find(1).update_attribute :is_public, false
- with_credentials "dlopper", "foo" do
- assert_success "ls", svn_url
- end
- end
-
- def test_commit_on_closed_projects_should_fail
- Project.find(1).update_attribute :status, Project::STATUS_CLOSED
- Role.find(2).add_permission! :commit_access
- with_credentials "dlopper", "foo" do
- assert_failure "mkdir --message Creating_a_directory", svn_url(random_filename)
- end
- end
-
- def test_commit_on_closed_private_projects_should_fail
- Project.find(1).update_attribute :status, Project::STATUS_CLOSED
- Project.find(1).update_attribute :is_public, false
- Role.find(2).add_permission! :commit_access
- with_credentials "dlopper", "foo" do
- assert_failure "mkdir --message Creating_a_directory", svn_url(random_filename)
- end
- end
-
- if ldap_configured?
- def test_user_with_ldap_auth_source_should_authenticate_with_ldap_credentials
- ldap_user = User.new(:mail => 'example1@redmine.org', :firstname => 'LDAP', :lastname => 'user', :auth_source_id => 1)
- ldap_user.login = 'example1'
- ldap_user.save!
-
- with_settings :login_required => '1' do
- with_credentials "example1", "123456" do
- assert_success "ls", svn_url
- end
- end
-
- with_settings :login_required => '1' do
- with_credentials "example1", "wrong" do
- assert_failure "ls", svn_url
- end
- end
- end
- end
-
- def test_checkout
- Dir.mktmpdir do |dir|
- assert_success "checkout", svn_url, dir
- end
- end
-
- def test_read_commands
- assert_success "info", svn_url
- assert_success "ls", svn_url
- assert_success "log", svn_url
- end
-
- def test_write_commands
- Role.find(2).add_permission! :commit_access
- filename = random_filename
-
- Dir.mktmpdir do |dir|
- assert_success "checkout", svn_url, dir
- Dir.chdir(dir) do
- # creates a file in the working copy
- f = File.new(File.join(dir, filename), "w")
- f.write "test file content"
- f.close
-
- assert_success "add", filename
- with_credentials "dlopper", "foo" do
- assert_success "commit --message Committing_a_file"
- assert_success "copy --message Copying_a_file", svn_url(filename), svn_url("#{filename}_copy")
- assert_success "delete --message Deleting_a_file", svn_url(filename)
- assert_success "mkdir --message Creating_a_directory", svn_url("#{filename}_dir")
- end
- assert_success "update"
-
- # checks that the working copy was updated
- assert File.exists?(File.join(dir, "#{filename}_copy"))
- assert File.directory?(File.join(dir, "#{filename}_dir"))
- end
- end
- end
-
- def test_read_invalid_repo_should_fail
- assert_failure "ls", svn_url("invalid")
- end
-
- protected
-
- def execute(*args)
- a = [SVN_BIN, "--no-auth-cache --non-interactive"]
- a << "--username #{username}" if username
- a << "--password #{password}" if password
-
- super a, *args
- end
-
- def svn_url(path=nil)
- host = ENV['REDMINE_TEST_DAV_SERVER'] || '127.0.0.1'
- url = "http://#{host}/svn/ecookbook"
- url << "/#{path}" if path
- url
- end
-end
--- /dev/null
+# Redmine - project management software
+# Copyright (C) 2006-2015 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.expand_path('../test_case', __FILE__)
+require 'tmpdir'
+
+class RedminePmTest::RepositorySubversionTest < RedminePmTest::TestCase
+ fixtures :projects, :users, :members, :roles, :member_roles, :auth_sources
+
+ SVN_BIN = Redmine::Configuration['scm_subversion_command'] || "svn"
+
+ def test_anonymous_read_on_public_repo_with_permission_should_succeed
+ assert_success "ls", svn_url
+ end
+
+ def test_anonymous_read_on_public_repo_with_anonymous_group_permission_should_succeed
+ Role.anonymous.remove_permission! :browse_repository
+ Member.create!(:project_id => 1, :principal => Group.anonymous, :role_ids => [2])
+ assert_success "ls", svn_url
+ end
+
+ def test_anonymous_read_on_public_repo_without_permission_should_fail
+ Role.anonymous.remove_permission! :browse_repository
+ assert_failure "ls", svn_url
+ end
+
+ def test_anonymous_read_on_private_repo_should_fail
+ Project.find(1).update_attribute :is_public, false
+ assert_failure "ls", svn_url
+ end
+
+ def test_anonymous_commit_on_public_repo_should_fail
+ Role.anonymous.add_permission! :commit_access
+ assert_failure "mkdir --message Creating_a_directory", svn_url(random_filename)
+ end
+
+ def test_anonymous_commit_on_private_repo_should_fail
+ Role.anonymous.add_permission! :commit_access
+ Project.find(1).update_attribute :is_public, false
+ assert_failure "mkdir --message Creating_a_directory", svn_url(random_filename)
+ end
+
+ def test_non_member_read_on_public_repo_with_permission_should_succeed
+ Role.anonymous.remove_permission! :browse_repository
+ with_credentials "miscuser8", "foo" do
+ assert_success "ls", svn_url
+ end
+ end
+
+ def test_non_member_read_on_public_repo_with_non_member_group_permission_should_succeed
+ Role.anonymous.remove_permission! :browse_repository
+ Role.non_member.remove_permission! :browse_repository
+ Member.create!(:project_id => 1, :principal => Group.non_member, :role_ids => [2])
+ with_credentials "miscuser8", "foo" do
+ assert_success "ls", svn_url
+ end
+ end
+
+ def test_non_member_read_on_public_repo_without_permission_should_fail
+ Role.anonymous.remove_permission! :browse_repository
+ Role.non_member.remove_permission! :browse_repository
+ with_credentials "miscuser8", "foo" do
+ assert_failure "ls", svn_url
+ end
+ end
+
+ def test_non_member_read_on_private_repo_should_fail
+ Project.find(1).update_attribute :is_public, false
+ with_credentials "miscuser8", "foo" do
+ assert_failure "ls", svn_url
+ end
+ end
+
+ def test_non_member_commit_on_public_repo_should_fail
+ Role.non_member.add_permission! :commit_access
+ assert_failure "mkdir --message Creating_a_directory", svn_url(random_filename)
+ end
+
+ def test_non_member_commit_on_private_repo_should_fail
+ Role.non_member.add_permission! :commit_access
+ Project.find(1).update_attribute :is_public, false
+ assert_failure "mkdir --message Creating_a_directory", svn_url(random_filename)
+ end
+
+ def test_member_read_on_public_repo_with_permission_should_succeed
+ Role.anonymous.remove_permission! :browse_repository
+ Role.non_member.remove_permission! :browse_repository
+ with_credentials "dlopper", "foo" do
+ assert_success "ls", svn_url
+ end
+ end
+
+ def test_member_read_on_public_repo_without_permission_should_fail
+ Role.anonymous.remove_permission! :browse_repository
+ Role.non_member.remove_permission! :browse_repository
+ Role.find(2).remove_permission! :browse_repository
+ with_credentials "dlopper", "foo" do
+ assert_failure "ls", svn_url
+ end
+ end
+
+ def test_member_read_on_private_repo_with_permission_should_succeed
+ Project.find(1).update_attribute :is_public, false
+ with_credentials "dlopper", "foo" do
+ assert_success "ls", svn_url
+ end
+ end
+
+ def test_member_read_on_private_repo_without_permission_should_fail
+ Role.find(2).remove_permission! :browse_repository
+ Project.find(1).update_attribute :is_public, false
+ with_credentials "dlopper", "foo" do
+ assert_failure "ls", svn_url
+ end
+ end
+
+ def test_member_commit_on_public_repo_with_permission_should_succeed
+ Role.find(2).add_permission! :commit_access
+ with_credentials "dlopper", "foo" do
+ assert_success "mkdir --message Creating_a_directory", svn_url(random_filename)
+ end
+ end
+
+ def test_member_commit_on_public_repo_without_permission_should_fail
+ Role.find(2).remove_permission! :commit_access
+ with_credentials "dlopper", "foo" do
+ assert_failure "mkdir --message Creating_a_directory", svn_url(random_filename)
+ end
+ end
+
+ def test_member_commit_on_private_repo_with_permission_should_succeed
+ Role.find(2).add_permission! :commit_access
+ Project.find(1).update_attribute :is_public, false
+ with_credentials "dlopper", "foo" do
+ assert_success "mkdir --message Creating_a_directory", svn_url(random_filename)
+ end
+ end
+
+ def test_member_commit_on_private_repo_without_permission_should_fail
+ Role.find(2).remove_permission! :commit_access
+ Project.find(1).update_attribute :is_public, false
+ with_credentials "dlopper", "foo" do
+ assert_failure "mkdir --message Creating_a_directory", svn_url(random_filename)
+ end
+ end
+
+ def test_invalid_credentials_should_fail
+ Project.find(1).update_attribute :is_public, false
+ with_credentials "dlopper", "foo" do
+ assert_success "ls", svn_url
+ end
+ with_credentials "dlopper", "wrong" do
+ assert_failure "ls", svn_url
+ end
+ end
+
+ def test_anonymous_read_should_fail_with_login_required
+ assert_success "ls", svn_url
+ with_settings :login_required => '1' do
+ assert_failure "ls", svn_url
+ end
+ end
+
+ def test_authenticated_read_should_succeed_with_login_required
+ with_settings :login_required => '1' do
+ with_credentials "miscuser8", "foo" do
+ assert_success "ls", svn_url
+ end
+ end
+ end
+
+ def test_read_on_archived_projects_should_fail
+ Project.find(1).update_attribute :status, Project::STATUS_ARCHIVED
+ assert_failure "ls", svn_url
+ end
+
+ def test_read_on_archived_private_projects_should_fail
+ Project.find(1).update_attribute :status, Project::STATUS_ARCHIVED
+ Project.find(1).update_attribute :is_public, false
+ with_credentials "dlopper", "foo" do
+ assert_failure "ls", svn_url
+ end
+ end
+
+ def test_read_on_closed_projects_should_succeed
+ Project.find(1).update_attribute :status, Project::STATUS_CLOSED
+ assert_success "ls", svn_url
+ end
+
+ def test_read_on_closed_private_projects_should_succeed
+ Project.find(1).update_attribute :status, Project::STATUS_CLOSED
+ Project.find(1).update_attribute :is_public, false
+ with_credentials "dlopper", "foo" do
+ assert_success "ls", svn_url
+ end
+ end
+
+ def test_commit_on_closed_projects_should_fail
+ Project.find(1).update_attribute :status, Project::STATUS_CLOSED
+ Role.find(2).add_permission! :commit_access
+ with_credentials "dlopper", "foo" do
+ assert_failure "mkdir --message Creating_a_directory", svn_url(random_filename)
+ end
+ end
+
+ def test_commit_on_closed_private_projects_should_fail
+ Project.find(1).update_attribute :status, Project::STATUS_CLOSED
+ Project.find(1).update_attribute :is_public, false
+ Role.find(2).add_permission! :commit_access
+ with_credentials "dlopper", "foo" do
+ assert_failure "mkdir --message Creating_a_directory", svn_url(random_filename)
+ end
+ end
+
+ if ldap_configured?
+ def test_user_with_ldap_auth_source_should_authenticate_with_ldap_credentials
+ ldap_user = User.new(:mail => 'example1@redmine.org', :firstname => 'LDAP', :lastname => 'user', :auth_source_id => 1)
+ ldap_user.login = 'example1'
+ ldap_user.save!
+
+ with_settings :login_required => '1' do
+ with_credentials "example1", "123456" do
+ assert_success "ls", svn_url
+ end
+ end
+
+ with_settings :login_required => '1' do
+ with_credentials "example1", "wrong" do
+ assert_failure "ls", svn_url
+ end
+ end
+ end
+ end
+
+ def test_checkout
+ Dir.mktmpdir do |dir|
+ assert_success "checkout", svn_url, dir
+ end
+ end
+
+ def test_read_commands
+ assert_success "info", svn_url
+ assert_success "ls", svn_url
+ assert_success "log", svn_url
+ end
+
+ def test_write_commands
+ Role.find(2).add_permission! :commit_access
+ filename = random_filename
+
+ Dir.mktmpdir do |dir|
+ assert_success "checkout", svn_url, dir
+ Dir.chdir(dir) do
+ # creates a file in the working copy
+ f = File.new(File.join(dir, filename), "w")
+ f.write "test file content"
+ f.close
+
+ assert_success "add", filename
+ with_credentials "dlopper", "foo" do
+ assert_success "commit --message Committing_a_file"
+ assert_success "copy --message Copying_a_file", svn_url(filename), svn_url("#{filename}_copy")
+ assert_success "delete --message Deleting_a_file", svn_url(filename)
+ assert_success "mkdir --message Creating_a_directory", svn_url("#{filename}_dir")
+ end
+ assert_success "update"
+
+ # checks that the working copy was updated
+ assert File.exists?(File.join(dir, "#{filename}_copy"))
+ assert File.directory?(File.join(dir, "#{filename}_dir"))
+ end
+ end
+ end
+
+ def test_read_invalid_repo_should_fail
+ assert_failure "ls", svn_url("invalid")
+ end
+
+ protected
+
+ def execute(*args)
+ a = [SVN_BIN, "--no-auth-cache --non-interactive"]
+ a << "--username #{username}" if username
+ a << "--password #{password}" if password
+
+ super a, *args
+ end
+
+ def svn_url(path=nil)
+ host = ENV['REDMINE_TEST_DAV_SERVER'] || '127.0.0.1'
+ url = "http://#{host}/svn/ecookbook"
+ url << "/#{path}" if path
+ url
+ end
+end
assert_template 'common/feed'
assert_select 'feed' do
- assert_select 'link[rel=self][href=?]', 'http://test.host/activity.atom?show_changesets=1&show_documents=1&show_files=1&show_issues=1&show_messages=1&show_news=1&show_time_entries=1&show_wiki_edits=1&with_subprojects=0'
- assert_select 'link[rel=alternate][href=?]', 'http://test.host/activity?show_changesets=1&show_documents=1&show_files=1&show_issues=1&show_messages=1&show_news=1&show_time_entries=1&show_wiki_edits=1&with_subprojects=0'
+ assert_select 'link[rel=self][href=?]', 'http://test.host/activity.atom?show_changesets=1&show_documents=1&show_files=1&show_issues=1&show_messages=1&show_news=1&show_time_entries=1&show_wiki_edits=1&with_subprojects=0'
+ assert_select 'link[rel=alternate][href=?]', 'http://test.host/activity?show_changesets=1&show_documents=1&show_files=1&show_issues=1&show_messages=1&show_news=1&show_time_entries=1&show_wiki_edits=1&with_subprojects=0'
assert_select 'entry' do
assert_select 'link[href=?]', 'http://test.host/issues/11'
end
get :edit, :id => 1
assert_response :success
assert_select 'input[value=secret]', 0
- assert_select 'input[name=dummy_password][value=?]', /x+/
+ assert_select 'input[name=dummy_password][value^=xxxxxx]'
end
def test_edit_invalid_should_respond_with_404
assert_select 'select[name=?]', 'board[parent_id]' do
assert_select 'option', (Project.find(1).boards.size + 1)
- assert_select 'option[value=""]', :text => ' '
+ assert_select 'option[value=""]'
assert_select 'option[value="1"]', :text => 'Help'
end
+
+ # replaced by nokogiri, not easy to test in DOM assertions
+ assert_not_include '<option value=""></option>', response.body
+ assert_include '<option value=""> </option>', response.body
end
def test_new_without_project_boards
assert_select 'a.icon-del[href=?]', '/issues?ids%5B%5D=1', :text => 'Delete'
# Statuses
- assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bstatus_id%5D=5', :text => 'Closed'
- assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bpriority_id%5D=8', :text => 'Immediate'
+ assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bstatus_id%5D=5', :text => 'Closed'
+ assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bpriority_id%5D=8', :text => 'Immediate'
# No inactive priorities
assert_select 'a', :text => /Inactive Priority/, :count => 0
# Versions
- assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bfixed_version_id%5D=3', :text => '2.0'
- assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bfixed_version_id%5D=4', :text => 'eCookbook Subproject 1 - 2.0'
+ assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bfixed_version_id%5D=3', :text => '2.0'
+ assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bfixed_version_id%5D=4', :text => 'eCookbook Subproject 1 - 2.0'
# Assignees
- assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bassigned_to_id%5D=3', :text => 'Dave Lopper'
+ assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bassigned_to_id%5D=3', :text => 'Dave Lopper'
end
def test_context_menu_one_issue_by_anonymous
assert_not_nil assigns(:issues)
assert_equal [1, 2], assigns(:issues).map(&:id).sort
- ids = assigns(:issues).map(&:id).sort.map {|i| "ids%5B%5D=#{i}"}.join('&')
+ ids = assigns(:issues).map(&:id).sort.map {|i| "ids%5B%5D=#{i}"}.join('&')
assert_select 'a.icon-edit[href=?]', "/issues/bulk_edit?#{ids}", :text => 'Edit'
- assert_select 'a.icon-copy[href=?]', "/issues/bulk_edit?copy=1&#{ids}", :text => 'Copy'
+ assert_select 'a.icon-copy[href=?]', "/issues/bulk_edit?copy=1&#{ids}", :text => 'Copy'
assert_select 'a.icon-del[href=?]', "/issues?#{ids}", :text => 'Delete'
- assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bstatus_id%5D=5", :text => 'Closed'
- assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bpriority_id%5D=8", :text => 'Immediate'
- assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bassigned_to_id%5D=3", :text => 'Dave Lopper'
+ assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bstatus_id%5D=5", :text => 'Closed'
+ assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bpriority_id%5D=8", :text => 'Immediate'
+ assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bassigned_to_id%5D=3", :text => 'Dave Lopper'
end
def test_context_menu_multiple_issues_of_different_projects
assert_not_nil assigns(:issues)
assert_equal [1, 2, 6], assigns(:issues).map(&:id).sort
- ids = assigns(:issues).map(&:id).sort.map {|i| "ids%5B%5D=#{i}"}.join('&')
+ ids = assigns(:issues).map(&:id).sort.map {|i| "ids%5B%5D=#{i}"}.join('&')
assert_select 'a.icon-edit[href=?]', "/issues/bulk_edit?#{ids}", :text => 'Edit'
assert_select 'a.icon-del[href=?]', "/issues?#{ids}", :text => 'Delete'
- assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bstatus_id%5D=5", :text => 'Closed'
- assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bpriority_id%5D=8", :text => 'Immediate'
- assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bassigned_to_id%5D=2", :text => 'John Smith'
+ assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bstatus_id%5D=5", :text => 'Closed'
+ assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bpriority_id%5D=8", :text => 'Immediate'
+ assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bassigned_to_id%5D=2", :text => 'John Smith'
end
def test_context_menu_should_include_list_custom_fields
get :issues, :ids => [1]
assert_select "li.cf_#{field.id}" do
- assert_select 'a[href=#]', :text => 'List'
+ assert_select 'a[href="#"]', :text => 'List'
assert_select 'ul' do
assert_select 'a', 3
- assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=Foo", :text => 'Foo'
- assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none'
+ assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=Foo", :text => 'Foo'
+ assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none'
end
end
end
get :issues, :ids => [1, 2]
assert_select "li.cf_#{field.id}" do
- assert_select 'a[href=#]', :text => 'List'
+ assert_select 'a[href="#"]', :text => 'List'
assert_select 'ul' do
assert_select 'a', 2
assert_select 'a', :text => 'none', :count => 0
get :issues, :ids => [1]
assert_select "li.cf_#{field.id}" do
- assert_select 'a[href=#]', :text => 'List'
+ assert_select 'a[href="#"]', :text => 'List'
assert_select 'ul' do
assert_select 'a', 3
assert_select 'a.icon-checked', :text => 'Bar'
get :issues, :ids => [1]
assert_select "li.cf_#{field.id}" do
- assert_select 'a[href=#]', :text => 'Bool'
+ assert_select 'a[href="#"]', :text => 'Bool'
assert_select 'ul' do
assert_select 'a', 3
- assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=0", :text => 'No'
- assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=1", :text => 'Yes'
- assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none'
+ assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=0", :text => 'No'
+ assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=1", :text => 'Yes'
+ assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none'
end
end
end
get :issues, :ids => [1]
assert_select "li.cf_#{field.id}" do
- assert_select 'a[href=#]', :text => 'User'
+ assert_select 'a[href="#"]', :text => 'User'
assert_select 'ul' do
assert_select 'a', Project.find(1).members.count + 1
- assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=2", :text => 'John Smith'
- assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none'
+ assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=2", :text => 'John Smith'
+ assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none'
end
end
end
get :issues, :ids => [1]
assert_select "li.cf_#{field.id}" do
- assert_select 'a[href=#]', :text => 'Version'
+ assert_select 'a[href="#"]', :text => 'Version'
assert_select 'ul' do
assert_select 'a', Project.find(1).shared_versions.count + 1
- assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=3", :text => '2.0'
- assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none'
+ assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=3", :text => '2.0'
+ assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none'
end
end
end
assert_response :success
assert_template 'context_menus/issues'
- assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bassigned_to_id%5D=2', :text => / me /
+ assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bassigned_to_id%5D=2', :text => / me /
end
def test_context_menu_should_propose_shared_versions_for_issues_from_different_projects
get :time_entries, :ids => [1, 2]
assert_response :success
assert_select "li.cf_#{field.id}" do
- assert_select 'a[href=#]', :text => "Field"
+ assert_select 'a[href="#"]', :text => "Field"
assert_select 'ul' do
assert_select 'a', 3
- assert_select 'a[href=?]', "/time_entries/bulk_update?ids%5B%5D=1&ids%5B%5D=2&time_entry%5Bcustom_field_values%5D%5B#{field.id}%5D=foo", :text => 'foo'
- assert_select 'a[href=?]', "/time_entries/bulk_update?ids%5B%5D=1&ids%5B%5D=2&time_entry%5Bcustom_field_values%5D%5B#{field.id}%5D=bar", :text => 'bar'
- assert_select 'a[href=?]', "/time_entries/bulk_update?ids%5B%5D=1&ids%5B%5D=2&time_entry%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none'
+ assert_select 'a[href=?]', "/time_entries/bulk_update?ids%5B%5D=1&ids%5B%5D=2&time_entry%5Bcustom_field_values%5D%5B#{field.id}%5D=foo", :text => 'foo'
+ assert_select 'a[href=?]', "/time_entries/bulk_update?ids%5B%5D=1&ids%5B%5D=2&time_entry%5Bcustom_field_values%5D%5B#{field.id}%5D=bar", :text => 'bar'
+ assert_select 'a[href=?]', "/time_entries/bulk_update?ids%5B%5D=1&ids%5B%5D=2&time_entry%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none'
end
end
end
assert_select 'a.atom[href="/issues.atom"]'
assert_select 'a.csv[href="/issues.csv"]'
assert_select 'a.pdf[href="/issues.pdf"]'
- assert_select 'form#csv-export-form[action=/issues.csv]'
+ assert_select 'form#csv-export-form[action="/issues.csv"]'
end
def test_index_should_not_warn_when_not_exceeding_export_limit
get :index, :set_filter => 1, :c => %w(subject description)
assert_select 'table.issues thead th', 3 # columns: chekbox + id + subject
- assert_select 'td.description[colspan=3]', :text => 'Unable to print recipes'
+ assert_select 'td.description[colspan="3"]', :text => 'Unable to print recipes'
get :index, :set_filter => 1, :c => %w(subject description), :format => 'pdf'
assert_response :success
@request.session[:user_id] = 2
get :show, :id => 1
- assert_select 'form#issue-form[method=post][enctype=multipart/form-data]' do
+ assert_select 'form#issue-form[method=post][enctype="multipart/form-data"]' do
assert_select 'input[type=file][name=?]', 'attachments[dummy][file]'
end
end
@request.session[:user_id] = 2
get :new, :project_id => 1, :tracker_id => 1
- assert_select 'form[id=issue-form][method=post][enctype=multipart/form-data]' do
+ assert_select 'form[id=issue-form][method=post][enctype="multipart/form-data"]' do
assert_select 'input[name=?][type=file]', 'attachments[dummy][file]'
end
end
assert_equal orig.subject, assigns(:issue).subject
assert assigns(:issue).copy?
- assert_select 'form[id=issue-form][action=/projects/ecookbook/issues]' do
+ assert_select 'form[id=issue-form][action="/projects/ecookbook/issues"]' do
assert_select 'select[name=?]', 'issue[project_id]' do
assert_select 'option[value="1"][selected=selected]', :text => 'eCookbook'
assert_select 'option[value="2"]:not([selected])', :text => 'OnlineStore'
assert_not_nil assigns(:issue)
assert assigns(:issue).copy?
- assert_select 'form#issue-form[action=/projects/ecookbook/issues]' do
+ assert_select 'form#issue-form[action="/projects/ecookbook/issues"]' do
assert_select 'select[name=?]', 'issue[project_id]' do
assert_select 'option[value="1"]:not([selected])', :text => 'eCookbook'
assert_select 'option[value="2"][selected=selected]', :text => 'OnlineStore'
assert_select 'option[value="7"][selected=selected]', :text => 'Urgent'
end
- assert_select 'input[name=?][value=2.5]', 'time_entry[hours]'
+ assert_select 'input[name=?][value="2.5"]', 'time_entry[hours]'
assert_select 'select[name=?]', 'time_entry[activity_id]' do
assert_select 'option[value="10"][selected=selected]', :text => 'Development'
end
assert_select 'input[name=?][value=?]', 'time_entry[hours]', '2.5'
assert_select 'input[name=?][value=?]', 'time_entry[comments]', 'should not be added'
assert_select 'select[name=?]', 'time_entry[activity_id]' do
- assert_select 'option[value=?][selected=selected]', TimeEntryActivity.first.id
+ assert_select 'option[value=?][selected=selected]', TimeEntryActivity.first.id.to_s
end
end
end
@fields.each_with_index do |field, i|
if fields.include?(field)
- assert_select "custom_field[id=#{field.id}] value", {:text => "Value#{i}", :count => 1}, "User #{user.id} was not able to view #{field.name} in API"
+ assert_select "custom_field[id=?] value", field.id.to_s, {:text => "Value#{i}", :count => 1}, "User #{user.id} was not able to view #{field.name} in API"
else
- assert_select "custom_field[id=#{field.id}] value", {:text => "Value#{i}", :count => 0}, "User #{user.id} was not able to view #{field.name} in API"
+ assert_select "custom_field[id=?] value", field.id.to_s, {:text => "Value#{i}", :count => 0}, "User #{user.id} was not able to view #{field.name} in API"
end
end
end
get :destroy
assert_response :success
assert_template 'destroy'
- assert_select 'form[action=/my/account/destroy]' do
+ assert_select 'form[action="/my/account/destroy"]' do
assert_select 'input[name=confirm]'
end
end
assert_response :success
assert_template 'diff'
# Line 11 removed
- assert_select 'th.line-num:content(11) ~ td.diff_out', :text => /Display more information/
+ assert_select 'th.line-num:contains(11) ~ td.diff_out', :text => /Display more information/
end
end
assert_select "th.line-num", :text => '1' do
assert_select "+ td.revision" do
assert_select "a", :text => '2'
- assert_select "+ td.author", :text => "test &" do
+ assert_select "+ td.author", :text => "test &" do
assert_select "+ td",
:text => "author escaping test"
end
assert_response :success
assert_template 'committers'
- assert_select 'td:content(dlopper) + td select' do
- assert_select 'option[value="3"][selected=selected]', :text => 'Dave Lopper'
- end
-
- assert_select 'td:content(foo) + td select' do
- assert_select 'option[value=""]'
- assert_select 'option[selected=selected]', 0 # no option selected
- end
+ assert_select 'input[value=dlopper] + select option[value="3"][selected=selected]', :text => 'Dave Lopper'
+ assert_select 'input[value=foo] + select option[selected=selected]', 0 # no option selected
end
def test_post_committers
assert_response :success
assert_template 'diff'
# Line 22 removed
- assert_select 'th.line-num:content(22) ~ td.diff_out', :text => /def remove/
+ assert_select 'th.line-num:contains(22) ~ td.diff_out', :text => /def remove/
end
end
assert_response :success
assert_template 'diff'
# Line 22 removed
- assert_select 'th.line-num:content(22) ~ td.diff_out', :text => /def remove/
+ assert_select 'th.line-num:contains(22) ~ td.diff_out', :text => /def remove/
assert_select 'h2', :text => /2f9c0091/
end
end
assert_response :success
assert_template 'diff'
# Line 22 removed
- assert_select 'th.line-num:content(22) ~ td.diff_out', :text => /def remove/
+ assert_select 'th.line-num:contains(22) ~ td.diff_out', :text => /def remove/
assert_select 'h2', :text => /2f9c0091/
end
end
assert_template 'diff'
if @diff_c_support
# Line 22 removed
- assert_select 'th.line-num:content(22) ~ td.diff_out', :text => /def remove/
+ assert_select 'th.line-num:contains(22) ~ td.diff_out', :text => /def remove/
assert_select 'h2', :text => /4:def6d2f1254a/
end
end
get :index, :q => 'escaped_once'
assert_response :success
assert_select '#search-results' do
- assert_select 'dt.issue a', :text => /<subject>/
- assert_select 'dd', :text => /<description>/
+ assert_select 'dt.issue a', :text => /<subject>/
+ assert_select 'dd', :text => /<description>/
end
end
def test_get_plugin_settings
ActionController::Base.append_view_path(File.join(Rails.root, "test/fixtures/plugins"))
Redmine::Plugin.register :foo do
- settings :partial => "foo_plugin/foo_plugin_settings",
- :default => {'sample_setting' => 'Plugin setting value'}
+ settings :partial => "foo_plugin/foo_plugin_settings"
end
+ Setting.plugin_foo = {'sample_setting' => 'Plugin setting value'}
get :plugin, :id => 'foo'
assert_response :success
assert_select 'form[action=?][method=get]', '/projects/ecookbook/time_entries.csv' do
# filter
assert_select 'input[name=?][value=?]', 'f[]', 'spent_on'
- assert_select 'input[name=?][value=?]', 'op[spent_on]', '>='
+ assert_select 'input[name=?][value=?]', 'op[spent_on]', '>='
assert_select 'input[name=?][value=?]', 'v[spent_on][]', '2007-04-01'
# columns
assert_select 'input[name=?][value=?]', 'c[]', 'spent_on'
get :index
assert_select "#header select" do
- assert_select "option", :text => 'Foo & Bar'
+ assert_select "option", :text => 'Foo & Bar'
end
end
assert_template 'index'
count = WorkflowTransition.where(:role_id => 1, :tracker_id => 2).count
- assert_select 'a[href=?]', '/workflows/edit?role_id=1&tracker_id=2', :content => count.to_s
+ assert_select 'a[href=?]', '/workflows/edit?role_id=1&tracker_id=2', :content => count.to_s
end
def test_get_edit
get '/attachments/7.xml', {}, credentials('jsmith')
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_select 'attachment id:content(7)' do
+ assert_select 'attachment id', :text => '7' do
assert_select '~ filename', :text => 'archive.zip'
assert_select '~ content_url', :text => 'http://www.example.com/attachments/download/7/archive.zip'
end
get '/attachments/16.xml', {}, credentials('jsmith')
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_select 'attachment id:content(16)' do
+ assert_select 'attachment id:contains(16)' do
assert_select '~ thumbnail_url', :text => 'http://www.example.com/attachments/thumbnail/16'
end
end
assert_select 'group' do
assert_select 'users' do
assert_select 'user', Group.find(10).users.count
- assert_select 'user[id=8]'
+ assert_select 'user[id="8"]'
end
end
end
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_select 'issue_statuses[type=array] issue_status id:content(2)' do
+ assert_select 'issue_statuses[type=array] issue_status id', :text => '2' do
assert_select '~ name', :text => 'Assigned'
end
end
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_select 'issue id:content(3)' do
+ assert_select 'issue id', :text => '3' do
assert_select '~ relations relation', 1
assert_select '~ relations relation[id="2"][issue_id="2"][issue_to_id="3"][relation_type=relates]'
end
- assert_select 'issue id:content(1)' do
+ assert_select 'issue id', :text => '1' do
assert_select '~ relations'
assert_select '~ relations relation', 0
end
assert_select 'issue attachments[type=array]' do
assert_select 'attachment', 5
- assert_select 'attachment id:content(4)' do
+ assert_select 'attachment id', :text => '4' do
assert_select '~ filename', :text => 'source.rb'
assert_select '~ content_url', :text => 'http://www.example.com/attachments/download/4/source.rb'
end
issue = Issue.generate_with_descendants!(:project_id => 1)
get "/issues/#{issue.id}.xml?include=children"
- assert_select 'issue children[type=array]' do
- assert_select 'issue', 2
- assert_select 'issue children', 1
+ assert_select 'issue id', :text => issue.id.to_s do
+ assert_select '~ children[type=array] > issue', 2
+ assert_select '~ children[type=array] > issue > children', 1
end
end
assert_select 'issue' do
assert_select 'watchers', Issue.find(1).watchers.count
assert_select 'watchers' do
- assert_select 'user[id=3]'
+ assert_select 'user[id="3"]'
end
end
end
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_select 'memberships[type=array] membership id:content(2)' do
- assert_select '~ user[id=3][name=Dave Lopper]'
- assert_select '~ roles role[id=2][name=Developer]'
+ assert_select 'memberships[type=array] membership id', :text => '2' do
+ assert_select '~ user[id="3"][name="Dave Lopper"]'
+ assert_select '~ roles role[id="2"][name=Developer]'
end
end
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_select 'membership id:content(2)' do
- assert_select '~ user[id=3][name=Dave Lopper]'
- assert_select '~ roles role[id=2][name=Developer]'
+ assert_select 'membership id', :text => '2' do
+ assert_select '~ user[id="3"][name="Dave Lopper"]'
+ assert_select '~ roles role[id="2"][name=Developer]'
end
end
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_select 'issue_categories[type=array] issue_category[id=2][name=Recipes]'
+ assert_select 'issue_categories[type=array] issue_category[id="2"][name=Recipes]'
end
test "GET /projects.xml with include=trackers should return trackers" do
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_select 'trackers[type=array] tracker[id=2][name=Feature request]'
+ assert_select 'trackers[type=array] tracker[id="2"][name="Feature request"]'
end
test "GET /projects.xml with include=enabled_modules should return enabled modules" do
assert_select 'project>id', :text => '1'
assert_select 'project>status', :text => '1'
assert_select 'project>is_public', :text => 'true'
- assert_select 'custom_field[name=Development status]', :text => 'Stable'
+ assert_select 'custom_field[name="Development status"]', :text => 'Stable'
assert_select 'trackers', 0
assert_select 'issue_categories', 0
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_select 'issue_categories[type=array] issue_category[id=2][name=Recipes]'
+ assert_select 'issue_categories[type=array] issue_category[id="2"][name=Recipes]'
end
test "GET /projects/:id.xml with include=trackers should return trackers" do
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_select 'trackers[type=array] tracker[id=2][name=Feature request]'
+ assert_select 'trackers[type=array] tracker[id="2"][name="Feature request"]'
end
test "GET /projects/:id.xml with include=enabled_modules should return enabled modules" do
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_select 'queries[type=array] query id:content(4)' do
+ assert_select 'queries[type=array] query id', :text => '4' do
assert_select '~ name', :text => 'Public query for all projects'
end
end
assert_equal 'application/xml', @response.content_type
assert_equal 3, assigns(:roles).size
- assert_select 'roles[type=array] role id:content(2)' do
+ assert_select 'roles[type=array] role id', :text => '2' do
assert_select '~ name', :text => 'Developer'
end
end
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_select 'trackers[type=array] tracker id:content(2)' do
+ assert_select 'trackers[type=array] tracker id', :text => '2' do
assert_select '~ name', :text => 'Feature request'
end
end
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_select 'versions[type=array] version id:content(2)' do
+ assert_select 'versions[type=array] version id', :text => '2' do
assert_select '~ name', :text => '1.0'
end
end
# Issue view
follow_redirect!
- assert_select 'th:content(Tester:) + td', :text => tester.name
+ assert_select 'th:contains("Tester:") + td', :text => tester.name
assert_select 'select[name=?]', "issue[custom_field_values][#{@field.id}]" do
assert_select 'option', users.size + 1 # +1 for blank value
assert_select 'option[value=?][selected=selected]', tester.id.to_s, :text => tester.name
def test_search_field_outside_project_should_link_to_global_search
get '/'
- assert_select 'div#quick-search form[action=/search]'
+ assert_select 'div#quick-search form[action="/search"]'
end
def test_search_field_inside_project_should_link_to_project_search
get '/projects/ecookbook'
- assert_select 'div#quick-search form[action=/projects/ecookbook/search]'
+ assert_select 'div#quick-search form[action="/projects/ecookbook/search"]'
end
end
class ThemesTest < Redmine::IntegrationTest
def setup
+ Redmine::Themes.rescan
@theme = Redmine::Themes.themes.last
Setting.ui_theme = @theme.id
end
get '/'
assert_response :success
- assert_select "link[rel=stylesheet][href^=/themes/#{@theme.dir}/stylesheets/application.css]"
+ assert_select "link[rel=stylesheet][href^=?]", "/themes/#{@theme.dir}/stylesheets/application.css"
end
def test_without_theme_js
get '/'
assert_response :success
- assert_select "script[src^=/themes/#{@theme.dir}/javascripts/theme.js]", 0
+ assert_select "script[src^=?]", "/themes/#{@theme.dir}/javascripts/theme.js", 0
end
def test_with_theme_js
get '/'
assert_response :success
- assert_select "script[src^=/themes/#{@theme.dir}/javascripts/theme.js]", 1
+ assert_select "script[src^=?]", "/themes/#{@theme.dir}/javascripts/theme.js", 1
ensure
@theme.javascripts.delete 'theme'
end
get '/'
assert_response :success
- assert_select 'link[rel=shortcut icon][href^=/favicon.ico]'
+ assert_select 'link[rel="shortcut icon"][href^="/favicon.ico"]'
end
def test_use_theme_favicon_if_theme_provides_one
get '/'
assert_response :success
- assert_select "link[rel=shortcut icon][href^=/themes/#{@theme.dir}/favicon/a.ico]"
+ assert_select 'link[rel="shortcut icon"][href^=?]', "/themes/#{@theme.dir}/favicon/a.ico"
ensure
@theme.favicons.delete 'a.ico'
end
get '/'
assert_response :success
- assert_select "link[rel=shortcut icon]", 1
- assert_select "link[rel=shortcut icon][href^=/themes/#{@theme.dir}/favicon/b.ico]"
+ assert_select 'link[rel="shortcut icon"]', 1
+ assert_select 'link[rel="shortcut icon"][href^=?]', "/themes/#{@theme.dir}/favicon/b.ico"
ensure
@theme.favicons.delete("b.ico")
@theme.favicons.delete("a.png")
get '/'
assert_response :success
- assert_select "link[rel=stylesheet][href^=/foo/themes/#{@theme.dir}/stylesheets/application.css]"
- assert_select "script[src^=/foo/themes/#{@theme.dir}/javascripts/theme.js]"
- assert_select "link[rel=shortcut icon][href^=/foo/themes/#{@theme.dir}/favicon/a.ico]"
+ assert_select "link[rel=stylesheet][href^=?]", "/foo/themes/#{@theme.dir}/stylesheets/application.css"
+ assert_select "script[src^=?]", "/foo/themes/#{@theme.dir}/javascripts/theme.js"
+ assert_select 'link[rel="shortcut icon"][href^=?]', "/foo/themes/#{@theme.dir}/favicon/a.ico"
ensure
Redmine::Utils.relative_url_root = ''
end
include ObjectHelpers
require 'net/ldap'
+require 'mocha/setup'
class ActionView::TestCase
helper :application
end
def assert_select_in(text, *args, &block)
- d = HTML::Document.new(CGI::unescapeHTML(String.new(text))).root
+ d = Nokogiri::HTML(CGI::unescapeHTML(String.new(text))).root
assert_select(d, *args, &block)
end
+ def assert_select_email(*args, &block)
+ email = ActionMailer::Base.deliveries.last
+ assert_not_nil email
+ html_body = email.parts.detect {|part| part.content_type.include?('text/html')}.try(&:body)
+ assert_not_nil html_body
+ assert_select_in html_body.encoded, *args, &block
+ end
+
def assert_mail_body_match(expected, mail, message=nil)
if expected.is_a?(String)
assert_include expected, mail_body(mail), message
+++ /dev/null
-# Redmine - project management software
-# Copyright (C) 2006-2015 Jean-Philippe Lang
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-require File.expand_path('../base', __FILE__)
-
-class Redmine::UiTest::IssuesTest < Redmine::UiTest::Base
- fixtures :projects, :users, :roles, :members, :member_roles,
- :trackers, :projects_trackers, :enabled_modules, :issue_statuses, :issues,
- :enumerations, :custom_fields, :custom_values, :custom_fields_trackers,
- :watchers
-
- def test_create_issue
- log_user('jsmith', 'jsmith')
- visit '/projects/ecookbook/issues/new'
- within('form#issue-form') do
- select 'Bug', :from => 'Tracker'
- select 'Low', :from => 'Priority'
- fill_in 'Subject', :with => 'new test issue'
- fill_in 'Description', :with => 'new issue'
- select '0 %', :from => 'Done'
- fill_in 'Due date', :with => ''
- fill_in 'Searchable field', :with => 'Value for field 2'
- # click_button 'Create' would match both 'Create' and 'Create and continue' buttons
- find('input[name=commit]').click
- end
-
- # find created issue
- issue = Issue.find_by_subject("new test issue")
- assert_kind_of Issue, issue
-
- # check redirection
- find 'div#flash_notice', :visible => true, :text => "Issue \##{issue.id} created."
- assert_equal issue_path(:id => issue), current_path
-
- # check issue attributes
- assert_equal 'jsmith', issue.author.login
- assert_equal 1, issue.project.id
- assert_equal IssueStatus.find_by_name('New'), issue.status
- assert_equal Tracker.find_by_name('Bug'), issue.tracker
- assert_equal IssuePriority.find_by_name('Low'), issue.priority
- assert_equal 'Value for field 2', issue.custom_field_value(CustomField.find_by_name('Searchable field'))
- end
-
- def test_create_issue_with_form_update
- field1 = IssueCustomField.create!(
- :field_format => 'string',
- :name => 'Field1',
- :is_for_all => true,
- :trackers => Tracker.where(:id => [1, 2])
- )
- field2 = IssueCustomField.create!(
- :field_format => 'string',
- :name => 'Field2',
- :is_for_all => true,
- :trackers => Tracker.where(:id => 2)
- )
-
- Role.non_member.add_permission! :add_issues
- Role.non_member.remove_permission! :edit_issues, :add_issue_notes
-
- log_user('someone', 'foo')
- visit '/projects/ecookbook/issues/new'
- assert page.has_no_content?(field2.name)
- assert page.has_content?(field1.name)
-
- fill_in 'Subject', :with => 'New test issue'
- fill_in 'Description', :with => 'New test issue description'
- fill_in field1.name, :with => 'CF1 value'
- select 'Low', :from => 'Priority'
-
- # field2 should show up when changing tracker
- select 'Feature request', :from => 'Tracker'
- assert page.has_content?(field2.name)
- assert page.has_content?(field1.name)
-
- fill_in field2.name, :with => 'CF2 value'
- assert_difference 'Issue.count' do
- page.first(:button, 'Create').click
- end
-
- issue = Issue.order('id desc').first
- assert_equal 'New test issue', issue.subject
- assert_equal 'New test issue description', issue.description
- assert_equal 'Low', issue.priority.name
- assert_equal 'CF1 value', issue.custom_field_value(field1)
- assert_equal 'CF2 value', issue.custom_field_value(field2)
- end
-
- def test_create_issue_with_watchers
- user = User.generate!(:firstname => 'Some', :lastname => 'Watcher')
- assert_equal 'Some Watcher', user.name
- log_user('jsmith', 'jsmith')
- visit '/projects/ecookbook/issues/new'
- fill_in 'Subject', :with => 'Issue with watchers'
- # Add a project member as watcher
- check 'Dave Lopper'
- # Search for another user
- assert page.has_no_css?('form#new-watcher-form')
- assert page.has_no_content?('Some Watcher')
- click_link 'Search for watchers to add'
- within('form#new-watcher-form') do
- fill_in 'user_search', :with => 'watch'
- assert page.has_content?('Some Watcher')
- check 'Some Watcher'
- click_button 'Add'
- end
- assert page.has_css?('form#issue-form')
- assert page.has_css?('p#watchers_form')
- using_wait_time(30) do
- within('span#watchers_inputs') do
- within("label#issue_watcher_user_ids_#{user.id}") do
- assert has_content?('Some Watcher'), "No watcher content"
- end
- end
- end
- assert_difference 'Issue.count' do
- find('input[name=commit]').click
- end
-
- issue = Issue.order('id desc').first
- assert_equal ['Dave Lopper', 'Some Watcher'], issue.watcher_users.map(&:name).sort
- end
-
- def test_create_issue_start_due_date
- with_settings :default_issue_start_date_to_creation_date => 0 do
- log_user('jsmith', 'jsmith')
- visit '/projects/ecookbook/issues/new'
- assert_equal "", page.find('input#issue_start_date').value
- assert_equal "", page.find('input#issue_due_date').value
- page.first('p#start_date_area img').click
- page.first("td.ui-datepicker-days-cell-over a").click
- assert_equal Date.today.to_s, page.find('input#issue_start_date').value
- page.first('p#due_date_area img').click
- page.first("td.ui-datepicker-days-cell-over a").click
- assert_equal Date.today.to_s, page.find('input#issue_due_date').value
- end
- end
-
- def test_create_issue_start_due_date_default
- log_user('jsmith', 'jsmith')
- visit '/projects/ecookbook/issues/new'
- fill_in 'Start date', :with => '2012-04-01'
- fill_in 'Due date', :with => ''
- page.first('p#due_date_area img').click
- page.first("td.ui-datepicker-days-cell-over a").click
- assert_equal '2012-04-01', page.find('input#issue_due_date').value
-
- fill_in 'Start date', :with => ''
- fill_in 'Due date', :with => '2012-04-01'
- page.first('p#start_date_area img').click
- page.first("td.ui-datepicker-days-cell-over a").click
- assert_equal '2012-04-01', page.find('input#issue_start_date').value
- end
-
- def test_preview_issue_description
- log_user('jsmith', 'jsmith')
- visit '/projects/ecookbook/issues/new'
- within('form#issue-form') do
- fill_in 'Subject', :with => 'new issue subject'
- fill_in 'Description', :with => 'new issue description'
- click_link 'Preview'
- end
- find 'div#preview fieldset', :visible => true, :text => 'new issue description'
- assert_difference 'Issue.count' do
- find('input[name=commit]').click
- end
-
- issue = Issue.order('id desc').first
- assert_equal 'new issue description', issue.description
- end
-
- def test_update_issue_with_form_update
- field = IssueCustomField.create!(
- :field_format => 'string',
- :name => 'Form update CF',
- :is_for_all => true,
- :trackers => Tracker.where(:name => 'Feature request')
- )
-
- Role.non_member.add_permission! :edit_issues
- Role.non_member.remove_permission! :add_issues, :add_issue_notes
-
- log_user('someone', 'foo')
- visit '/issues/1'
- assert page.has_no_content?('Form update CF')
-
- page.first(:link, 'Edit').click
- # the custom field should show up when changing tracker
- select 'Feature request', :from => 'Tracker'
- assert page.has_content?('Form update CF')
-
- fill_in 'Form update', :with => 'CF value'
- assert_no_difference 'Issue.count' do
- page.first(:button, 'Submit').click
- end
-
- issue = Issue.find(1)
- assert_equal 'CF value', issue.custom_field_value(field)
- end
-
- def test_remove_issue_watcher_from_sidebar
- user = User.find(3)
- Watcher.create!(:watchable => Issue.find(1), :user => user)
-
- log_user('jsmith', 'jsmith')
- visit '/issues/1'
- assert page.first('#sidebar').has_content?('Watchers (1)')
- assert page.first('#sidebar').has_content?(user.name)
- assert_difference 'Watcher.count', -1 do
- page.first('ul.watchers .user-3 a.delete').click
- assert page.first('#sidebar').has_content?('Watchers (0)')
- end
- assert page.first('#sidebar').has_no_content?(user.name)
- end
-
- def test_watch_issue_via_context_menu
- log_user('jsmith', 'jsmith')
- visit '/issues'
- assert page.has_css?('tr#issue-1')
- find('tr#issue-1 td.updated_on').click
- page.execute_script "$('tr#issue-1 td.updated_on').trigger('contextmenu');"
- assert_difference 'Watcher.count' do
- within('#context-menu') do
- click_link 'Watch'
- end
- # wait for ajax response
- assert page.has_css?('#context-menu .issue-1-watcher.icon-fav')
- assert page.has_css?('tr#issue-1')
- end
- assert Issue.find(1).watched_by?(User.find_by_login('jsmith'))
- end
-
- def test_bulk_watch_issues_via_context_menu
- log_user('jsmith', 'jsmith')
- visit '/issues'
- assert page.has_css?('tr#issue-1')
- assert page.has_css?('tr#issue-4')
- find('tr#issue-1 input[type=checkbox]').click
- find('tr#issue-4 input[type=checkbox]').click
- page.execute_script "$('tr#issue-1 td.updated_on').trigger('contextmenu');"
- assert_difference 'Watcher.count', 2 do
- within('#context-menu') do
- click_link 'Watch'
- end
- # wait for ajax response
- assert page.has_css?('#context-menu .issue-bulk-watcher.icon-fav')
- assert page.has_css?('tr#issue-1')
- assert page.has_css?('tr#issue-4')
- end
- assert Issue.find(1).watched_by?(User.find_by_login('jsmith'))
- assert Issue.find(4).watched_by?(User.find_by_login('jsmith'))
- end
-end
--- /dev/null
+# Redmine - project management software
+# Copyright (C) 2006-2015 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.expand_path('../base', __FILE__)
+
+class Redmine::UiTest::IssuesTest < Redmine::UiTest::Base
+ fixtures :projects, :users, :roles, :members, :member_roles,
+ :trackers, :projects_trackers, :enabled_modules, :issue_statuses, :issues,
+ :enumerations, :custom_fields, :custom_values, :custom_fields_trackers,
+ :watchers
+
+ def test_create_issue
+ log_user('jsmith', 'jsmith')
+ visit '/projects/ecookbook/issues/new'
+ within('form#issue-form') do
+ select 'Bug', :from => 'Tracker'
+ select 'Low', :from => 'Priority'
+ fill_in 'Subject', :with => 'new test issue'
+ fill_in 'Description', :with => 'new issue'
+ select '0 %', :from => 'Done'
+ fill_in 'Due date', :with => ''
+ fill_in 'Searchable field', :with => 'Value for field 2'
+ # click_button 'Create' would match both 'Create' and 'Create and continue' buttons
+ find('input[name=commit]').click
+ end
+
+ # find created issue
+ issue = Issue.find_by_subject("new test issue")
+ assert_kind_of Issue, issue
+
+ # check redirection
+ find 'div#flash_notice', :visible => true, :text => "Issue \##{issue.id} created."
+ assert_equal issue_path(:id => issue), current_path
+
+ # check issue attributes
+ assert_equal 'jsmith', issue.author.login
+ assert_equal 1, issue.project.id
+ assert_equal IssueStatus.find_by_name('New'), issue.status
+ assert_equal Tracker.find_by_name('Bug'), issue.tracker
+ assert_equal IssuePriority.find_by_name('Low'), issue.priority
+ assert_equal 'Value for field 2', issue.custom_field_value(CustomField.find_by_name('Searchable field'))
+ end
+
+ def test_create_issue_with_form_update
+ field1 = IssueCustomField.create!(
+ :field_format => 'string',
+ :name => 'Field1',
+ :is_for_all => true,
+ :trackers => Tracker.where(:id => [1, 2])
+ )
+ field2 = IssueCustomField.create!(
+ :field_format => 'string',
+ :name => 'Field2',
+ :is_for_all => true,
+ :trackers => Tracker.where(:id => 2)
+ )
+
+ Role.non_member.add_permission! :add_issues
+ Role.non_member.remove_permission! :edit_issues, :add_issue_notes
+
+ log_user('someone', 'foo')
+ visit '/projects/ecookbook/issues/new'
+ assert page.has_no_content?(field2.name)
+ assert page.has_content?(field1.name)
+
+ fill_in 'Subject', :with => 'New test issue'
+ fill_in 'Description', :with => 'New test issue description'
+ fill_in field1.name, :with => 'CF1 value'
+ select 'Low', :from => 'Priority'
+
+ # field2 should show up when changing tracker
+ select 'Feature request', :from => 'Tracker'
+ assert page.has_content?(field2.name)
+ assert page.has_content?(field1.name)
+
+ fill_in field2.name, :with => 'CF2 value'
+ assert_difference 'Issue.count' do
+ page.first(:button, 'Create').click
+ end
+
+ issue = Issue.order('id desc').first
+ assert_equal 'New test issue', issue.subject
+ assert_equal 'New test issue description', issue.description
+ assert_equal 'Low', issue.priority.name
+ assert_equal 'CF1 value', issue.custom_field_value(field1)
+ assert_equal 'CF2 value', issue.custom_field_value(field2)
+ end
+
+ def test_create_issue_with_watchers
+ user = User.generate!(:firstname => 'Some', :lastname => 'Watcher')
+ assert_equal 'Some Watcher', user.name
+ log_user('jsmith', 'jsmith')
+ visit '/projects/ecookbook/issues/new'
+ fill_in 'Subject', :with => 'Issue with watchers'
+ # Add a project member as watcher
+ check 'Dave Lopper'
+ # Search for another user
+ assert page.has_no_css?('form#new-watcher-form')
+ assert page.has_no_content?('Some Watcher')
+ click_link 'Search for watchers to add'
+ within('form#new-watcher-form') do
+ fill_in 'user_search', :with => 'watch'
+ assert page.has_content?('Some Watcher')
+ check 'Some Watcher'
+ click_button 'Add'
+ end
+ assert page.has_css?('form#issue-form')
+ assert page.has_css?('p#watchers_form')
+ using_wait_time(30) do
+ within('span#watchers_inputs') do
+ within("label#issue_watcher_user_ids_#{user.id}") do
+ assert has_content?('Some Watcher'), "No watcher content"
+ end
+ end
+ end
+ assert_difference 'Issue.count' do
+ find('input[name=commit]').click
+ end
+
+ issue = Issue.order('id desc').first
+ assert_equal ['Dave Lopper', 'Some Watcher'], issue.watcher_users.map(&:name).sort
+ end
+
+ def test_create_issue_start_due_date
+ with_settings :default_issue_start_date_to_creation_date => 0 do
+ log_user('jsmith', 'jsmith')
+ visit '/projects/ecookbook/issues/new'
+ assert_equal "", page.find('input#issue_start_date').value
+ assert_equal "", page.find('input#issue_due_date').value
+ page.first('p#start_date_area img').click
+ page.first("td.ui-datepicker-days-cell-over a").click
+ assert_equal Date.today.to_s, page.find('input#issue_start_date').value
+ page.first('p#due_date_area img').click
+ page.first("td.ui-datepicker-days-cell-over a").click
+ assert_equal Date.today.to_s, page.find('input#issue_due_date').value
+ end
+ end
+
+ def test_create_issue_start_due_date_default
+ log_user('jsmith', 'jsmith')
+ visit '/projects/ecookbook/issues/new'
+ fill_in 'Start date', :with => '2012-04-01'
+ fill_in 'Due date', :with => ''
+ page.first('p#due_date_area img').click
+ page.first("td.ui-datepicker-days-cell-over a").click
+ assert_equal '2012-04-01', page.find('input#issue_due_date').value
+
+ fill_in 'Start date', :with => ''
+ fill_in 'Due date', :with => '2012-04-01'
+ page.first('p#start_date_area img').click
+ page.first("td.ui-datepicker-days-cell-over a").click
+ assert_equal '2012-04-01', page.find('input#issue_start_date').value
+ end
+
+ def test_preview_issue_description
+ log_user('jsmith', 'jsmith')
+ visit '/projects/ecookbook/issues/new'
+ within('form#issue-form') do
+ fill_in 'Subject', :with => 'new issue subject'
+ fill_in 'Description', :with => 'new issue description'
+ click_link 'Preview'
+ end
+ find 'div#preview fieldset', :visible => true, :text => 'new issue description'
+ assert_difference 'Issue.count' do
+ find('input[name=commit]').click
+ end
+
+ issue = Issue.order('id desc').first
+ assert_equal 'new issue description', issue.description
+ end
+
+ def test_update_issue_with_form_update
+ field = IssueCustomField.create!(
+ :field_format => 'string',
+ :name => 'Form update CF',
+ :is_for_all => true,
+ :trackers => Tracker.where(:name => 'Feature request')
+ )
+
+ Role.non_member.add_permission! :edit_issues
+ Role.non_member.remove_permission! :add_issues, :add_issue_notes
+
+ log_user('someone', 'foo')
+ visit '/issues/1'
+ assert page.has_no_content?('Form update CF')
+
+ page.first(:link, 'Edit').click
+ # the custom field should show up when changing tracker
+ select 'Feature request', :from => 'Tracker'
+ assert page.has_content?('Form update CF')
+
+ fill_in 'Form update', :with => 'CF value'
+ assert_no_difference 'Issue.count' do
+ page.first(:button, 'Submit').click
+ end
+
+ issue = Issue.find(1)
+ assert_equal 'CF value', issue.custom_field_value(field)
+ end
+
+ def test_remove_issue_watcher_from_sidebar
+ user = User.find(3)
+ Watcher.create!(:watchable => Issue.find(1), :user => user)
+
+ log_user('jsmith', 'jsmith')
+ visit '/issues/1'
+ assert page.first('#sidebar').has_content?('Watchers (1)')
+ assert page.first('#sidebar').has_content?(user.name)
+ assert_difference 'Watcher.count', -1 do
+ page.first('ul.watchers .user-3 a.delete').click
+ assert page.first('#sidebar').has_content?('Watchers (0)')
+ end
+ assert page.first('#sidebar').has_no_content?(user.name)
+ end
+
+ def test_watch_issue_via_context_menu
+ log_user('jsmith', 'jsmith')
+ visit '/issues'
+ assert page.has_css?('tr#issue-1')
+ find('tr#issue-1 td.updated_on').click
+ page.execute_script "$('tr#issue-1 td.updated_on').trigger('contextmenu');"
+ assert_difference 'Watcher.count' do
+ within('#context-menu') do
+ click_link 'Watch'
+ end
+ # wait for ajax response
+ assert page.has_css?('#context-menu .issue-1-watcher.icon-fav')
+ assert page.has_css?('tr#issue-1')
+ end
+ assert Issue.find(1).watched_by?(User.find_by_login('jsmith'))
+ end
+
+ def test_bulk_watch_issues_via_context_menu
+ log_user('jsmith', 'jsmith')
+ visit '/issues'
+ assert page.has_css?('tr#issue-1')
+ assert page.has_css?('tr#issue-4')
+ find('tr#issue-1 input[type=checkbox]').click
+ find('tr#issue-4 input[type=checkbox]').click
+ page.execute_script "$('tr#issue-1 td.updated_on').trigger('contextmenu');"
+ assert_difference 'Watcher.count', 2 do
+ within('#context-menu') do
+ click_link 'Watch'
+ end
+ # wait for ajax response
+ assert page.has_css?('#context-menu .issue-bulk-watcher.icon-fav')
+ assert page.has_css?('tr#issue-1')
+ assert page.has_css?('tr#issue-4')
+ end
+ assert Issue.find(1).watched_by?(User.find_by_login('jsmith'))
+ assert Issue.find(4).watched_by?(User.find_by_login('jsmith'))
+ end
+end
result = textilizable(raw, :edit_section_links => {:controller => 'wiki', :action => 'edit', :project_id => '1', :id => 'Test'}).gsub("\n", "")
# heading that contains inline code
- assert_match Regexp.new('<div class="contextual" id="section-4" title="Edit this section">' +
- '<a href="/projects/1/wiki/Test/edit\?section=4"><img alt="Edit" src="/images/edit.png(\?\d+)?" /></a></div>' +
+ assert_match Regexp.new('<div class="contextual" title="Edit this section" id="section-4">' +
+ '<a href="/projects/1/wiki/Test/edit\?section=4"><img src="/images/edit.png(\?\d+)?" alt="Edit" /></a></div>' +
'<a name="Subtitle-with-inline-code"></a>' +
'<h2 >Subtitle with <code>inline code</code><a href="#Subtitle-with-inline-code" class="wiki-anchor">¶</a></h2>'),
result
# last heading
- assert_match Regexp.new('<div class="contextual" id="section-5" title="Edit this section">' +
- '<a href="/projects/1/wiki/Test/edit\?section=5"><img alt="Edit" src="/images/edit.png(\?\d+)?" /></a></div>' +
+ assert_match Regexp.new('<div class="contextual" title="Edit this section" id="section-5">' +
+ '<a href="/projects/1/wiki/Test/edit\?section=5"><img src="/images/edit.png(\?\d+)?" alt="Edit" /></a></div>' +
'<a name="Subtitle-after-pre-tag"></a>' +
'<h2 >Subtitle after pre tag<a href="#Subtitle-after-pre-tag" class="wiki-anchor">¶</a></h2>'),
result
def test_thumbnail_tag
a = Attachment.find(3)
- assert_equal '<a href="/attachments/3/logo.gif" title="logo.gif"><img alt="3" src="/attachments/thumbnail/3" /></a>',
- thumbnail_tag(a)
+ assert_select_in thumbnail_tag(a),
+ 'a[href=?][title=?] img[alt="3"][src=?]',
+ "/attachments/3/logo.gif", "logo.gif", "/attachments/thumbnail/3"
end
def test_link_to_project
group = Group.generate!
result = render_principals_for_new_group_users(group)
- assert_select_in result, 'input[name=?][value=2]', 'user_ids[]'
+ assert_select_in result, 'input[name=?][value="2"]', 'user_ids[]'
end
def test_render_principals_for_new_group_users_with_limited_results_should_paginate
project = Project.generate!
result = render_principals_for_new_members(project)
- assert_select_in result, 'input[name=?][value=2]', 'membership[user_ids][]'
+ assert_select_in result, 'input[name=?][value="2"]', 'membership[user_ids][]'
end
def test_render_principals_for_new_members_with_limited_results_should_paginate
def test_link_to_version_within_project
@project = Project.find(2)
User.current = User.find(1)
- assert_equal '<a href="/versions/5" title="07/01/2006">Alpha</a>', link_to_version(Version.find(5))
+ assert_equal '<a title="07/01/2006" href="/versions/5">Alpha</a>', link_to_version(Version.find(5))
end
def test_link_to_version
User.current = User.find(1)
- assert_equal '<a href="/versions/5" title="07/01/2006">Alpha</a>', link_to_version(Version.find(5))
+ assert_equal '<a title="07/01/2006" href="/versions/5">Alpha</a>', link_to_version(Version.find(5))
end
def test_link_to_version_without_effective_date
setup_subjects
@output_buffer = @gantt.subjects
assert_select "div.project-name a", /#{@project.name}/
- assert_select "div.project-name[style*=left:4px]"
+ assert_select 'div.project-name[style*="left:4px"]'
end
test "#subjects version should be rendered" do
setup_subjects
@output_buffer = @gantt.subjects
assert_select "div.version-name a", /#{@version.name}/
- assert_select "div.version-name[style*=left:24px]"
+ assert_select 'div.version-name[style*="left:24px"]'
end
test "#subjects version without assigned issues should not be rendered" do
setup_subjects
@output_buffer = @gantt.subjects
assert_select "div.issue-subject", /#{@issue.subject}/
- assert_select "div.issue-subject[style*=left:44px]"
+ assert_select 'div.issue-subject[style*="left:44px"]'
end
test "#subjects issue assigned to a shared version of another project should be rendered" do
)
@output_buffer = @gantt.subjects
# parent task 44px
- assert_select "div.issue-subject[style*=left:44px]", /#{@issue.subject}/
+ assert_select 'div.issue-subject[style*="left:44px"]', /#{@issue.subject}/
# children 64px
- assert_select "div.issue-subject[style*=left:64px]", /child1/
- assert_select "div.issue-subject[style*=left:64px]", /child2/
+ assert_select 'div.issue-subject[style*="left:64px"]', /child1/
+ assert_select 'div.issue-subject[style*="left:64px"]', /child2/
# grandchild 84px
- assert_select "div.issue-subject[style*=left:84px]", /grandchild/, @output_buffer
+ assert_select 'div.issue-subject[style*="left:84px"]', /grandchild/, @output_buffer
end
test "#lines" do
test "#subject should use the indent option to move the div to the right" do
create_gantt
@output_buffer = @gantt.subject('subject', :format => :html, :indent => 40)
- assert_select "div[style*=left:40]"
+ assert_select 'div[style*="left:40"]'
end
test "#line_for_project" do
test "#line todo line should start from the starting point on the left" do
create_gantt
@output_buffer = @gantt.line(today - 7, today + 7, 30, false, 'line', :format => :html, :zoom => 4)
- assert_select "div.task_todo[style*=left:28px]", 1
+ assert_select 'div.task_todo[style*="left:28px"]', 1
end
test "#line todo line should be the total width" do
create_gantt
@output_buffer = @gantt.line(today - 7, today + 7, 30, false, 'line', :format => :html, :zoom => 4)
- assert_select "div.task_todo[style*=width:58px]", 1
+ assert_select 'div.task_todo[style*="width:58px"]', 1
end
test "#line late line should start from the starting point on the left" do
create_gantt
@output_buffer = @gantt.line(today - 7, today + 7, 30, false, 'line', :format => :html, :zoom => 4)
- assert_select "div.task_late[style*=left:28px]", 1
+ assert_select 'div.task_late[style*="left:28px"]', 1
end
test "#line late line should be the total delayed width" do
create_gantt
@output_buffer = @gantt.line(today - 7, today + 7, 30, false, 'line', :format => :html, :zoom => 4)
- assert_select "div.task_late[style*=width:30px]", 1
+ assert_select 'div.task_late[style*="width:30px"]', 1
end
test "#line done line should start from the starting point on the left" do
create_gantt
@output_buffer = @gantt.line(today - 7, today + 7, 30, false, 'line', :format => :html, :zoom => 4)
- assert_select "div.task_done[style*=left:28px]", 1
+ assert_select 'div.task_done[style*="left:28px"]', 1
end
test "#line done line should be the width for the done ratio" do
create_gantt
@output_buffer = @gantt.line(today - 7, today + 7, 30, false, 'line', :format => :html, :zoom => 4)
# 15 days * 4 px * 30% - 2 px for borders = 16 px
- assert_select "div.task_done[style*=width:16px]", 1
+ assert_select 'div.task_done[style*="width:16px"]', 1
end
test "#line done line should be the total width for 100% done ratio" do
create_gantt
@output_buffer = @gantt.line(today - 7, today + 7, 100, false, 'line', :format => :html, :zoom => 4)
# 15 days * 4 px - 2 px for borders = 58 px
- assert_select "div.task_done[style*=width:58px]", 1
+ assert_select 'div.task_done[style*="width:58px"]', 1
end
test "#line done line should be the total width for 100% done ratio with same start and end dates" do
create_gantt
@output_buffer = @gantt.line(today + 7, today + 7, 100, false, 'line', :format => :html, :zoom => 4)
- assert_select "div.task_done[style*=width:2px]", 1
+ assert_select 'div.task_done[style*="width:2px"]', 1
end
test "#line done line should not be the total done width if the gantt starts after start date" do
create_gantt
@output_buffer = @gantt.line(today - 16, today - 2, 30, false, 'line', :format => :html, :zoom => 4)
- assert_select "div.task_done[style*=left:0px]", 1
- assert_select "div.task_done[style*=width:8px]", 1
+ assert_select 'div.task_done[style*="left:0px"]', 1
+ assert_select 'div.task_done[style*="width:8px"]', 1
end
test "#line starting marker should appear at the start date" do
create_gantt
@output_buffer = @gantt.line(today - 7, today + 7, 30, true, 'line', :format => :html, :zoom => 4)
assert_select "div.starting", 1
- assert_select "div.starting[style*=left:28px]", 1
+ assert_select 'div.starting[style*="left:28px"]', 1
end
test "#line starting marker should not appear if the start date is before gantt start date" do
create_gantt
@output_buffer = @gantt.line(today - 7, today + 7, 30, true, 'line', :format => :html, :zoom => 4)
assert_select "div.ending", 1
- assert_select "div.ending[style*=left:88px]", 1
+ assert_select 'div.ending[style*="left:88px"]', 1
end
test "#line ending marker should not appear if the end date is before gantt start date" do
node = Redmine::MenuManager::MenuItem.new(:testing, :issues_path)
@output_buffer = render_menu_node(node, nil)
- assert_select "a[href=/issues]", "Testing"
+ assert_select 'a[href="/issues"]', "Testing"
end
def test_render_menu_node_with_symbol_as_url_and_project
node = Redmine::MenuManager::MenuItem.new(:testing, :project_issues_path)
@output_buffer = render_menu_node(node, Project.find(1))
- assert_select "a[href=/projects/ecookbook/issues]", "Testing"
+ assert_select 'a[href="/projects/ecookbook/issues"]', "Testing"
end
def test_render_menu_node_with_nested_items
class MailerTest < ActiveSupport::TestCase
include Redmine::I18n
- include ActionDispatch::Assertions::SelectorAssertions
+ include Rails::Dom::Testing::Assertions
fixtures :projects, :enabled_modules, :issues, :users, :email_addresses, :members,
:member_roles, :roles, :documents, :attachments, :news,
:tokens, :journals, :journal_details, :changesets,
# link to a changeset
assert_select 'a[href=?][title=?]',
'https://mydomain.foo/projects/ecookbook/repository/revisions/2',
- 'This commit fixes #1, #2 and references #1 & #3',
+ 'This commit fixes #1, #2 and references #1 & #3',
:text => 'r2'
# link to a description diff
- assert_select 'a[href=?][title=?]',
- 'https://mydomain.foo/journals/diff/3?detail_id=4',
+ assert_select 'a[href^=?][title=?]',
+ # should be https://mydomain.foo/journals/diff/3?detail_id=4
+ # but the Rails 4.2 DOM assertion doesn't handle the ? in the
+ # attribute value
+ 'https://mydomain.foo/journals/diff/3',
'View differences',
:text => 'diff'
# link to an attachment
# link to a changeset
assert_select 'a[href=?][title=?]',
'http://mydomain.foo/rdm/projects/ecookbook/repository/revisions/2',
- 'This commit fixes #1, #2 and references #1 & #3',
+ 'This commit fixes #1, #2 and references #1 & #3',
:text => 'r2'
# link to a description diff
- assert_select 'a[href=?][title=?]',
- 'http://mydomain.foo/rdm/journals/diff/3?detail_id=4',
+ assert_select 'a[href^=?][title=?]',
+ # should be http://mydomain.foo/rdm/journals/diff/3?detail_id=4
+ # but the Rails 4.2 DOM assertion doesn't handle the ? in the
+ # attribute value
+ 'http://mydomain.foo/rdm/journals/diff/3',
'View differences',
:text => 'diff'
# link to an attachment
# link to a changeset
assert_select 'a[href=?][title=?]',
'http://mydomain.foo/rdm/projects/ecookbook/repository/revisions/2',
- 'This commit fixes #1, #2 and references #1 & #3',
+ 'This commit fixes #1, #2 and references #1 & #3',
:text => 'r2'
# link to a description diff
- assert_select 'a[href=?][title=?]',
- 'http://mydomain.foo/rdm/journals/diff/3?detail_id=4',
+ assert_select 'a[href^=?][title=?]',
+ # should be http://mydomain.foo/rdm/journals/diff/3?detail_id=4
+ # but the Rails 4.2 DOM assertion doesn't handle the ? in the
+ # attribute value
+ 'http://mydomain.foo/rdm/journals/diff/3',
'View differences',
:text => 'diff'
# link to an attachment
end
end
- def test_mail_should_return_a_mail_message
- assert_kind_of ::Mail::Message, Mailer.test_email(User.find(1))
- end
-
def test_with_synched_deliveries_should_yield_with_synced_deliveries
ActionMailer::Base.delivery_method = :async_smtp
ActionMailer::Base.async_smtp_settings = {:foo => 'bar'}