@@ -9,60 +9,11 @@ module Alchemy
99 let ( :page ) { mock_model ( Page , urlname : "testpage" , language_code : "en" ) }
1010
1111 context "page path helpers" do
12- describe "#show_page_path_params" do
13- subject ( :show_page_path_params ) { helper . show_page_path_params ( page ) }
14-
15- context "if prefix_locale? is false" do
16- before do
17- expect ( helper ) . to receive ( :prefix_locale? ) . with ( page . language_code ) { false }
18- end
19-
20- it "returns a Hash with urlname and no locale parameter" do
21- expect ( show_page_path_params ) . to include ( urlname : "testpage" )
22- expect ( show_page_path_params ) . to_not include ( locale : "en" )
23- end
24-
25- context "with additional parameters" do
26- subject ( :show_page_path_params ) do
27- helper . show_page_path_params ( page , { query : "test" } )
28- end
29-
30- it "returns a Hash with urlname, no locale and query parameter" do
31- expect ( show_page_path_params ) . to \
32- include ( urlname : "testpage" , query : "test" )
33- expect ( show_page_path_params ) . to_not \
34- include ( locale : "en" )
35- end
36- end
37- end
38-
39- context "if prefix_locale? is false" do
40- before do
41- expect ( helper ) . to receive ( :prefix_locale? ) . with ( page . language_code ) { true }
42- end
43-
44- it "returns a Hash with urlname and locale parameter" do
45- expect ( show_page_path_params ) . to \
46- include ( urlname : "testpage" , locale : "en" )
47- end
48-
49- context "with additional parameters" do
50- subject ( :show_page_path_params ) do
51- helper . show_page_path_params ( page , { query : "test" } )
52- end
53-
54- it "returns a Hash with urlname, locale and query parameter" do
55- expect ( show_page_path_params ) . to \
56- include ( urlname : "testpage" , locale : "en" , query : "test" )
57- end
58- end
59- end
60- end
61-
6212 describe "#show_alchemy_page_path" do
6313 context "when prefix_locale? set to true" do
6414 before do
65- expect ( helper ) . to receive ( :prefix_locale? ) . with ( page . language_code ) { true }
15+ allow ( page ) . to receive ( :url_path ) . with ( { } ) . and_return ( "/#{ page . language_code } /testpage" )
16+ allow ( page ) . to receive ( :url_path ) . with ( { query : "test" } ) . and_return ( "/#{ page . language_code } /testpage?query=test" )
6617 end
6718
6819 it "should return the correct relative path string" do
@@ -77,7 +28,8 @@ module Alchemy
7728
7829 context "when prefix_locale? set to false" do
7930 before do
80- expect ( helper ) . to receive ( :prefix_locale? ) . with ( page . language_code ) { false }
31+ allow ( page ) . to receive ( :url_path ) . with ( { } ) . and_return ( "/testpage" )
32+ allow ( page ) . to receive ( :url_path ) . with ( { query : "test" } ) . and_return ( "/testpage?query=test" )
8133 end
8234
8335 it "should return the correct relative path string" do
@@ -94,33 +46,35 @@ module Alchemy
9446 describe "#show_alchemy_page_url" do
9547 context "when prefix_locale? set to true" do
9648 before do
97- expect ( helper ) . to receive ( :prefix_locale? ) . with ( page . language_code ) { true }
49+ allow ( page ) . to receive ( :url_path ) . with ( { } ) . and_return ( "/#{ page . language_code } /testpage" )
50+ allow ( page ) . to receive ( :url_path ) . with ( { query : "test" } ) . and_return ( "/#{ page . language_code } /testpage?query=test" )
9851 end
9952
10053 it "should return the correct url string" do
10154 expect ( helper . show_alchemy_page_url ( page ) ) . to \
102- eq ( "http:// #{ helper . request . host } /#{ page . language_code } /testpage" )
55+ eq ( "/#{ page . language_code } /testpage" )
10356 end
10457
10558 it "should return the correct url string with additional parameters" do
10659 expect ( helper . show_alchemy_page_url ( page , { query : "test" } ) ) . to \
107- eq ( "http:// #{ helper . request . host } /#{ page . language_code } /testpage?query=test" )
60+ eq ( "/#{ page . language_code } /testpage?query=test" )
10861 end
10962 end
11063
11164 context "when prefix_locale? set to false" do
11265 before do
113- expect ( helper ) . to receive ( :prefix_locale? ) . with ( page . language_code ) { false }
66+ allow ( page ) . to receive ( :url_path ) . with ( { } ) . and_return ( "/testpage" )
67+ allow ( page ) . to receive ( :url_path ) . with ( { query : "test" } ) . and_return ( "/testpage?query=test" )
11468 end
11569
11670 it "should return the correct url string" do
11771 expect ( helper . show_alchemy_page_url ( page ) ) . to \
118- eq ( "http:// #{ helper . request . host } /testpage" )
72+ eq ( "/testpage" )
11973 end
12074
12175 it "should return the correct url string with additional parameter" do
12276 expect ( helper . show_alchemy_page_url ( page , { query : "test" } ) ) . to \
123- eq ( "http:// #{ helper . request . host } /testpage?query=test" )
77+ eq ( "/testpage?query=test" )
12478 end
12579 end
12680 end
0 commit comments