Skip to content

Commit 576545c

Browse files
committed
Add specs for page_meta_information and page_title_with_translations helper methods.
1 parent 7dca437 commit 576545c

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

pages/spec/helpers/refinery/pages/admin/pages_helper_spec.rb

+49
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,55 @@ module Admin
4949
end
5050
end
5151
end
52+
53+
describe "#page_meta_information" do
54+
let(:page) { FactoryGirl.build(:page) }
55+
56+
context "when show_in_menu is false" do
57+
it "adds 'hidden' label" do
58+
page.show_in_menu = false
59+
60+
helper.page_meta_information(page).should eq("<span class=\"label\">hidden</span>")
61+
end
62+
end
63+
64+
context "when draft is true" do
65+
it "adds 'draft' label" do
66+
page.draft = true
67+
68+
helper.page_meta_information(page).should eq("<span class=\"label notice\">draft</span>")
69+
end
70+
end
71+
end
72+
73+
describe "#page_title_with_translations" do
74+
let(:page) { FactoryGirl.build(:page) }
75+
76+
before do
77+
Globalize.with_locale(:en) do
78+
page.title = "draft"
79+
page.save!
80+
end
81+
82+
Globalize.with_locale(:lv) do
83+
page.title = "melnraksts"
84+
page.save!
85+
end
86+
end
87+
88+
context "when title is present" do
89+
it "returns it" do
90+
helper.page_title_with_translations(page).should eq("draft")
91+
end
92+
end
93+
94+
context "when title for current locale isn't available" do
95+
it "returns existing title from translations" do
96+
Refinery::Page::Translation.where(:locale => :en).first.delete
97+
helper.page_title_with_translations(page).should eq("melnraksts")
98+
end
99+
end
100+
end
52101
end
53102
end
54103
end

0 commit comments

Comments
 (0)