Chris@0: # Redmine - project management software Chris@909: # Copyright (C) 2006-2011 Jean-Philippe Lang Chris@0: # Chris@0: # This program is free software; you can redistribute it and/or Chris@0: # modify it under the terms of the GNU General Public License Chris@0: # as published by the Free Software Foundation; either version 2 Chris@0: # of the License, or (at your option) any later version. Chris@909: # Chris@0: # This program is distributed in the hope that it will be useful, Chris@0: # but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@0: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@0: # GNU General Public License for more details. Chris@909: # Chris@0: # You should have received a copy of the GNU General Public License Chris@0: # along with this program; if not, write to the Free Software Chris@0: # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Chris@0: Chris@119: require File.expand_path('../../test_helper', __FILE__) Chris@0: require 'issues_controller' Chris@0: Chris@0: class IssuesControllerTransactionTest < ActionController::TestCase Chris@0: fixtures :projects, Chris@0: :users, Chris@0: :roles, Chris@0: :members, Chris@0: :member_roles, Chris@0: :issues, Chris@0: :issue_statuses, Chris@0: :versions, Chris@0: :trackers, Chris@0: :projects_trackers, Chris@0: :issue_categories, Chris@0: :enabled_modules, Chris@0: :enumerations, Chris@0: :attachments, Chris@0: :workflows, Chris@0: :custom_fields, Chris@0: :custom_values, Chris@0: :custom_fields_projects, Chris@0: :custom_fields_trackers, Chris@0: :time_entries, Chris@0: :journals, Chris@0: :journal_details, Chris@0: :queries Chris@0: Chris@0: self.use_transactional_fixtures = false Chris@909: Chris@0: def setup Chris@0: @controller = IssuesController.new Chris@0: @request = ActionController::TestRequest.new Chris@0: @response = ActionController::TestResponse.new Chris@0: User.current = nil Chris@0: end Chris@909: Chris@0: def test_put_update_stale_issue Chris@0: issue = Issue.find(2) Chris@0: @request.session[:user_id] = 2 Chris@0: Chris@0: assert_no_difference 'Journal.count' do Chris@0: assert_no_difference 'TimeEntry.count' do Chris@0: assert_no_difference 'Attachment.count' do Chris@0: put :update, Chris@0: :id => issue.id, Chris@0: :issue => { Chris@0: :fixed_version_id => 4, Chris@0: :lock_version => (issue.lock_version - 1) Chris@0: }, Chris@0: :notes => '', Chris@0: :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}, Chris@0: :time_entry => { :hours => '2.5', :comments => '', :activity_id => TimeEntryActivity.first.id } Chris@0: end Chris@0: end Chris@0: end Chris@909: Chris@0: assert_response :success Chris@0: assert_template 'edit' Chris@0: assert_tag :tag => 'div', :attributes => { :id => 'errorExplanation' }, Chris@0: :content => /Data has been updated by another user/ Chris@0: end Chris@0: end