Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
39 additions
and
6 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
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,11 @@ | ||
class OrganizationDecorator < Draper::Decorator | ||
delegate_all | ||
|
||
def leagues | ||
@leagues ||= model.leagues | ||
end | ||
|
||
def title | ||
"View Organization | " + model.name | ||
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
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,23 @@ | ||
require 'spec_helper' | ||
|
||
describe OrganizationDecorator do | ||
let(:organization) {Organization.new} | ||
subject do | ||
organization.leagues.build(:name => 'foo') | ||
OrganizationDecorator.new(organization) | ||
end | ||
|
||
describe 'leagues' do | ||
it 'shows the leagues' do | ||
subject.leagues.size.should == 1 | ||
end | ||
end | ||
|
||
describe 'title' do | ||
let(:title) { "title"} | ||
before { subject.name = title} | ||
it 'shows the title' do | ||
subject.title.should == "View Organization | #{title}" | ||
end | ||
end | ||
end |