From 6efa89a93f3fc6aa157a853f27003a7ba4bbb7b4 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Wed, 23 Jun 2010 16:43:14 -0700 Subject: [PATCH] [#4181] Redirect DeliverablesController list and show to the Contract page. --- app/controllers/deliverables_controller.rb | 8 ++++++++ init.rb | 2 +- test/integration/deliverables_list_test.rb | 19 +++++++++++++++++++ test/integration/deliverables_show_test.rb | 19 +++++++++++++++++++ 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 test/integration/deliverables_list_test.rb create mode 100644 test/integration/deliverables_show_test.rb diff --git a/app/controllers/deliverables_controller.rb b/app/controllers/deliverables_controller.rb index 373c36d..a6390cf 100644 --- a/app/controllers/deliverables_controller.rb +++ b/app/controllers/deliverables_controller.rb @@ -6,12 +6,20 @@ class DeliverablesController < InheritedResources::Base before_filter :find_contract before_filter :authorize + def index + redirect_to contract_url(@project, @contract) + end + def create @deliverable = begin_of_association_chain.deliverables.build(params[:deliverable]) @deliverable.type = 'FixedDeliverable' create! { contract_url(@project, @contract) } end + def show + redirect_to contract_url(@project, @contract) + end + def destroy destroy! { contract_url(@project, @contract) } end diff --git a/init.rb b/init.rb index 5b630df..4373f90 100644 --- a/init.rb +++ b/init.rb @@ -16,7 +16,7 @@ Redmine::Plugin.register :redmine_contracts do project_module :contracts do permission(:manage_budget, { :contracts => [:index, :new, :create, :show, :edit, :update, :destroy], - :deliverables => [:new, :create, :destroy] + :deliverables => [:index, :new, :create, :show, :destroy] }, :public => true) end diff --git a/test/integration/deliverables_list_test.rb b/test/integration/deliverables_list_test.rb new file mode 100644 index 0000000..706bfac --- /dev/null +++ b/test/integration/deliverables_list_test.rb @@ -0,0 +1,19 @@ +require 'test_helper' + +class DeliverablesListTest < ActionController::IntegrationTest + include Redmine::I18n + + def setup + @project = Project.generate!(:identifier => 'main') + @contract = Contract.generate!(:project => @project) + @manager = User.generate! + @deliverable = FixedDeliverable.generate!(:contract => @contract, :manager => @manager) + end + + should "redirect to the contract page" do + visit "/projects/#{@project.identifier}/contracts/#{@contract.id}/deliverables/" + assert_response :success + assert_template 'contracts/show' + + end +end diff --git a/test/integration/deliverables_show_test.rb b/test/integration/deliverables_show_test.rb new file mode 100644 index 0000000..62902d5 --- /dev/null +++ b/test/integration/deliverables_show_test.rb @@ -0,0 +1,19 @@ +require 'test_helper' + +class DeliverablesShowTest < ActionController::IntegrationTest + include Redmine::I18n + + def setup + @project = Project.generate!(:identifier => 'main') + @contract = Contract.generate!(:project => @project) + @manager = User.generate! + @deliverable = FixedDeliverable.generate!(:contract => @contract, :manager => @manager) + end + + should "redirect to the contract page" do + visit "/projects/#{@project.identifier}/contracts/#{@contract.id}/deliverables/#{@deliverable.id}" + assert_response :success + assert_template 'contracts/show' + + end +end