-
Notifications
You must be signed in to change notification settings - Fork 526
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #438 from haines/issue_436
Store helper proxies instead of raw view contexts
- Loading branch information
Showing
10 changed files
with
150 additions
and
38 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
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
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
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 |
---|---|---|
@@ -1,39 +1,39 @@ | ||
shared_examples_for "view helpers" do |subject| | ||
describe "#helpers" do | ||
it "returns the class's helpers" do | ||
expect(subject.helpers).to be subject.class.helpers | ||
it "returns the current view context" do | ||
Draper::ViewContext.stub current: :current_view_context | ||
expect(subject.helpers).to be :current_view_context | ||
end | ||
|
||
it "is aliased to #h" do | ||
expect(subject.h).to be subject.helpers | ||
Draper::ViewContext.stub current: :current_view_context | ||
expect(subject.h).to be :current_view_context | ||
end | ||
end | ||
|
||
describe "#localize" do | ||
it "delegates to #helpers" do | ||
subject.stub helpers: double | ||
subject.helpers.should_receive(:localize).with(:an_object, some: "parameter") | ||
subject.localize(:an_object, some: "parameter") | ||
end | ||
|
||
it "is aliased to #l" do | ||
subject.stub helpers: double | ||
subject.helpers.should_receive(:localize).with(:an_object, some: "parameter") | ||
subject.l(:an_object, some: "parameter") | ||
end | ||
end | ||
|
||
describe ".helpers" do | ||
it "returns a HelperProxy" do | ||
expect(subject.class.helpers).to be_a Draper::HelperProxy | ||
end | ||
|
||
it "memoizes" do | ||
helpers = subject.class.helpers | ||
|
||
expect(subject.class.helpers).to be helpers | ||
it "returns the current view context" do | ||
Draper::ViewContext.stub current: :current_view_context | ||
expect(subject.class.helpers).to be :current_view_context | ||
end | ||
|
||
it "is aliased to .h" do | ||
expect(subject.class.h).to be subject.class.helpers | ||
Draper::ViewContext.stub current: :current_view_context | ||
expect(subject.class.h).to be :current_view_context | ||
end | ||
end | ||
end |