Merge branch 'dev' into fix/14596-details-pane-long-attributes

pull/2011/head
Alex Coles 10 years ago
commit 5dc4356350
  1. 14
      app/controllers/work_packages_controller.rb
  2. 6
      app/helpers/work_packages_helper.rb
  3. 2
      config/locales/js-de.yml
  4. 25
      karma/tests/work_packages/tabs/user-activity-directive-test.js
  5. 9
      lib/api/v3/work_packages/work_package_representer.rb
  6. 2
      public/templates/work_packages/tabs/_user_activity.html
  7. 22
      spec/controllers/work_packages_controller_spec.rb
  8. 17
      spec/lib/api/v3/work_packages/work_package_representer_spec.rb

@ -61,8 +61,10 @@ class WorkPackagesController < ApplicationController
:protect_from_unauthorized_export, :only => [:index, :all, :preview]
before_filter :load_query, :only => :index
# The order in here is actually imporant for the angular client.
# The order in here is actually important for the angular client.
# The first 6 are always to be displayed.
# Beware that 'percentageDone' may be removed if the related setting is
# disabled.
DEFAULT_WORK_PACKAGE_PROPERTIES = [:status, :assignee, :responsible,
:date, :percentageDone, :priority,
:category, :estimatedTime, :versionName, :spentTime]
@ -460,7 +462,15 @@ class WorkPackagesController < ApplicationController
parse_preview_data_helper :work_package, [:notes, :description]
end
def hook_overview_attributes(initial_attributes = DEFAULT_WORK_PACKAGE_PROPERTIES)
def enabled_default_work_package_properties
@enabled_default_work_package_properties ||= begin
properties = DEFAULT_WORK_PACKAGE_PROPERTIES
properties.delete(:percentageDone) if Setting.work_package_done_ratio == 'disabled'
properties
end
end
def hook_overview_attributes(initial_attributes = enabled_default_work_package_properties)
attributes = initial_attributes
call_hook(:work_packages_overview_attributes,
project: @project,

@ -30,12 +30,6 @@
module WorkPackagesHelper
include AccessibilityHelper
def work_package_api_done_ratio_if_enabled(api, issue)
if Setting.work_package_done_ratio != 'disabled'
api.done_ratio issue.done_ratio
end
end
def work_package_breadcrumb
full_path = if !@project.nil?
link_to(I18n.t(:label_work_package_plural), project_path(@project, {:jump => current_menu_item}))

@ -304,7 +304,7 @@ de:
no_results:
title: Keine Arbeitspakete anzuzeigen
description_html: |
<p>Es wurden entweder keine Arbeitspaketet erzeugt oder alle Arbeitspakete wurden ausgefiltert.</p>
<p>Es wurden entweder keine Arbeitspakete erzeugt oder alle Arbeitspakete wurden ausgefiltert.</p>
properties:
assignee: "Zugewiesen an"
author: "Autor"

@ -101,9 +101,32 @@ describe('userActivity Directive', function() {
expect(element.find('.avatar').attr('title')).to.equal('John Doe');
});
describe('when being empty', function() {
beforeEach(function() {
scope.activity.links.user.fetch = function() {
return {
then: function(cb) {
cb({
props: {
id: 1,
name: "John Doe",
avatar: '',
status: 1
}
});
}
};
};
compile();
});
it('should not be rendered', function() {
expect(element.find('.avatar')).to.have.length(0);
});
});
});
});
});
});

@ -216,7 +216,10 @@ module API
property :start_date, getter: -> (*) { model.start_date.to_datetime.utc.iso8601 unless model.start_date.nil? }, render_nil: true
property :due_date, getter: -> (*) { model.due_date.to_datetime.utc.iso8601 unless model.due_date.nil? }, render_nil: true
property :estimated_time, render_nil: true
property :percentage_done, render_nil: true
property :percentage_done,
render_nil: true,
exec_context: :decorator,
setter: -> (value, *) { represented.percentage_done = value }
property :version_id, getter: -> (*) { model.fixed_version.try(:id) }, render_nil: true
property :version_name, getter: -> (*) { model.fixed_version.try(:name) }, render_nil: true
property :project_id, getter: -> (*) { model.project.id }
@ -265,6 +268,10 @@ module API
def visible_children
@visible_children ||= represented.model.children.find_all { |child| child.visible? }
end
def percentage_done
represented.percentage_done unless Setting.work_package_done_ratio == 'disabled'
end
end
end
end

@ -17,7 +17,7 @@
ng-click="editComment()"></i>
</div>
</div>
<img class="avatar" ng-src="{{ userAvatar }}" alt="Avatar" title="{{userName}}" />
<img class="avatar" ng-src="{{ userAvatar }}" alt="Avatar" title="{{userName}}" ng-if="userAvatar" />
<span class="user" ng-if="userActive"><a ng-href="{{ userPath(userId) }}" name="{{ currentAnchor }}" ng-bind="userName"></a></span>
<span class="user" ng-if="!userActive">{{ userName }}</span>
<span class="date">{{ I18n.t('js.label_commented_on') }} <date-time date-time-value="activity.props.createdAt"/></date-time>

@ -151,6 +151,28 @@ describe WorkPackagesController, :type => :controller do
allow(query).to receive(:as_json).and_return("")
end
describe 'settings passed to front-end client' do
describe 'visible attributes' do
let(:call_action) { get('index', :project_id => project.id) }
context 'all attributes visible' do
before { call_action }
it { expect(assigns(:enabled_default_work_package_properties)).to match_array(WorkPackagesController::DEFAULT_WORK_PACKAGE_PROPERTIES) }
end
context 'done ratio is disabled' do
before do
allow(Setting).to receive(:work_package_done_ratio).and_return('disabled')
call_action
end
it { expect(assigns(:enabled_default_work_package_properties)).not_to include(:percentageDone) }
end
end
end
describe 'html' do
let(:call_action) { get('index', :project_id => project.id) }
before { call_action }

@ -39,7 +39,8 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do
id: 42,
created_at: DateTime.now,
updated_at: DateTime.now,
category: category
category: category,
done_ratio: 50
)
}
let(:category) { FactoryGirl.build(:category) }
@ -95,6 +96,20 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do
it { is_expected.to have_json_path('estimatedTime/value') }
end
describe 'percentageDone' do
describe 'work package done ratio setting behavior' do
context 'setting enabled' do
it { expect(parse_json(subject)['percentageDone']).to eq(50) }
end
context 'setting disabled' do
before { allow(Setting).to receive(:work_package_done_ratio).and_return('disabled') }
it { expect(parse_json(subject)['percentageDone']).to be_nil }
end
end
end
describe '_links' do
it { is_expected.to have_json_type(Object).at_path('_links') }

Loading…
Cancel
Save