diff --git a/app/controllers/contracts_controller.rb b/app/controllers/contracts_controller.rb
index a623b11..c80eda6 100644
--- a/app/controllers/contracts_controller.rb
+++ b/app/controllers/contracts_controller.rb
@@ -6,6 +6,10 @@ class ContractsController < InheritedResources::Base
before_filter :find_project
before_filter :authorize
+ def create
+ create! { contract_url(@project, resource) }
+ end
+
protected
def begin_of_association_chain
diff --git a/app/views/contracts/index.html.erb b/app/views/contracts/index.html.erb
index 48ec5ae..7522af2 100644
--- a/app/views/contracts/index.html.erb
+++ b/app/views/contracts/index.html.erb
@@ -14,7 +14,7 @@
<% collection.each do |contract| %>
<% content_tag_for(:tr, contract) do %>
- <%= h contract.id %> |
+ <%= link_to(h(contract.id), contract_path(@project, contract)) %> |
<%= h contract.name %> |
<%= h contract.account_executive.name %> |
<%= h format_date(contract.end_date) %> |
diff --git a/app/views/contracts/show.html.erb b/app/views/contracts/show.html.erb
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/app/views/contracts/show.html.erb
@@ -0,0 +1 @@
+
diff --git a/init.rb b/init.rb
index 46d8414..622e3f7 100644
--- a/init.rb
+++ b/init.rb
@@ -14,7 +14,7 @@ Redmine::Plugin.register :redmine_contracts do
requires_redmine_plugin :redmine_rate, :version_or_higher => '0.1.0'
project_module :contracts do
- permission :manage_budget, {:contracts => [:index, :new] }, :public => true
+ permission :manage_budget, {:contracts => [:index, :new, :create, :show] }, :public => true
end
menu(:project_menu,
diff --git a/test/integration/contracts_new_test.rb b/test/integration/contracts_new_test.rb
index 4b20cbb..c38d554 100644
--- a/test/integration/contracts_new_test.rb
+++ b/test/integration/contracts_new_test.rb
@@ -15,4 +15,30 @@ class ContractsNewTest < ActionController::IntegrationTest
assert_select "form#new_contract"
end
+ should "create a new contract" do
+ @account_executive = User.generate!
+
+ visit_contracts_for_project(@project)
+ click_link 'New Contract'
+ assert_response :success
+
+ fill_in "Name", :with => 'A New Contract'
+ select @account_executive.name, :from => "Account Executive"
+ fill_in "Start", :with => '2010-01-01'
+ fill_in "End Date", :with => '2010-12-31'
+ select "Net 30", :from => "Payment Terms"
+
+ click_button "Create Contract"
+
+ assert_response :success
+ assert_template 'contracts/show'
+
+ @contract = Contract.last
+ assert_equal "A New Contract", @contract.name
+ assert_equal @account_executive, @contract.account_executive
+ assert_equal '2010-01-01', @contract.start_date.to_s
+ assert_equal '2010-12-31', @contract.end_date.to_s
+ assert_equal 'net_30', @contract.payment_terms
+
+ end
end