From 6b3f7c4dc8ba80972e08777226fe186c2e234a0a Mon Sep 17 00:00:00 2001 From: Christian Ratz Date: Tue, 4 Mar 2014 11:27:41 +0100 Subject: [PATCH 01/12] Removed path from guessed host - path is not needed here anymore --- app/controllers/settings_controller.rb | 2 +- app/views/settings/_general.html.erb | 2 +- config/locales/en.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb index 1c56e471d0..719f4e7511 100644 --- a/app/controllers/settings_controller.rb +++ b/app/controllers/settings_controller.rb @@ -53,7 +53,7 @@ class SettingsController < ApplicationController @options[:user_format] = User::USER_FORMATS.keys.collect {|f| [User.current.name(f), f.to_s] } @deliveries = ActionMailer::Base.perform_deliveries - @guessed_host_and_path = request.host_with_port.dup + OpenProject::Configuration.rails_relative_url_root + @guessed_host = request.host_with_port.dup end end diff --git a/app/views/settings/_general.html.erb b/app/views/settings/_general.html.erb index 7a47856ab1..9735606806 100644 --- a/app/views/settings/_general.html.erb +++ b/app/views/settings/_general.html.erb @@ -43,7 +43,7 @@ See doc/COPYRIGHT.rdoc for more details.

<%= setting_text_field :activity_days_default, :size => 6 %> <%= l(:label_day_plural) %>

<%= setting_text_field :host_name, :size => 60 %>
-<%= l(:label_example) %>: <%= @guessed_host_and_path %>

+<%= l(:label_example) %>: <%= @guessed_host %>

<%= setting_select :protocol, [['HTTP', 'http'], ['HTTPS', 'https']] %>

