From fb3b904b8ffbe65ba11ed68252cdb441421b9a2b Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 4 Feb 2012 17:36:15 +0000 Subject: [PATCH] Better handling of issue update conflicts (#8691). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8774 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/issues_controller.rb | 37 +++++- app/models/issue.rb | 12 +- app/views/issues/_conflict.html.erb | 26 ++++ app/views/issues/_edit.html.erb | 2 + config/locales/ar.yml | 4 + config/locales/bg.yml | 4 + config/locales/bs.yml | 4 + config/locales/ca.yml | 4 + config/locales/cs.yml | 4 + config/locales/da.yml | 4 + config/locales/de.yml | 4 + config/locales/el.yml | 4 + config/locales/en-GB.yml | 4 + config/locales/en.yml | 4 + config/locales/es.yml | 4 + config/locales/eu.yml | 4 + config/locales/fa.yml | 4 + config/locales/fi.yml | 4 + config/locales/fr.yml | 4 + config/locales/gl.yml | 4 + config/locales/he.yml | 4 + config/locales/hr.yml | 4 + config/locales/hu.yml | 4 + config/locales/id.yml | 4 + config/locales/it.yml | 4 + config/locales/ja.yml | 4 + config/locales/ko.yml | 4 + config/locales/lt.yml | 4 + config/locales/lv.yml | 4 + config/locales/mk.yml | 4 + config/locales/mn.yml | 4 + config/locales/nl.yml | 4 + config/locales/no.yml | 4 + config/locales/pl.yml | 4 + config/locales/pt-BR.yml | 4 + config/locales/pt.yml | 4 + config/locales/ro.yml | 4 + config/locales/ru.yml | 4 + config/locales/sk.yml | 4 + config/locales/sl.yml | 4 + config/locales/sr-YU.yml | 4 + config/locales/sr.yml | 4 + config/locales/sv.yml | 4 + config/locales/th.yml | 4 + config/locales/tr.yml | 4 + config/locales/uk.yml | 4 + config/locales/vi.yml | 4 + config/locales/zh-TW.yml | 4 + config/locales/zh.yml | 4 + public/stylesheets/application.css | 6 +- test/fixtures/issues.yml | 1 + .../issues_controller_transaction_test.rb | 125 +++++++++++++++++- test/unit/issue_test.rb | 7 + 53 files changed, 384 insertions(+), 12 deletions(-) create mode 100644 app/views/issues/_conflict.html.erb diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 9976a93cc..df130f9d5 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -171,7 +171,7 @@ class IssuesController < ApplicationController end def edit - update_issue_from_params + return unless update_issue_from_params respond_to do |format| format.html { } @@ -180,9 +180,23 @@ class IssuesController < ApplicationController end def update - update_issue_from_params + return unless update_issue_from_params + saved = false + begin + saved = @issue.save_issue_with_child_records(params, @time_entry) + rescue ActiveRecord::StaleObjectError + @conflict = true + if params[:last_journal_id] + if params[:last_journal_id].present? + last_journal_id = params[:last_journal_id].to_i + @conflict_journals = @issue.journals.all(:conditions => ["#{Journal.table_name}.id > ?", last_journal_id]) + else + @conflict_journals = @issue.journals.all + end + end + end - if @issue.save_issue_with_child_records(params, @time_entry) + if saved render_attachment_warning_if_needed(@issue) flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record? @@ -345,7 +359,22 @@ private @notes = params[:notes] || (params[:issue].present? ? params[:issue][:notes] : nil) @issue.init_journal(User.current, @notes) - @issue.safe_attributes = params[:issue] + + issue_attributes = params[:issue] + if issue_attributes && params[:conflict_resolution] + case params[:conflict_resolution] + when 'overwrite' + issue_attributes = issue_attributes.dup + issue_attributes.delete(:lock_version) + when 'add_notes' + issue_attributes = {} + when 'cancel' + redirect_to issue_path(@issue) + return false + end + end + @issue.safe_attributes = issue_attributes + true end # TODO: Refactor, lots of extra code in here diff --git a/app/models/issue.rb b/app/models/issue.rb index f6c458990..098113bdf 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -436,6 +436,15 @@ class Issue < ActiveRecord::Base @current_journal end + # Returns the id of the last journal or nil + def last_journal_id + if new_record? + nil + else + journals.first(:order => "#{Journal.table_name}.id DESC").try(:id) + end + end + # Return true if the issue is closed, otherwise false def closed? self.status.is_closed? @@ -692,8 +701,7 @@ class Issue < ActiveRecord::Base end rescue ActiveRecord::StaleObjectError attachments[:files].each(&:destroy) - errors.add :base, l(:notice_locking_conflict) - raise ActiveRecord::Rollback + raise ActiveRecord::StaleObjectError end end end diff --git a/app/views/issues/_conflict.html.erb b/app/views/issues/_conflict.html.erb new file mode 100644 index 000000000..2685447f4 --- /dev/null +++ b/app/views/issues/_conflict.html.erb @@ -0,0 +1,26 @@ +
+ <%= l(:notice_issue_update_conflict) %> + <% if @conflict_journals.present? %> +
+ <% @conflict_journals.sort_by(&:id).each do |journal| %> +

<%= authoring journal.created_on, journal.user, :label => :label_updated_time_by %>

+ <% if journal.details.any? %> +
    + <% details_to_strings(journal.details).each do |string| %> +
  • <%= string %>
  • + <% end %> +
+ <% end %> + <%= textilizable(journal, :notes) unless journal.notes.blank? %> + <% end %> +
+ <% end %> +
+

+
+ <% if @notes.present? %> +
+ <% end %> + +

+

<%= submit_tag l(:button_submit) %>

diff --git a/app/views/issues/_edit.html.erb b/app/views/issues/_edit.html.erb index 4db1a3e0f..432800f99 100644 --- a/app/views/issues/_edit.html.erb +++ b/app/views/issues/_edit.html.erb @@ -1,5 +1,6 @@ <% labelled_form_for @issue, :html => {:id => 'issue-form', :multipart => true} do |f| %> <%= error_messages_for 'issue', 'time_entry' %> + <%= render :partial => 'conflict' if @conflict %>
<% if @edit_allowed || !@allowed_statuses.empty? %>
<%= l(:label_change_properties) %> @@ -35,6 +36,7 @@
<%= f.hidden_field :lock_version %> + <%= hidden_field_tag 'last_journal_id', params[:last_journal_id] || @issue.last_journal_id %> <%= submit_tag l(:button_submit) %> <%= link_to_remote l(:label_preview), { :url => preview_issue_path(:project_id => @project, :id => @issue), diff --git a/config/locales/ar.yml b/config/locales/ar.yml index 5f7e321af..6cbc4b273 100644 --- a/config/locales/ar.yml +++ b/config/locales/ar.yml @@ -1018,3 +1018,7 @@ ar: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/bg.yml b/config/locales/bg.yml index ac67c8bfb..a480801e3 100644 --- a/config/locales/bg.yml +++ b/config/locales/bg.yml @@ -1016,3 +1016,7 @@ bg: description_date_from: Въведете начална дата description_date_to: Въведете крайна дата setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/bs.yml b/config/locales/bs.yml index b452eba88..031138623 100644 --- a/config/locales/bs.yml +++ b/config/locales/bs.yml @@ -1032,3 +1032,7 @@ bs: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/ca.yml b/config/locales/ca.yml index 29290160f..77097eac1 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -1020,3 +1020,7 @@ ca: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/cs.yml b/config/locales/cs.yml index af74ee244..09f265d6e 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -1021,3 +1021,7 @@ cs: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/da.yml b/config/locales/da.yml index 2471d1187..538a33bc0 100644 --- a/config/locales/da.yml +++ b/config/locales/da.yml @@ -1035,3 +1035,7 @@ da: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/de.yml b/config/locales/de.yml index 8588ab8c2..b6f433ed1 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -1038,3 +1038,7 @@ de: label_completed_versions: Completed versions field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/el.yml b/config/locales/el.yml index e3cb20932..8c033eb36 100644 --- a/config/locales/el.yml +++ b/config/locales/el.yml @@ -1018,3 +1018,7 @@ el: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/en-GB.yml b/config/locales/en-GB.yml index a64c3fc2e..a89dafaf1 100644 --- a/config/locales/en-GB.yml +++ b/config/locales/en-GB.yml @@ -1020,3 +1020,7 @@ en-GB: label_completed_versions: Completed versions field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/en.yml b/config/locales/en.yml index a000d60df..47f009830 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -172,6 +172,7 @@ en: notice_issue_done_ratios_updated: Issue done ratios updated. notice_gantt_chart_truncated: "The chart was truncated because it exceeds the maximum number of items that can be displayed (%{max})" notice_issue_successful_create: "Issue %{id} created." + notice_issue_update_conflict: "The issue has been updated by an other user while you were editing it." error_can_t_load_default_data: "Default configuration could not be loaded: %{value}" error_scm_not_found: "The entry or revision was not found in the repository." @@ -971,6 +972,9 @@ en: text_scm_command_version: Version text_scm_config: You can configure your scm commands in config/configuration.yml. Please restart the application after editing it. text_scm_command_not_available: Scm command is not available. Please check settings on the administration panel. + text_issue_conflict_resolution_overwrite: "Apply my changes anyway (previous notes will be kept but some changes may be overwritten)" + text_issue_conflict_resolution_add_notes: "Add my notes and discard my other changes" + text_issue_conflict_resolution_cancel: "Discard all my changes and redisplay %{link}" default_role_manager: Manager default_role_developer: Developer diff --git a/config/locales/es.yml b/config/locales/es.yml index 018831f75..407e94c81 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -1055,3 +1055,7 @@ es: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/eu.yml b/config/locales/eu.yml index a02157a52..67c546a4a 100644 --- a/config/locales/eu.yml +++ b/config/locales/eu.yml @@ -1021,3 +1021,7 @@ eu: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/fa.yml b/config/locales/fa.yml index 1a8ca71a5..13e9161f9 100644 --- a/config/locales/fa.yml +++ b/config/locales/fa.yml @@ -1020,3 +1020,7 @@ fa: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 2ad1e9884..2f8c01249 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -1039,3 +1039,7 @@ fi: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/fr.yml b/config/locales/fr.yml index ebed747af..77241b293 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -187,6 +187,7 @@ fr: notice_api_access_key_reseted: Votre clé d'accès API a été réinitialisée. notice_gantt_chart_truncated: "Le diagramme a été tronqué car il excède le nombre maximal d'éléments pouvant être affichés (%{max})" notice_issue_successful_create: "La demande %{id} a été créée." + notice_issue_update_conflict: "La demande a été mise à jour par un autre utilisateur pendant que vous la modifiez." error_can_t_load_default_data: "Une erreur s'est produite lors du chargement du paramétrage : %{value}" error_scm_not_found: "L'entrée et/ou la révision demandée n'existe pas dans le dépôt." @@ -928,6 +929,9 @@ fr: text_wiki_page_reassign_children: "Réaffecter les sous-pages à cette page" text_own_membership_delete_confirmation: "Vous allez supprimer tout ou partie de vos permissions sur ce projet et ne serez peut-être plus autorisé à modifier ce projet.\nEtes-vous sûr de vouloir continuer ?" text_warn_on_leaving_unsaved: "Cette page contient du texte non sauvegardé qui sera perdu si vous quittez la page." + text_issue_conflict_resolution_overwrite: "Appliquer quand même ma mise à jour (les notes précédentes seront conservées mais des changements pourront être écrasés)" + text_issue_conflict_resolution_add_notes: "Ajouter mes notes et ignorer mes autres changements" + text_issue_conflict_resolution_cancel: "Annuler ma mise à jour et réafficher %{link}" default_role_manager: "Manager " default_role_developer: "Développeur " diff --git a/config/locales/gl.yml b/config/locales/gl.yml index 12331b29b..c4e3216ed 100644 --- a/config/locales/gl.yml +++ b/config/locales/gl.yml @@ -1029,3 +1029,7 @@ gl: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/he.yml b/config/locales/he.yml index c877adf3c..73ad5b368 100644 --- a/config/locales/he.yml +++ b/config/locales/he.yml @@ -1023,3 +1023,7 @@ he: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/hr.yml b/config/locales/hr.yml index 3d09f1b18..f4fc6e91b 100644 --- a/config/locales/hr.yml +++ b/config/locales/hr.yml @@ -1024,3 +1024,7 @@ hr: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/hu.yml b/config/locales/hu.yml index ddff9f764..96ea2bbc1 100644 --- a/config/locales/hu.yml +++ b/config/locales/hu.yml @@ -1037,3 +1037,7 @@ text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/id.yml b/config/locales/id.yml index 6ebd43b17..9874afe1f 100644 --- a/config/locales/id.yml +++ b/config/locales/id.yml @@ -1024,3 +1024,7 @@ id: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/it.yml b/config/locales/it.yml index 309d878ca..4c2e2b08f 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -1019,3 +1019,7 @@ it: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/ja.yml b/config/locales/ja.yml index b2306d8c8..0fbb23a9e 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -1048,3 +1048,7 @@ ja: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/ko.yml b/config/locales/ko.yml index e9e9bf03f..f38641bd7 100644 --- a/config/locales/ko.yml +++ b/config/locales/ko.yml @@ -1068,3 +1068,7 @@ ko: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/lt.yml b/config/locales/lt.yml index c1529496f..a1cd35bb1 100644 --- a/config/locales/lt.yml +++ b/config/locales/lt.yml @@ -1078,3 +1078,7 @@ lt: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/lv.yml b/config/locales/lv.yml index 4d36e9082..adeafaff3 100644 --- a/config/locales/lv.yml +++ b/config/locales/lv.yml @@ -1012,3 +1012,7 @@ lv: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/mk.yml b/config/locales/mk.yml index 95e756fd0..fb79c4cbe 100644 --- a/config/locales/mk.yml +++ b/config/locales/mk.yml @@ -1018,3 +1018,7 @@ mk: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/mn.yml b/config/locales/mn.yml index 9082312ce..4b589adbf 100644 --- a/config/locales/mn.yml +++ b/config/locales/mn.yml @@ -1018,3 +1018,7 @@ mn: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/nl.yml b/config/locales/nl.yml index d7420078f..f73b46bcf 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -1000,3 +1000,7 @@ nl: label_completed_versions: Completed versions field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/no.yml b/config/locales/no.yml index c12deac59..1acd50d79 100644 --- a/config/locales/no.yml +++ b/config/locales/no.yml @@ -1008,3 +1008,7 @@ text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/pl.yml b/config/locales/pl.yml index eddba2036..6d841e26d 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -1035,3 +1035,7 @@ pl: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index e44340d6f..1dc70a179 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -1041,3 +1041,7 @@ pt-BR: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/pt.yml b/config/locales/pt.yml index 4218d1272..737d8044c 100644 --- a/config/locales/pt.yml +++ b/config/locales/pt.yml @@ -1023,3 +1023,7 @@ pt: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/ro.yml b/config/locales/ro.yml index 40d8de4a5..62378ce6e 100644 --- a/config/locales/ro.yml +++ b/config/locales/ro.yml @@ -1015,3 +1015,7 @@ ro: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/ru.yml b/config/locales/ru.yml index f2246ab6b..8ac0e5903 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -1131,3 +1131,7 @@ ru: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/sk.yml b/config/locales/sk.yml index 8c10a393d..2d210d36d 100644 --- a/config/locales/sk.yml +++ b/config/locales/sk.yml @@ -1018,3 +1018,7 @@ sk: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/sl.yml b/config/locales/sl.yml index b129d8d45..e84766094 100644 --- a/config/locales/sl.yml +++ b/config/locales/sl.yml @@ -1018,3 +1018,7 @@ sl: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/sr-YU.yml b/config/locales/sr-YU.yml index f63491422..6059c5ccf 100644 --- a/config/locales/sr-YU.yml +++ b/config/locales/sr-YU.yml @@ -1018,3 +1018,7 @@ sr-YU: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/sr.yml b/config/locales/sr.yml index e56dbcc18..6baabf1ac 100644 --- a/config/locales/sr.yml +++ b/config/locales/sr.yml @@ -1019,3 +1019,7 @@ sr: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/sv.yml b/config/locales/sv.yml index e894dd621..7f38a2e9f 100644 --- a/config/locales/sv.yml +++ b/config/locales/sv.yml @@ -1059,3 +1059,7 @@ sv: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/th.yml b/config/locales/th.yml index 0c52f74c0..81137e8f1 100644 --- a/config/locales/th.yml +++ b/config/locales/th.yml @@ -1015,3 +1015,7 @@ th: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/tr.yml b/config/locales/tr.yml index c2200b973..e9b1b2fb2 100644 --- a/config/locales/tr.yml +++ b/config/locales/tr.yml @@ -1037,3 +1037,7 @@ tr: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/uk.yml b/config/locales/uk.yml index 418db9119..1e7616cc1 100644 --- a/config/locales/uk.yml +++ b/config/locales/uk.yml @@ -1015,3 +1015,7 @@ uk: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/vi.yml b/config/locales/vi.yml index e7eba7d00..ce72ef3f1 100644 --- a/config/locales/vi.yml +++ b/config/locales/vi.yml @@ -1069,3 +1069,7 @@ vi: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index 57399bcc7..4d23b83b7 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -1098,3 +1098,7 @@ text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 9995b3ce8..4fffcee9c 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1020,3 +1020,7 @@ zh: text_project_identifier_info: Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed. field_multiple: Multiple values setting_commit_cross_project_ref: Allow issues of all the other projects to be referenced and fixed + text_issue_conflict_resolution_add_notes: Add my notes and discard my other changes + text_issue_conflict_resolution_overwrite: Apply my changes anyway (previous notes will be kept but some changes may be overwritten) + notice_issue_update_conflict: The issue has been updated by an other user while you were editing it. + text_issue_conflict_resolution_cancel: Discard all my changes and redisplay %{link} diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index ea4fc0410..d0043fa11 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -518,7 +518,7 @@ input#principal_search, input#user_search {width:100%} * html div#tab-content-members fieldset div { height: 450px; } /***** Flash & error messages ****/ -#errorExplanation, div.flash, .nodata, .warning { +#errorExplanation, div.flash, .nodata, .warning, .conflict { padding: 4px 4px 4px 30px; margin-bottom: 12px; font-size: 1.1em; @@ -541,7 +541,7 @@ div.flash.notice { color: #005f00; } -div.flash.warning { +div.flash.warning, .conflict { background: url(../images/warning.png) 8px 5px no-repeat; background-color: #FFEBC1; border-color: #FDBF3B; @@ -561,6 +561,8 @@ span.error {padding-left:20px; background:url(../images/exclamation.png) no-repe #errorExplanation ul { font-size: 0.9em;} #errorExplanation h2, #errorExplanation p { display: none; } +.conflict-details {font-size:80%;} + /***** Ajax indicator ******/ #ajax-indicator { position: absolute; /* fixed not supported by IE */ diff --git a/test/fixtures/issues.yml b/test/fixtures/issues.yml index b001b4835..5d8687bca 100644 --- a/test/fixtures/issues.yml +++ b/test/fixtures/issues.yml @@ -18,6 +18,7 @@ issues_001: root_id: 1 lft: 1 rgt: 2 + lock_version: 3 issues_002: created_on: 2006-07-19 21:04:21 +02:00 project_id: 1 diff --git a/test/functional/issues_controller_transaction_test.rb b/test/functional/issues_controller_transaction_test.rb index 3770dff0d..75c0b6a83 100644 --- a/test/functional/issues_controller_transaction_test.rb +++ b/test/functional/issues_controller_transaction_test.rb @@ -52,7 +52,7 @@ class IssuesControllerTransactionTest < ActionController::TestCase User.current = nil end - def test_put_update_stale_issue + def test_update_stale_issue_should_not_update_the_issue issue = Issue.find(2) @request.session[:user_id] = 2 @@ -65,7 +65,7 @@ class IssuesControllerTransactionTest < ActionController::TestCase :fixed_version_id => 4, :lock_version => (issue.lock_version - 1) }, - :notes => '', + :notes => 'My notes', :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}, :time_entry => { :hours => '2.5', :comments => '', :activity_id => TimeEntryActivity.first.id } end @@ -74,8 +74,125 @@ class IssuesControllerTransactionTest < ActionController::TestCase assert_response :success assert_template 'edit' - assert_tag :tag => 'div', :attributes => { :id => 'errorExplanation' }, - :content => /Data has been updated by another user/ + assert_tag 'div', :attributes => {:class => 'conflict'} + assert_tag 'input', :attributes => {:name => 'conflict_resolution', :value => 'overwrite'} + assert_tag 'input', :attributes => {:name => 'conflict_resolution', :value => 'add_notes'} + assert_tag 'input', :attributes => {:name => 'conflict_resolution', :value => 'cancel'} + 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, + :lock_version => (issue.lock_version - 1) + }, + :notes => '' + + assert_tag 'div', :attributes => {:class => 'conflict'} + assert_tag 'input', :attributes => {:name => 'conflict_resolution', :value => 'overwrite'} + assert_no_tag 'input', :attributes => {:name => 'conflict_resolution', :value => 'add_notes'} + assert_tag 'input', :attributes => {:name => 'conflict_resolution', :value => 'cancel'} + + end + + def test_update_stale_issue_should_show_conflicting_journals + @request.session[:user_id] = 2 + + put :update, :id => 1, + :issue => { + :fixed_version_id => 4, + :lock_version => 2 + }, + :notes => '', + :last_journal_id => 1 + + assert_not_nil assigns(:conflict_journals) + assert_equal 1, assigns(:conflict_journals).size + assert_equal 2, assigns(:conflict_journals).first.id + assert_tag 'div', :attributes => {:class => 'conflict'}, + :descendant => {:content => /Some notes with Redmine links/} + 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, + :lock_version => 2 + }, + :notes => '', + :last_journal_id => '' + + assert_not_nil assigns(:conflict_journals) + assert_equal 2, assigns(:conflict_journals).size + assert_tag 'div', :attributes => {:class => 'conflict'}, + :descendant => {:content => /Some notes with Redmine links/} + assert_tag 'div', :attributes => {:class => 'conflict'}, + :descendant => {:content => /Journal notes/} + end + + 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, + :lock_version => 2 + }, + :notes => 'overwrite_conflict_resolution', + :conflict_resolution => 'overwrite' + end + + assert_response 302 + issue = Issue.find(1) + assert_equal 4, issue.fixed_version_id + journal = Journal.first(:order => 'id DESC') + 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, + :lock_version => 2 + }, + :notes => 'add_notes_conflict_resolution', + :conflict_resolution => 'add_notes' + end + + assert_response 302 + issue = Issue.find(1) + assert_nil issue.fixed_version_id + journal = Journal.first(:order => 'id DESC') + assert_equal 'add_notes_conflict_resolution', journal.notes + 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, + :lock_version => 2 + }, + :notes => 'add_notes_conflict_resolution', + :conflict_resolution => 'cancel' + end + + assert_redirected_to '/issues/1' + issue = Issue.find(1) + assert_nil issue.fixed_version_id end def test_index_should_rescue_invalid_sql_query diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb index eda13d7a8..14abd413b 100644 --- a/test/unit/issue_test.rb +++ b/test/unit/issue_test.rb @@ -1237,6 +1237,13 @@ class IssueTest < ActiveSupport::TestCase assert !@issue.recipients.include?(@issue.assigned_to.mail) end + end + + def test_last_journal_id_with_journals_should_return_the_journal_id + assert_equal 2, Issue.find(1).last_journal_id + end + def test_last_journal_id_without_journals_should_return_nil + assert_nil Issue.find(3).last_journal_id end end -- 2.39.5