forked from amatsuda/active_decorator
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests for partial variables decoration
- Loading branch information
Showing
5 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,16 @@ | ||
<% @authors.each do |author| %> | ||
<%= author.name %> | ||
<%= author.reverse_name %> | ||
<% if params[:partial] == 'collection' %> | ||
<%= render author.books %> | ||
<% elsif params[:partial] == 'locals' %> | ||
<% author.books.each do |book| %> | ||
<%= render :partial => 'books/book_locals', :locals => {:b => book} %> | ||
<% end %> | ||
<% else %> | ||
<% author.books.each do |book| %> | ||
<%= render book %> | ||
<% end %> | ||
<% end %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<%= book.title %> | ||
<%= book.reverse_title %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<%= b.title %> | ||
<%= b.upcased_title %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require 'spec_helper' | ||
|
||
feature 'decorating partial object' do | ||
background do | ||
Author.create! :name => 'aamine' | ||
nari = Author.create! :name => 'nari' | ||
nari.books.create! :title => 'the gc book' | ||
end | ||
after do | ||
Book.delete_all | ||
Author.delete_all | ||
end | ||
|
||
scenario 'decorating implicit @object' do | ||
visit '/authors' | ||
page.should have_content 'the gc book' | ||
page.should have_content 'the gc book'.reverse | ||
end | ||
|
||
scenario 'decorating implicit @collection' do | ||
visit '/authors?partial=collection' | ||
page.should have_content 'the gc book' | ||
page.should have_content 'the gc book'.reverse | ||
end | ||
|
||
scenario 'decorating objects in @locals' do | ||
visit '/authors?partial=locals' | ||
page.should have_content 'the gc book' | ||
page.should have_content 'the gc book'.upcase | ||
end | ||
end |