https://svn.lrde.epita.fr/svn/ranch/trunk
Index: ChangeLog
from Nicolas Desprès <nicolas.despres(a)gmail.com>
Make sure the bench name list is uniq.
* web/ranch/app/views/benches/list.rhtml: Adapt to the list content.
We store only name now.
* web/ranch/app/controllers/benches_controller.rb: Stores only name
and ensure the list is uniq.
* web/ranch/test/fixtures/benches.yml: Add a bench with the same
name of another.
* web/ranch/test/functional/benches_controller_test.rb: Test this
issue.
app/controllers/benches_controller.rb | 6 ++++--
app/views/benches/list.rhtml | 7 ++++---
test/fixtures/benches.yml | 17 ++++++++++++-----
test/functional/benches_controller_test.rb | 6 +++++-
4 files changed, 25 insertions(+), 11 deletions(-)
Index: web/ranch/app/views/benches/list.rhtml
--- web/ranch/app/views/benches/list.rhtml (revision 10)
+++ web/ranch/app/views/benches/list.rhtml (working copy)
@@ -7,12 +7,13 @@
<p>
<center>
<table>
- <% for bench in @benches %>
+ <% for bench_name in @benches_name %>
<tr>
<td>
- <%= link_to bench.name, :controller => "reggraph",
+ <%= link_to bench_name, :controller => "graph",
:action => "index",
- :bench => bench %>
+ :project_id => @project.id,
+ :bench_name => bench_name %>
</td>
</tr>
<% end %>
Index: web/ranch/app/controllers/benches_controller.rb
--- web/ranch/app/controllers/benches_controller.rb (revision 10)
+++ web/ranch/app/controllers/benches_controller.rb (working copy)
@@ -4,9 +4,11 @@
def list
@project = Project.find_by_id(@params[:project_id])
- @benches = Bench.find_all_by_project_id((a)project.id).sort do |a, b|
- a.name <=> b.name
+ @benches_name = Bench.find_all_by_project_id((a)project.id).collect do |x|
+ x.name
end
+ @benches_name.uniq!
+ @benches_name.sort!
end
end
Index: web/ranch/test/fixtures/benches.yml
--- web/ranch/test/fixtures/benches.yml (revision 10)
+++ web/ranch/test/fixtures/benches.yml (working copy)
@@ -1,19 +1,26 @@
# Read about fixtures at
http://ar.rubyonrails.org/classes/Fixtures.html
-determinize:
- id: 1
+<% id = 1 %>
+
+determinize_r1:
+ id: <% id += 1 %>
+ project_id: 1
+ name: determinize
+determinize_r2:
+ id: <% id += 1 %>
project_id: 1
name: determinize
+
quotient:
- id: 2
+ id: <% id += 1 %>
project_id: 1
name: quotient
open:
- id: 3
+ id: <% id += 1 %>
project_id: 2
name: open
close:
- id: 4
+ id: <% id += 1 %>
project_id: 2
name: close
Index: web/ranch/test/functional/benches_controller_test.rb
--- web/ranch/test/functional/benches_controller_test.rb (revision 10)
+++ web/ranch/test/functional/benches_controller_test.rb (working copy)
@@ -21,6 +21,10 @@
assert_template 'list'
assert_not_nil assigns(:project)
- assert_not_nil assigns(:benches)
+ assert_not_nil assigns(:benches_name)
+
+ assert_equal(1,
+ (assigns(:benches_name).find_all{|x| x == 'determinize'}).size,
+ 'there is duplicated benches name')
end
end