From 1729bc48c944b07926e3a304121fdeb1ca8081a0 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Thu, 17 Jun 2010 15:39:12 -0700 Subject: [PATCH] [#4177] Created a Contract list view based on the comps. --- app/views/contracts/index.html.erb | 26 ++++++++++++++++++++++++- config/locales/en.yml | 4 ++++ test/integration/contracts_list_test.rb | 25 +++++++++++++++++++----- test/test_helper.rb | 8 ++++++++ 4 files changed, 57 insertions(+), 6 deletions(-) diff --git a/app/views/contracts/index.html.erb b/app/views/contracts/index.html.erb index 5418338..17b5126 100644 --- a/app/views/contracts/index.html.erb +++ b/app/views/contracts/index.html.erb @@ -1 +1,25 @@ -Yay! +<% if collection.empty? %> +

<%= l(:label_no_data) %>

+<% else %> + + + + + <%# TODO: Status %> + <%# TODO: Type %> + + <%# TODO: Total Budget %> + + + + <% collection.each do |contract| %> + <% content_tag_for(:tr, contract) do %> + + + + + <% end %> + <% end %> + +
<%= l(:field_id) %><%= l(:field_name) %><%= l(:field_account_executive_short) %><%= l(:field_end_date) %>
<%= h contract.id %><%= h contract.name %><%= h contract.account_executive.name %><%= h format_date(contract.end_date) %>
+<% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 8c9c313..fe309b9 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2,4 +2,8 @@ en: field_end_date: End Date field_executed: Executed text_contracts: Contracts + field_id: ID + field_account_executive: Account Executive + field_account_executive_short: "Acct. Mgr." + field_end_date: "End Date" diff --git a/test/integration/contracts_list_test.rb b/test/integration/contracts_list_test.rb index abff216..9f2863e 100644 --- a/test/integration/contracts_list_test.rb +++ b/test/integration/contracts_list_test.rb @@ -1,17 +1,32 @@ require 'test_helper' class ContractsListTest < ActionController::IntegrationTest + include Redmine::I18n + def setup @project = Project.generate! @contract = Contract.generate!(:project => @project) + @contract2 = Contract.generate!(:project => @project) end should "allow any user to list the contracts on a project" do - visit_project(@project) - click_link "Contracts" - - assert_response :success - assert_template 'contracts/index' + visit_contracts_for_project(@project) end + should "list all contracts for the project" do + visit_contracts_for_project(@project) + + 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)}/ + end + end + + end + + should "not list contracts from other projects" + end diff --git a/test/test_helper.rb b/test/test_helper.rb index 5d68d8e..9673290 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -31,6 +31,14 @@ module IntegrationTestHelper assert_response :success end + def visit_contracts_for_project(project) + visit_project(project) + click_link "Contracts" + + assert_response :success + assert_template 'contracts/index' + end + def assert_forbidden assert_response :forbidden assert_template 'common/403'