##// END OF EJS Templates
Speeds up rendering of the project list for users who belong to hundreds of projects....
Speeds up rendering of the project list for users who belong to hundreds of projects. git-svn-id: http://svn.redmine.org/redmine/trunk@16123 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r15586:5e2f833f0c66
r15741:f8df935dcada
Show More
issues_controller_transaction_test.rb
282 lines | 9.3 KiB | text/x-ruby | RubyLexer
/ test / functional / issues_controller_transaction_test.rb
Jean-Philippe Lang
Fixes a test failure with SQLite3 due to transaction fixtures (#5290)....
r3555 # Redmine - project management software
Jean-Philippe Lang
Updates copyright for 2016....
r14856 # Copyright (C) 2006-2016 Jean-Philippe Lang
Jean-Philippe Lang
Fixes a test failure with SQLite3 due to transaction fixtures (#5290)....
r3555 #
# 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.
Toshi MARUYAMA
remove trailing white-spaces from test/functional/issues_controller_transaction_test.rb....
r6799 #
Jean-Philippe Lang
Fixes a test failure with SQLite3 due to transaction fixtures (#5290)....
r3555 # 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.
Toshi MARUYAMA
remove trailing white-spaces from test/functional/issues_controller_transaction_test.rb....
r6799 #
Jean-Philippe Lang
Fixes a test failure with SQLite3 due to transaction fixtures (#5290)....
r3555 # 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.
Jean-Baptiste Barth
Use absolute paths in test/**/* requires for Ruby 1.9.2 compatibility. #4050...
r4395 require File.expand_path('../../test_helper', __FILE__)
Jean-Philippe Lang
Fixes a test failure with SQLite3 due to transaction fixtures (#5290)....
r3555 require 'issues_controller'
Jean-Philippe Lang
Adds our own class for controller tests....
r15279 class IssuesControllerTransactionTest < Redmine::ControllerTest
Jean-Philippe Lang
Functional tests cleanup....
r10709 tests IssuesController
Jean-Philippe Lang
Fixes a test failure with SQLite3 due to transaction fixtures (#5290)....
r3555 fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules,
:enumerations,
:attachments,
:workflows,
:custom_fields,
:custom_values,
:custom_fields_projects,
:custom_fields_trackers,
:time_entries,
:journals,
:journal_details,
:queries
self.use_transactional_fixtures = false
Toshi MARUYAMA
remove trailing white-spaces from test/functional/issues_controller_transaction_test.rb....
r6799
Jean-Philippe Lang
Fixes a test failure with SQLite3 due to transaction fixtures (#5290)....
r3555 def setup
User.current = nil
end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/issues_controller_transaction_test.rb....
r6799
Jean-Philippe Lang
Better handling of issue update conflicts (#8691)....
r8654 def test_update_stale_issue_should_not_update_the_issue
Jean-Philippe Lang
Fixes a test failure with SQLite3 due to transaction fixtures (#5290)....
r3555 issue = Issue.find(2)
@request.session[:user_id] = 2
assert_no_difference 'Journal.count' do
assert_no_difference 'TimeEntry.count' do
Jean-Philippe Lang
Better handling of attachments when issue validation fails (#10253)....
r8771 put :update,
:id => issue.id,
:issue => {
:fixed_version_id => 4,
Jean-Philippe Lang
Private issue notes (#1554)....
r10336 :notes => 'My notes',
Jean-Philippe Lang
Better handling of attachments when issue validation fails (#10253)....
r8771 :lock_version => (issue.lock_version - 1)
},
:time_entry => { :hours => '2.5', :comments => '', :activity_id => TimeEntryActivity.first.id }
end
end
assert_response :success
Jean-Philippe Lang
Fixed: escaped link in conflict resolution form (#11341)....
r9742
assert_select 'div.conflict'
assert_select 'input[name=?][value=?]', 'conflict_resolution', 'overwrite'
assert_select 'input[name=?][value=?]', 'conflict_resolution', 'add_notes'
assert_select 'label' do
assert_select 'input[name=?][value=?]', 'conflict_resolution', 'cancel'
Jean-Philippe Lang
Quote values in DOM selectors for Nokogiri compatibility....
r13237 assert_select 'a[href="/issues/2"]'
Jean-Philippe Lang
Fixed: escaped link in conflict resolution form (#11341)....
r9742 end
Jean-Philippe Lang
Better handling of attachments when issue validation fails (#10253)....
r8771 end
def test_update_stale_issue_should_save_attachments
set_tmp_attachments_directory
issue = Issue.find(2)
@request.session[:user_id] = 2
assert_no_difference 'Journal.count' do
assert_no_difference 'TimeEntry.count' do
assert_difference 'Attachment.count' do
Jean-Philippe Lang
Fixes a test failure with SQLite3 due to transaction fixtures (#5290)....
r3555 put :update,
:id => issue.id,
:issue => {
:fixed_version_id => 4,
Jean-Philippe Lang
Private issue notes (#1554)....
r10336 :notes => 'My notes',
Jean-Philippe Lang
Fixes a test failure with SQLite3 due to transaction fixtures (#5290)....
r3555 :lock_version => (issue.lock_version - 1)
},
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}},
Jean-Philippe Lang
Fixes some parameters in functional tests....
r3587 :time_entry => { :hours => '2.5', :comments => '', :activity_id => TimeEntryActivity.first.id }
Jean-Philippe Lang
Fixes a test failure with SQLite3 due to transaction fixtures (#5290)....
r3555 end
end
end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/issues_controller_transaction_test.rb....
r6799
Jean-Philippe Lang
Fixes a test failure with SQLite3 due to transaction fixtures (#5290)....
r3555 assert_response :success
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15313
Toshi MARUYAMA
Rails4: replace deprecated Relation#first with finder options at IssuesControllerTransactionTest...
r12363 attachment = Attachment.order('id DESC').first
Jean-Philippe Lang
Replaced remaining #assert_tag with #assert_select....
r13242 assert_select 'input[name=?][value=?]', 'attachments[p0][token]', attachment.token
assert_select 'input[name=?][value=?]', 'attachments[p0][filename]', 'testfile.txt'
Jean-Philippe Lang
Better handling of issue update conflicts (#8691)....
r8654 end
def test_update_stale_issue_without_notes_should_not_show_add_notes_option
issue = Issue.find(2)
@request.session[:user_id] = 2
put :update, :id => issue.id,
:issue => {
:fixed_version_id => 4,
Jean-Philippe Lang
Private issue notes (#1554)....
r10336 :notes => '',
Jean-Philippe Lang
Better handling of issue update conflicts (#8691)....
r8654 :lock_version => (issue.lock_version - 1)
Jean-Philippe Lang
Private issue notes (#1554)....
r10336 }
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15313 assert_response :success
Jean-Philippe Lang
Better handling of issue update conflicts (#8691)....
r8654
Jean-Philippe Lang
Replaced remaining #assert_tag with #assert_select....
r13242 assert_select 'div.conflict'
assert_select 'input[name=conflict_resolution][value=overwrite]'
assert_select 'input[name=conflict_resolution][value=add_notes]', 0
assert_select 'input[name=conflict_resolution][value=cancel]'
Jean-Philippe Lang
Better handling of issue update conflicts (#8691)....
r8654 end
def test_update_stale_issue_should_show_conflicting_journals
@request.session[:user_id] = 2
put :update, :id => 1,
:issue => {
:fixed_version_id => 4,
Jean-Philippe Lang
Private issue notes (#1554)....
r10336 :notes => '',
Jean-Philippe Lang
Better handling of issue update conflicts (#8691)....
r8654 :lock_version => 2
},
:last_journal_id => 1
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15313 assert_response :success
Jean-Philippe Lang
Better handling of issue update conflicts (#8691)....
r8654
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15313 assert_select '.conflict-journal', 1
Jean-Philippe Lang
Replaced remaining #assert_tag with #assert_select....
r13242 assert_select 'div.conflict', :text => /Some notes with Redmine links/
Jean-Philippe Lang
Better handling of issue update conflicts (#8691)....
r8654 end
def test_update_stale_issue_without_previous_journal_should_show_all_journals
@request.session[:user_id] = 2
put :update, :id => 1,
:issue => {
:fixed_version_id => 4,
Jean-Philippe Lang
Private issue notes (#1554)....
r10336 :notes => '',
Jean-Philippe Lang
Better handling of issue update conflicts (#8691)....
r8654 :lock_version => 2
},
:last_journal_id => ''
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15313 assert_response :success
Jean-Philippe Lang
Better handling of issue update conflicts (#8691)....
r8654
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15313 assert_select '.conflict-journal', 2
Jean-Philippe Lang
Replaced remaining #assert_tag with #assert_select....
r13242 assert_select 'div.conflict', :text => /Some notes with Redmine links/
assert_select 'div.conflict', :text => /Journal notes/
Jean-Philippe Lang
Better handling of issue update conflicts (#8691)....
r8654 end
Jean-Philippe Lang
Private issue notes (#1554)....
r10336 def test_update_stale_issue_should_show_private_journals_with_permission_only
journal = Journal.create!(:journalized => Issue.find(1), :notes => 'Privates notes', :private_notes => true, :user_id => 1)
@request.session[:user_id] = 2
put :update, :id => 1, :issue => {:fixed_version_id => 4, :lock_version => 2}, :last_journal_id => ''
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15313 assert_response :success
assert_select '.conflict-journal', :text => /Privates notes/
Jean-Philippe Lang
Private issue notes (#1554)....
r10336
Role.find(1).remove_permission! :view_private_notes
put :update, :id => 1, :issue => {:fixed_version_id => 4, :lock_version => 2}, :last_journal_id => ''
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15313 assert_response :success
assert_select '.conflict-journal', :text => /Privates notes/, :count => 0
Jean-Philippe Lang
Private issue notes (#1554)....
r10336 end
Jean-Philippe Lang
Better handling of issue update conflicts (#8691)....
r8654 def test_update_stale_issue_with_overwrite_conflict_resolution_should_update
@request.session[:user_id] = 2
assert_difference 'Journal.count' do
put :update, :id => 1,
:issue => {
:fixed_version_id => 4,
Jean-Philippe Lang
Private issue notes (#1554)....
r10336 :notes => 'overwrite_conflict_resolution',
Jean-Philippe Lang
Better handling of issue update conflicts (#8691)....
r8654 :lock_version => 2
},
:conflict_resolution => 'overwrite'
end
assert_response 302
issue = Issue.find(1)
assert_equal 4, issue.fixed_version_id
Toshi MARUYAMA
Rails4: replace deprecated Relation#first with finder options at IssuesControllerTransactionTest...
r12363 journal = Journal.order('id DESC').first
Jean-Philippe Lang
Better handling of issue update conflicts (#8691)....
r8654 assert_equal 'overwrite_conflict_resolution', journal.notes
assert journal.details.any?
end
def test_update_stale_issue_with_add_notes_conflict_resolution_should_update
@request.session[:user_id] = 2
assert_difference 'Journal.count' do
put :update, :id => 1,
:issue => {
:fixed_version_id => 4,
Jean-Philippe Lang
Private issue notes (#1554)....
r10336 :notes => 'add_notes_conflict_resolution',
Jean-Philippe Lang
Better handling of issue update conflicts (#8691)....
r8654 :lock_version => 2
},
:conflict_resolution => 'add_notes'
end
assert_response 302
issue = Issue.find(1)
assert_nil issue.fixed_version_id
Toshi MARUYAMA
Rails4: replace deprecated Relation#first with finder options at IssuesControllerTransactionTest...
r12363 journal = Journal.order('id DESC').first
Jean-Philippe Lang
Better handling of issue update conflicts (#8691)....
r8654 assert_equal 'add_notes_conflict_resolution', journal.notes
Jean-Philippe Lang
Private note flag disappears in issue update conflict (#21551)....
r14602 assert_equal false, journal.private_notes
assert journal.details.empty?
end
def test_update_stale_issue_with_add_notes_conflict_resolution_should_preserve_private_notes
@request.session[:user_id] = 2
journal = new_record(Journal) do
put :update, :id => 1,
:issue => {
:fixed_version_id => 4,
:notes => 'add_privates_notes_conflict_resolution',
:private_notes => '1',
:lock_version => 2
},
:conflict_resolution => 'add_notes'
end
assert_response 302
assert_equal 'add_privates_notes_conflict_resolution', journal.notes
assert_equal true, journal.private_notes
Jean-Philippe Lang
Better handling of issue update conflicts (#8691)....
r8654 assert journal.details.empty?
end
def test_update_stale_issue_with_cancel_conflict_resolution_should_redirect_without_updating
@request.session[:user_id] = 2
assert_no_difference 'Journal.count' do
put :update, :id => 1,
:issue => {
:fixed_version_id => 4,
Jean-Philippe Lang
Private issue notes (#1554)....
r10336 :notes => 'add_notes_conflict_resolution',
Jean-Philippe Lang
Better handling of issue update conflicts (#8691)....
r8654 :lock_version => 2
},
:conflict_resolution => 'cancel'
end
assert_redirected_to '/issues/1'
issue = Issue.find(1)
assert_nil issue.fixed_version_id
Jean-Philippe Lang
Fixes a test failure with SQLite3 due to transaction fixtures (#5290)....
r3555 end
Jean-Philippe Lang
Moves test to non-transactional fixtures tests (failure with postgresql)....
r7958
Jean-Philippe Lang
Test moved to tests with transactional fixtures disabled....
r10415 def test_put_update_with_spent_time_and_failure_should_not_add_spent_time
@request.session[:user_id] = 2
assert_no_difference('TimeEntry.count') do
put :update,
:id => 1,
:issue => { :subject => '' },
:time_entry => { :hours => '2.5', :comments => 'should not be added', :activity_id => TimeEntryActivity.first.id }
assert_response :success
end
Jean-Philippe Lang
Test failure (#23996)....
r15586 assert_select 'input[name=?][value=?]', 'time_entry[hours]', '2.50'
Jean-Philippe Lang
Test moved to tests with transactional fixtures disabled....
r10415 assert_select 'input[name=?][value=?]', 'time_entry[comments]', 'should not be added'
assert_select 'select[name=?]', 'time_entry[activity_id]' do
Jean-Philippe Lang
Upgrade to Rails 4.2.0 (#14534)....
r13510 assert_select 'option[value=?][selected=selected]', TimeEntryActivity.first.id.to_s
Jean-Philippe Lang
Test moved to tests with transactional fixtures disabled....
r10415 end
end
Jean-Philippe Lang
Moves test to non-transactional fixtures tests (failure with postgresql)....
r7958 def test_index_should_rescue_invalid_sql_query
Jean-Philippe Lang
Adds STI to Query model. Issue queries are now IssueQuery instances....
r10737 IssueQuery.any_instance.stubs(:statement).returns("INVALID STATEMENT")
Jean-Philippe Lang
Moves test to non-transactional fixtures tests (failure with postgresql)....
r7958
get :index
assert_response 500
Jean-Philippe Lang
Replaced remaining #assert_tag with #assert_select....
r13242 assert_select 'p', :text => /An error occurred/
Jean-Philippe Lang
Moves test to non-transactional fixtures tests (failure with postgresql)....
r7958 assert_nil session[:query]
assert_nil session[:issues_index_sort]
end
Jean-Philippe Lang
Fixes a test failure with SQLite3 due to transaction fixtures (#5290)....
r3555 end