Add controller spec for cost object updates via context menu

pull/6827/head
Till Breuer 11 years ago committed by Sebastian Schuster
parent c6b80df6a7
commit 2a27acc187
  1. 24
      spec/controllers/work_packages_bulk_controller_spec.rb
  2. 4
      spec/models/work_package_spec.rb

@ -0,0 +1,24 @@
require 'spec_helper'
describe WorkPackages::BulkController do
let(:project) { FactoryGirl.create(:project_with_types) }
let(:controller_role) { FactoryGirl.build(:role, :permissions => [:view_work_packages, :edit_work_packages]) }
let(:user) { FactoryGirl.create :user, member_in_project: project, member_through_role: controller_role }
let(:cost_object) { FactoryGirl.create :cost_object, project: project }
let(:work_package) { FactoryGirl.create(:work_package, project: project) }
before do
User.stub(:current).and_return user
end
describe :update do
context 'when a cost report is assigned' do
before { put :update, ids: [work_package.id], work_package: {cost_object_id: cost_object.id} }
subject { work_package.reload.cost_object.try :id }
it { should == cost_object.id }
end
end
end

@ -11,8 +11,8 @@ describe WorkPackage do
let(:project2) { FactoryGirl.create(:project_with_types, types: project.types) }
let(:work_package) { FactoryGirl.create(:work_package, :project => project,
:type => project.types.first,
:author => user) }
:type => project.types.first,
:author => user) }
let!(:cost_entry) { FactoryGirl.create(:cost_entry, work_package: work_package, project: project, units: 3, spent_on: Date.today, user: user, comments: "test entry") }
let!(:cost_object) { FactoryGirl.create(:cost_object, project: project) }

Loading…
Cancel
Save