diff --git a/config/locales/en.yml b/config/locales/en.yml index 81cca549b1..bb3aa553ac 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1258,7 +1258,7 @@ en: setting_file_max_size_displayed: "Max size of text files displayed inline" setting_gravatar_default: "Default Gravatar image" setting_gravatar_enabled: "Use Gravatar user icons" - setting_host_name: "Host name and path" + setting_host_name: "Host name" setting_work_package_done_ratio: "Calculate the work package done ratio with" setting_work_package_done_ratio_field: "Use the work package field" setting_work_package_done_ratio_status: "Use the work package status" From 1e29f9fb3aee12e04154827d3c9c54cef5c3c381 Mon Sep 17 00:00:00 2001 From: Till Breuer Date: Tue, 4 Mar 2014 11:30:16 +0100 Subject: [PATCH 02/12] Fix duplication of work package priority in priority drop down --- app/controllers/work_packages_controller.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/work_packages_controller.rb b/app/controllers/work_packages_controller.rb index 3b8eea604a..494f4732ca 100644 --- a/app/controllers/work_packages_controller.rb +++ b/app/controllers/work_packages_controller.rb @@ -384,7 +384,10 @@ class WorkPackagesController < ApplicationController def priorities priorities = IssuePriority.active - priorities << work_package.priority if work_package + + current_priority = work_package.try :priority + priorities << current_priority if current_priority && !priorities.include?(current_priority) + priorities end From fc38f8e16a7b1ca3094e3a2a18769cddcb57e26b Mon Sep 17 00:00:00 2001 From: Till Breuer Date: Tue, 4 Mar 2014 11:54:22 +0100 Subject: [PATCH 03/12] Don't preselect inactive default priorities for new work packages --- app/controllers/work_packages_controller.rb | 8 ++++++-- app/models/work_package.rb | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/controllers/work_packages_controller.rb b/app/controllers/work_packages_controller.rb index 494f4732ca..456e0f2be2 100644 --- a/app/controllers/work_packages_controller.rb +++ b/app/controllers/work_packages_controller.rb @@ -384,11 +384,15 @@ class WorkPackagesController < ApplicationController def priorities priorities = IssuePriority.active + augment_priorities_with_current_work_package_priority priorities + priorities + end + + def augment_priorities_with_current_work_package_priority(priorities) current_priority = work_package.try :priority - priorities << current_priority if current_priority && !priorities.include?(current_priority) - priorities + priorities << current_priority if current_priority && !priorities.include?(current_priority) end def allowed_statuses diff --git a/app/models/work_package.rb b/app/models/work_package.rb index 3bd94009b1..65111fee11 100644 --- a/app/models/work_package.rb +++ b/app/models/work_package.rb @@ -938,7 +938,7 @@ class WorkPackage < ActiveRecord::Base def set_default_values if new_record? # set default values for new records only self.status ||= Status.default - self.priority ||= IssuePriority.default + self.priority ||= IssuePriority.active.default end end From f02c3c4eac5c272daff6b496f921a9a5b5ce3959 Mon Sep 17 00:00:00 2001 From: Till Breuer Date: Tue, 4 Mar 2014 11:56:15 +0100 Subject: [PATCH 04/12] Add missing encoding header to work packages controller spec --- spec/controllers/work_packages_controller_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/controllers/work_packages_controller_spec.rb b/spec/controllers/work_packages_controller_spec.rb index 784f03b693..f8e1a31cdc 100644 --- a/spec/controllers/work_packages_controller_spec.rb +++ b/spec/controllers/work_packages_controller_spec.rb @@ -1,3 +1,4 @@ +#-- encoding: UTF-8 #-- copyright # OpenProject is a project management system. # Copyright (C) 2012-2014 the OpenProject Foundation (OPF) From f37bb6574737b184de5a49778b9fad86d3524935 Mon Sep 17 00:00:00 2001 From: Christian Ratz Date: Tue, 4 Mar 2014 15:44:29 +0100 Subject: [PATCH 05/12] new version; updated changelog --- doc/CHANGELOG.md | 5 +++++ lib/open_project/version.rb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index 717aa4571d..62f9bce074 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -29,6 +29,11 @@ See doc/COPYRIGHT.rdoc for more details. # Changelog +## 3.0.0pre50 + +* Removed path from guessed host +* `#4008` Deactivating work package priorities has no effect + ## 3.0.0pre49 * `#2616` Fix: Search: Clicking on 'Back' results in wrong data diff --git a/lib/open_project/version.rb b/lib/open_project/version.rb index 14f132dae7..2b00cf2719 100644 --- a/lib/open_project/version.rb +++ b/lib/open_project/version.rb @@ -49,7 +49,7 @@ module OpenProject # # 2.0.0debian-2 def self.special - 'pre49' + 'pre50' end def self.revision From f5bd0c739584adc6ab6efb206f701417101c55c3 Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Tue, 4 Mar 2014 13:48:58 +0100 Subject: [PATCH 06/12] fixes cuke limited to date when used with plugin --- features/planning_elements/filter.feature | 8 ++++---- features/step_definitions/timecop_steps.rb | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/features/planning_elements/filter.feature b/features/planning_elements/filter.feature index 874ce7f5f8..98286eb9fa 100644 --- a/features/planning_elements/filter.feature +++ b/features/planning_elements/filter.feature @@ -212,8 +212,6 @@ Feature: Filtering work packages via the api And the json-response should not contain a work_package "work_package#1" And the json-response should contain a work_package "work_package#2" - # Always make sure, that historical tests are tagged with @timetravel: - # otherwise the time remains frozen for other features!!! Scenario: looking up historical data Given the date is "2014/01/01" And there are the following work packages in project "sample_project": @@ -225,7 +223,8 @@ Feature: Filtering work packages via the api And the work_package "work_package#3" is updated with the following: | type | Story | | responsible | bob | - Given the date is "2014/03/01" + # resetting to today as plugins might depend on the current time + Given the date is today And I call the work_package-api on project "sample_project" at time "2014/01/03" and filter for types "Story" Then the json-response should include 1 work package And the json-response for work_package "work_package#3" should have the type "Task" @@ -241,7 +240,8 @@ Feature: Filtering work packages via the api | type | Story | | responsible | pamela | | due_date | 2014/01/20 | - Given the date is "2014/03/01" + # resetting to today as plugins might depend on the current time + Given the date is today And I call the work_package-api on project "sample_project" at time "2014/01/03" and filter for types "Story" Then the json-response for work_package "work_package#1" should have the due_date "2014/01/15" And the work package "work_package#1" has the due_date "2014/01/20" diff --git a/features/step_definitions/timecop_steps.rb b/features/step_definitions/timecop_steps.rb index a5640a5060..a7e4ca66f4 100644 --- a/features/step_definitions/timecop_steps.rb +++ b/features/step_definitions/timecop_steps.rb @@ -63,6 +63,10 @@ Given(/^the date is "(.*?)"$/) do |date| Support::ResetTimecop.reset_after end +Given(/^the date is today$/) do + Timecop.return +end + module Support module ResetTimecop def self.reset_after From 05c3a973992442fa625e538293907e9b75c895de Mon Sep 17 00:00:00 2001 From: Michael Frister Date: Tue, 4 Mar 2014 16:41:35 +0100 Subject: [PATCH 07/12] Make custom value repair migration work with Postgres --- ...3056_repair_invalid_default_work_package_custom_values.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/db/migrate/20131210113056_repair_invalid_default_work_package_custom_values.rb b/db/migrate/20131210113056_repair_invalid_default_work_package_custom_values.rb index 35a3ea9596..a0304fa1c5 100644 --- a/db/migrate/20131210113056_repair_invalid_default_work_package_custom_values.rb +++ b/db/migrate/20131210113056_repair_invalid_default_work_package_custom_values.rb @@ -42,7 +42,10 @@ class RepairInvalidDefaultWorkPackageCustomValues < ActiveRecord::Migration def create_missing_work_package_custom_values missing_custom_values.each do |c| - insert <<-SQL + # Use execute instead of insert as Rails' Postgres adapter's insert fails when inserting + # into tables ending in 'values'. + # See https://www.openproject.org/work_packages/5033 + execute <<-SQL INSERT INTO custom_values (customized_type, customized_id, custom_field_id, value) VALUES ('WorkPackage', '#{c['work_package_id']}', From 5dca6b452d9aad71b2cdd77e0ce336a69e968d2f Mon Sep 17 00:00:00 2001 From: ulferts Date: Tue, 4 Mar 2014 16:52:44 +0100 Subject: [PATCH 08/12] updates changelog #5033 --- doc/CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index 62f9bce074..c3894b79f1 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -29,10 +29,12 @@ See doc/COPYRIGHT.rdoc for more details. # Changelog +* `#5033` Migration RepairInvalidDefaultWorkPackageCustomValues fails on Postgres + ## 3.0.0pre50 -* Removed path from guessed host * `#4008` Deactivating work package priorities has no effect +* Removed path from guessed host ## 3.0.0pre49 From f3fdc647a0e064f85106e74391ad1e724f679a7c Mon Sep 17 00:00:00 2001 From: Till Breuer Date: Fri, 28 Feb 2014 10:28:00 +0100 Subject: [PATCH 09/12] Fix variable naming --- app/assets/javascripts/timelines/ui.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/timelines/ui.js b/app/assets/javascripts/timelines/ui.js index c3078f8ce6..991b2539db 100644 --- a/app/assets/javascripts/timelines/ui.js +++ b/app/assets/javascripts/timelines/ui.js @@ -452,7 +452,6 @@ jQuery.extend(Timeline, { }, setupUI: function() { - this.setupToolbar(); this.setupChart(); }, @@ -893,9 +892,9 @@ jQuery.extend(Timeline, { var header = function(key) { var th = jQuery(''); if (key.substr(0, 3) === "cf_") { - var timeline_id = parseInt(key.substr(3), 10); - if (timeline.custom_fields[timeline_id]) { - th.append(timeline.custom_fields[timeline_id].name); + var customFieldId = parseInt(key.substr(3), 10); + if (timeline.custom_fields[customFieldId]) { + th.append(timeline.custom_fields[customFieldId].name); } } else { th.append(timeline.i18n('timelines.filter.column.' + key)); From add8b8d455794497afdd4324be6d4689d70ba574 Mon Sep 17 00:00:00 2001 From: Till Breuer Date: Fri, 28 Feb 2014 11:56:17 +0100 Subject: [PATCH 10/12] Disable deactivated custom field columns before timeline rendering --- app/assets/javascripts/timelines.js | 40 +++++++++++++++++++ .../javascripts/timelines/TimelineLoader.js | 8 +++- .../step_definitions/custom_field_steps.rb | 6 +++ .../step_definitions/timelines_then_steps.rb | 19 +++++++++ .../timeline_view_custom_fields.feature | 18 ++++++++- 5 files changed, 88 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/timelines.js b/app/assets/javascripts/timelines.js index ad27e7c3c4..97d552d77f 100644 --- a/app/assets/javascripts/timelines.js +++ b/app/assets/javascripts/timelines.js @@ -596,6 +596,46 @@ jQuery.extend(Timeline, { }); }, + getCustomFieldColumns: function() { + return this.options.columns.filter(function(column) { + return column.substr(0, 3) === 'cf_'; + }); + }, + getCustomFields: function() { + var customFields = []; + + jQuery.each(this.custom_fields, function(key, customField) { + customFields.push(customField); + }); + + return customFields; + }, + getValidCustomFieldIds: function() { + return this.getCustomFields().map(function(cf) { + return cf.id; + }); + }, + getIdOfCustomFieldColumn: function(cfColumn) { + return parseInt(cfColumn.substr(3, 10), 10); + }, + getInvalidCustomFieldColumns: function() { + var validCustomFieldIds = this.getValidCustomFieldIds(); + var timeline = this; + + return this.getCustomFieldColumns().filter(function(cfColumn) { + return validCustomFieldIds.indexOf(timeline.getIdOfCustomFieldColumn(cfColumn)) === -1; + }); + }, + removeColumnByName: function(columnName) { + this.options.columns.splice(this.options.columns.indexOf(columnName), 1); + }, + clearUpCustomFieldColumns: function() { + var timeline = this; + + jQuery.each(this.getInvalidCustomFieldColumns(), function(i, cfColumn) { + timeline.removeColumnByName(cfColumn); + }); + }, getReportings: function() { return Timeline.Reporting.all(this); }, diff --git a/app/assets/javascripts/timelines/TimelineLoader.js b/app/assets/javascripts/timelines/TimelineLoader.js index 5fc649edeb..0a725f7579 100644 --- a/app/assets/javascripts/timelines/TimelineLoader.js +++ b/app/assets/javascripts/timelines/TimelineLoader.js @@ -558,6 +558,10 @@ Timeline.TimelineLoader = (function () { }); }; + DataEnhancer.prototype.clearUpCustomFieldColumns = function() { + this.timeline.clearUpCustomFieldColumns(); + }; + /** * TimelineLoader * @@ -676,7 +680,7 @@ Timeline.TimelineLoader = (function () { }; TimelineLoader.prototype.registerGlobalElements = function () { - var projectPrefix = this.globalPrefix + + var projectPrefix = this.globalPrefix + this.options.project_prefix + "/" + this.options.project_id; @@ -1087,6 +1091,8 @@ Timeline.TimelineLoader = (function () { // have the following signature: // // function (e, data) {} + this.dataEnhancer.clearUpCustomFieldColumns(); + return data; }; diff --git a/features/step_definitions/custom_field_steps.rb b/features/step_definitions/custom_field_steps.rb index ddf5809f24..15b56adf66 100644 --- a/features/step_definitions/custom_field_steps.rb +++ b/features/step_definitions/custom_field_steps.rb @@ -96,6 +96,12 @@ Given(/^the custom field "(.*?)" is enabled for the project "(.*?)"$/) do |field project.save! end +Given(/^the custom field "(.*?)" is disabled for the project "(.*?)"$/) do |field_name, project_name| + custom_field = WorkPackageCustomField.find_by_name(field_name) + project = Project.find_by_name(project_name) + + project.work_package_custom_fields.delete custom_field +end Given /^the custom field "(.+)" is( not)? summable$/ do |field_name, negative| custom_field = WorkPackageCustomField.find_by_name(field_name) diff --git a/features/step_definitions/timelines_then_steps.rb b/features/step_definitions/timelines_then_steps.rb index 2e99780bb1..9a2097f754 100644 --- a/features/step_definitions/timelines_then_steps.rb +++ b/features/step_definitions/timelines_then_steps.rb @@ -34,6 +34,12 @@ Then(/^I should see a modal window with selector "(.*?)"$/) do |selector| dialog["class"].include?("ui-dialog-content").should be_true end +Then(/^I should see the column "(.*?)" immediately before the column "(.*?)" in the timelines table$/) do |content1, content2| + steps %Q{ + Then I should see the column "#{content1}" immediately before the column "#{content2}" in ".tl-main-table" + } +end + Then(/^I should see the column "(.*?)" before the column "(.*?)" in the timelines table$/) do |content1, content2| steps %Q{ Then I should see the column "#{content1}" before the column "#{content2}" in ".tl-main-table" @@ -51,6 +57,19 @@ Then(/^I should see the column "(.*?)" before the column "(.*?)" in "(.*?)"$/) d elements[-1].should have_xpath("preceding::th/descendant-or-self::*[text()='#{content1}']") end +Then(/^I should see the column "(.*?)" immediately before the column "(.*?)" in "(.*?)"$/) do |content1, content2, table| + #Check that the things really exist and wait until the exist + steps %Q{ + Then I should see "#{content1}" within "#{table}" + Then I should see "#{content2}" within "#{table}" + } + + elements = find_lowest_containing_element content1, table + following = elements[0].first :xpath, 'following::th' + following.text.should == content2 +end + + Then(/^I should see a modal window$/) do steps 'Then I should see a modal window with selector "#modalDiv"' end diff --git a/features/timelines/timeline_view_custom_fields.feature b/features/timelines/timeline_view_custom_fields.feature index 9a67e1971a..96728e44ac 100644 --- a/features/timelines/timeline_view_custom_fields.feature +++ b/features/timelines/timeline_view_custom_fields.feature @@ -36,7 +36,7 @@ Feature: Timeline View Tests | login | manager | And there is a role "manager" And the role "manager" may have the following rights: - | view_work_packages | + | view_work_packages | | view_timelines | | edit_timelines | | edit_work_packages | @@ -61,11 +61,14 @@ Feature: Timeline View Tests | cfBool | bool | true | true | | | cfList | list | true | true | A,B,C | | cfUser | user | true | true | | + | cfLocal | bool | false | true | | And the custom field "cfBool" is activated for type "Phase" And the custom field "cfList" is activated for type "Phase" And the custom field "cfUser" is activated for type "Phase" + And the custom field "cfLocal" is activated for type "Phase" + And the custom field "cfLocal" is enabled for the project "ecookbook" @javascript Scenario: Select custom field column @@ -79,6 +82,17 @@ Feature: Timeline View Tests And I should see the column "Start date" before the column "cfBool" in the timelines table And I should see the column "cfBool" before the column "End date" in the timelines table + @javascript + Scenario: Select custom field column and deactivate custom field + Given I am working in the timeline "Testline" of the project called "ecookbook" + When there is a timeline "Testline" for project "ecookbook" + And I set the columns shown in the timeline to: + | start_date | + | cf_4 | + | due_date | + And the custom field "cfLocal" is disabled for the project "ecookbook" + Then I should see the column "Start date" immediately before the column "End date" in the timelines table + @javascript Scenario: Show Boolean Custom Field Value Given I am working in the timeline "Testline" of the project called "ecookbook" @@ -116,4 +130,4 @@ Feature: Timeline View Tests | cf_3 | | due_date | And I wait for timeline to load table - Then I should see "Bob Bobbit" in the row of the work package "user" \ No newline at end of file + Then I should see "Bob Bobbit" in the row of the work package "user" From 507a3cf4262926684114549b2093178d7f8fbe88 Mon Sep 17 00:00:00 2001 From: Till Breuer Date: Fri, 28 Feb 2014 17:46:58 +0100 Subject: [PATCH 11/12] Refactor custom field step --- features/step_definitions/custom_field_steps.rb | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/features/step_definitions/custom_field_steps.rb b/features/step_definitions/custom_field_steps.rb index 15b56adf66..bf982e1dff 100644 --- a/features/step_definitions/custom_field_steps.rb +++ b/features/step_definitions/custom_field_steps.rb @@ -65,16 +65,11 @@ Given /^the work package "(.+?)" has the custom field "(.+?)" set to "(.+?)"$/ d wp = InstanceFinder.find(WorkPackage, wp_name) custom_field = InstanceFinder.find(WorkPackageCustomField, field_name) - set = false + custom_value = wp.custom_values.detect {|cv| cv.custom_field_id == custom_field.id} - wp.custom_values.each do |custom_value| - if custom_value.custom_field_id == custom_field.id then - set = true - custom_value.value = value - end - end - - if !set then + if custom_value + custom_value.value = value + else wp.custom_values.build(:custom_field => custom_field, :value => value) end From c81684916e49b48f6e8ad46223c65d6a71f22449 Mon Sep 17 00:00:00 2001 From: Till Breuer Date: Sun, 2 Mar 2014 19:12:56 +0100 Subject: [PATCH 12/12] Show filter field set if a boolean custom field filter has been applied --- app/assets/javascripts/timelines_select_boxes.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/timelines_select_boxes.js b/app/assets/javascripts/timelines_select_boxes.js index fad878f25c..41ca4872cf 100644 --- a/app/assets/javascripts/timelines_select_boxes.js +++ b/app/assets/javascripts/timelines_select_boxes.js @@ -154,8 +154,19 @@ jQuery(document).ready(function($) { ((e.attr("type") === "text" || e.attr("type") === "hidden") && e.val() !== "" && !e.hasClass("select2-input")) || (e.attr("type") === "checkbox" && e.attr("checked")) ) { - e.closest("fieldset").removeClass('collapsed').children("div").show(); + showFieldSet(e); } }); + + $('#content').find('.cf_boolean_select').each(function (index, field) { + field = $(field); + if (field.val() !== '') { + showFieldSet(field); + } + }); + + function showFieldSet(field) { + field.closest("fieldset").removeClass('collapsed').children("div").show(); + } });