diff --git a/app/controllers/contracts_controller.rb b/app/controllers/contracts_controller.rb
index c91f866..a623b11 100644
--- a/app/controllers/contracts_controller.rb
+++ b/app/controllers/contracts_controller.rb
@@ -6,6 +6,12 @@ class ContractsController < InheritedResources::Base
before_filter :find_project
before_filter :authorize
+ protected
+
+ def begin_of_association_chain
+ @project
+ end
+
private
def find_project
diff --git a/app/views/contracts/index.html.erb b/app/views/contracts/index.html.erb
index 17b5126..48ec5ae 100644
--- a/app/views/contracts/index.html.erb
+++ b/app/views/contracts/index.html.erb
@@ -14,10 +14,10 @@
<% collection.each do |contract| %>
<% content_tag_for(:tr, contract) do %>
- <%= h contract.id %> |
- <%= h contract.name %> |
- <%= h contract.account_executive.name %> |
- <%= h format_date(contract.end_date) %> |
+ <%= h contract.id %> |
+ <%= h contract.name %> |
+ <%= h contract.account_executive.name %> |
+ <%= h format_date(contract.end_date) %> |
<% end %>
<% end %>
diff --git a/test/integration/contracts_list_test.rb b/test/integration/contracts_list_test.rb
index 9f2863e..e57492f 100644
--- a/test/integration/contracts_list_test.rb
+++ b/test/integration/contracts_list_test.rb
@@ -4,9 +4,18 @@ class ContractsListTest < ActionController::IntegrationTest
include Redmine::I18n
def setup
- @project = Project.generate!
+ @project = Project.generate!(:identifier => 'main')
@contract = Contract.generate!(:project => @project)
@contract2 = Contract.generate!(:project => @project)
+
+ @other_project = Project.generate!(:identifier => 'other')
+ @other_contract = Contract.generate!(:project => @other_project)
+ [@project,
+ @other_project,
+ @contract,
+ @contract2,
+ @other_contract
+ ].map {|c| c.reload }
end
should "allow any user to list the contracts on a project" do
@@ -18,15 +27,22 @@ class ContractsListTest < ActionController::IntegrationTest
assert_select "table#contracts" do
[@contract, @contract2].each do |contract|
- assert_select "td", :text => /#{contract.id}/
- assert_select "td", :text => /#{contract.name}/
- assert_select "td", :text => /#{contract.account_executive.name}/
- assert_select "td", :text => /#{format_date(contract.end_date)}/
+ assert_select "td.id", :text => /#{contract.id}/
+ assert_select "td.name", :text => /#{contract.name}/
+ assert_select "td.account-executive", :text => /#{contract.account_executive.name}/
+ assert_select "td.end-date", :text => /#{format_date(contract.end_date)}/
end
end
end
- should "not list contracts from other projects"
+ should "not list contracts from other projects" do
+ visit_contracts_for_project(@project)
+
+ assert_select "table#contracts" do
+ assert_select "td", :text => /#{@other_contract.name}/, :count => 0
+ end
+
+ end
end