Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/tests/locale #3356

Merged
merged 1 commit into from
Mar 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions pages/spec/features/refinery/pages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -365,28 +365,39 @@ def standard_page_menu_items_exist?
context "with multiple locales" do

describe "redirects" do
before { allow(Refinery::I18n).to receive(:frontend_locales).and_return([:en, :ru]) }
after { allow(Refinery::I18n).to receive(:frontend_locales).and_call_original }
let(:en_page_title) { 'News' }
let(:en_page_slug) { 'news' }
let(:ru_page_title) { 'Новости' }
let(:ru_page_slug_encoded) { '%D0%BD%D0%BE%D0%B2%D0%BE%D1%81%D1%82%D0%B8' }
let!(:news_page) do
_page = Globalize.with_locale(:en) { Page.create title: en_page_title }
@page = Globalize.with_locale(:en) { Page.create title: en_page_title }
Globalize.with_locale(:ru) do
_page.title = ru_page_title
_page.save
@page.title = ru_page_title
@page.save
end

_page
@page
end

before {
allow(Refinery::I18n).to receive(:frontend_locales).and_return([:en, :ru])
allow(Page).to receive(:fast_menu).and_return([@page])
}

after { allow(Refinery::I18n).to receive(:frontend_locales).and_call_original }

it "should recognise when default locale is in the path" do
visit "/en/#{en_page_slug}"

expect(current_path).to eq("/en/#{en_page_slug}")
end

it "should display the default locale when locale is not in the path" do
visit "/#{en_page_slug}"

expect(current_path).to eq("/#{en_page_slug}")
end

it "should redirect to default locale slug" do
visit "/#{ru_page_slug_encoded}"

Expand All @@ -401,6 +412,14 @@ def standard_page_menu_items_exist?
visit "/en/#{en_page_slug}"
end

it "should not have the locale in the menu href link" do
visit "/en/#{en_page_slug}"

within('.menu') do
expect(page).to have_selector(:css, "a[href='/#{en_page_slug}']")
end
end

describe "nested page" do
let(:nested_page_title) { 'nested_page' }
let(:nested_page_slug) { 'nested_page' }
Expand Down Expand Up @@ -428,4 +447,4 @@ def standard_page_menu_items_exist?
end
end
end
end
end