From 4d40c029ee9a57c558258554f51e4dd7dc024ca3 Mon Sep 17 00:00:00 2001 From: Jan Sandbrink Date: Thu, 3 Sep 2015 16:56:40 +0200 Subject: [PATCH] Adapt to enforced current_user in representers --- lib/api/v3/budgets/budgets_by_project_api.rb | 3 ++- lib/api/v3/cost_entries/aggregated_cost_entry_representer.rb | 2 +- lib/api/v3/cost_entries/cost_entries_by_work_package_api.rb | 3 ++- spec/lib/api/v3/budgets/budget_representer_spec.rb | 2 +- spec/lib/api/v3/cost_entries/cost_entry_representer_spec.rb | 2 +- spec/lib/api/v3/cost_types/cost_type_representer_spec.rb | 2 +- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/api/v3/budgets/budgets_by_project_api.rb b/lib/api/v3/budgets/budgets_by_project_api.rb index 39c905f3f4..b82088c144 100644 --- a/lib/api/v3/budgets/budgets_by_project_api.rb +++ b/lib/api/v3/budgets/budgets_by_project_api.rb @@ -40,7 +40,8 @@ module API get do BudgetCollectionRepresenter.new(@budgets, @budgets.count, - api_v3_paths.budgets_by_project(@project.id)) + api_v3_paths.budgets_by_project(@project.id), + current_user: current_user) end end end diff --git a/lib/api/v3/cost_entries/aggregated_cost_entry_representer.rb b/lib/api/v3/cost_entries/aggregated_cost_entry_representer.rb index b58c3d5d79..63e98d0ee3 100644 --- a/lib/api/v3/cost_entries/aggregated_cost_entry_representer.rb +++ b/lib/api/v3/cost_entries/aggregated_cost_entry_representer.rb @@ -27,7 +27,7 @@ module API @cost_type = cost_type @spent_units = units - super(nil) + super(nil, current_user: nil) end linked_property :cost_type, diff --git a/lib/api/v3/cost_entries/cost_entries_by_work_package_api.rb b/lib/api/v3/cost_entries/cost_entries_by_work_package_api.rb index 9eb5b04f58..720789af84 100644 --- a/lib/api/v3/cost_entries/cost_entries_by_work_package_api.rb +++ b/lib/api/v3/cost_entries/cost_entries_by_work_package_api.rb @@ -45,7 +45,8 @@ module API cost_entries = @cost_helper.cost_entries CostEntryCollectionRepresenter.new(cost_entries, cost_entries.count, - path) + path, + current_user: current_user) end end diff --git a/spec/lib/api/v3/budgets/budget_representer_spec.rb b/spec/lib/api/v3/budgets/budget_representer_spec.rb index eed330d0e9..627084d107 100644 --- a/spec/lib/api/v3/budgets/budget_representer_spec.rb +++ b/spec/lib/api/v3/budgets/budget_representer_spec.rb @@ -35,7 +35,7 @@ describe ::API::V3::Budgets::BudgetRepresenter do updated_on: Date.today) } - let(:representer) { described_class.new(budget) } + let(:representer) { described_class.new(budget, current_user: user) } context 'generation' do subject(:generated) { representer.to_json } diff --git a/spec/lib/api/v3/cost_entries/cost_entry_representer_spec.rb b/spec/lib/api/v3/cost_entries/cost_entry_representer_spec.rb index c6ca2fd810..f8cc37eaae 100644 --- a/spec/lib/api/v3/cost_entries/cost_entry_representer_spec.rb +++ b/spec/lib/api/v3/cost_entries/cost_entry_representer_spec.rb @@ -23,7 +23,7 @@ describe ::API::V3::CostEntries::CostEntryRepresenter do include API::V3::Utilities::PathHelper let(:cost_entry) { FactoryGirl.build(:cost_entry, id: 42) } - let(:representer) { described_class.new(cost_entry) } + let(:representer) { described_class.new(cost_entry, current_user: double('current_user')) } subject { representer.to_json } diff --git a/spec/lib/api/v3/cost_types/cost_type_representer_spec.rb b/spec/lib/api/v3/cost_types/cost_type_representer_spec.rb index f28899481f..51515af930 100644 --- a/spec/lib/api/v3/cost_types/cost_type_representer_spec.rb +++ b/spec/lib/api/v3/cost_types/cost_type_representer_spec.rb @@ -23,7 +23,7 @@ describe ::API::V3::CostTypes::CostTypeRepresenter do include API::V3::Utilities::PathHelper let(:cost_type) { FactoryGirl.build_stubbed(:cost_type) } - let(:representer) { described_class.new(cost_type) } + let(:representer) { described_class.new(cost_type, current_user: double('current_user')) } subject { representer.to_json }