Test for absence of done_ratio in case of respective Setting

pull/2794/head
Alexander Bach 10 years ago
parent 83c6b2d1ea
commit e5792ae904
  1. 20
      spec/lib/api/v3/work_packages/form/work_package_payload_representer_spec.rb
  2. 2
      spec/lib/api/v3/work_packages/work_package_representer_spec.rb

@ -29,13 +29,13 @@
require 'spec_helper' require 'spec_helper'
describe ::API::V3::WorkPackages::Form::WorkPackagePayloadRepresenter do describe ::API::V3::WorkPackages::Form::WorkPackagePayloadRepresenter do
let(:work_package) { let(:work_package) do
FactoryGirl.build(:work_package, FactoryGirl.build(:work_package,
start_date: Date.today.to_datetime, start_date: Date.today.to_datetime,
due_date: Date.today.to_datetime, due_date: Date.today.to_datetime,
created_at: DateTime.now, created_at: DateTime.now,
updated_at: DateTime.now) updated_at: DateTime.now)
} end
let(:representer) { described_class.create(work_package) } let(:representer) { described_class.create(work_package) }
before { allow(work_package).to receive(:lock_version).and_return(1) } before { allow(work_package).to receive(:lock_version).and_return(1) }
@ -79,10 +79,18 @@ describe ::API::V3::WorkPackages::Form::WorkPackagePayloadRepresenter do
end end
describe 'percentage done' do describe 'percentage done' do
it { is_expected.to have_json_path('percentageDone') } context 'percentage done enabled' do
it { is_expected.to have_json_type(Integer).at_path('percentageDone') } it { is_expected.to have_json_path('percentageDone') }
it do it { is_expected.to have_json_type(Integer).at_path('percentageDone') }
is_expected.to be_json_eql(work_package.done_ratio.to_json).at_path('percentageDone') it do
is_expected.to be_json_eql(work_package.done_ratio.to_json).at_path('percentageDone')
end
end
context 'percentage done disabled' do
before { allow(Setting).to receive(:work_package_done_ratio).and_return('disabled') }
it { is_expected.to_not have_json_path('percentageDone') }
end end
end end

@ -218,7 +218,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do
context 'setting disabled' do context 'setting disabled' do
before { allow(Setting).to receive(:work_package_done_ratio).and_return('disabled') } before { allow(Setting).to receive(:work_package_done_ratio).and_return('disabled') }
it { expect(parse_json(subject)['percentageDone']).to be_nil } it { is_expected.to_not have_json_path('percentageDone') }
end end
end end
end end

Loading…
Cancel
Save