From bdeb19059aa64ab3aa9320dcdafd27a6e70dddb2 Mon Sep 17 00:00:00 2001 From: Ulrich Gabor Date: Tue, 5 Jan 2016 15:08:26 +0100 Subject: [PATCH] Test for issue 1709; parent relations with localized and non-localized sources --- .../features/i18n_mixed_sources.feature | 38 +++++++++++++++++++ .../fixtures/i18n-mixed-sources/config.rb | 1 + .../i18n-mixed-sources/locales/en.yml | 4 ++ .../i18n-mixed-sources/locales/es.yml | 4 ++ .../i18n-mixed-sources/source/a/sub.html.erb | 9 +++++ .../source/b/index.html.erb | 9 +++++ .../i18n-mixed-sources/source/index.html.erb | 9 +++++ .../source/localizable/a/index.html.erb | 9 +++++ .../source/localizable/b/sub.html.erb | 9 +++++ .../source/localizable/index.html.erb | 9 +++++ 10 files changed, 101 insertions(+) create mode 100644 middleman-core/features/i18n_mixed_sources.feature create mode 100644 middleman-core/fixtures/i18n-mixed-sources/config.rb create mode 100644 middleman-core/fixtures/i18n-mixed-sources/locales/en.yml create mode 100644 middleman-core/fixtures/i18n-mixed-sources/locales/es.yml create mode 100644 middleman-core/fixtures/i18n-mixed-sources/source/a/sub.html.erb create mode 100644 middleman-core/fixtures/i18n-mixed-sources/source/b/index.html.erb create mode 100644 middleman-core/fixtures/i18n-mixed-sources/source/index.html.erb create mode 100644 middleman-core/fixtures/i18n-mixed-sources/source/localizable/a/index.html.erb create mode 100644 middleman-core/fixtures/i18n-mixed-sources/source/localizable/b/sub.html.erb create mode 100644 middleman-core/fixtures/i18n-mixed-sources/source/localizable/index.html.erb diff --git a/middleman-core/features/i18n_mixed_sources.feature b/middleman-core/features/i18n_mixed_sources.feature new file mode 100644 index 00000000..c287d871 --- /dev/null +++ b/middleman-core/features/i18n_mixed_sources.feature @@ -0,0 +1,38 @@ +Feature: i18n merging path trees + + Scenario: Mixing localized and non-localized sources and merging the path trees (see issue #1709) + Given a fixture app "i18n-test-app" + And a file named "config.rb" with: + """ + activate :i18n, mount_at_root: :en, langs: [:en, :es] + """ + Given the Server is running at "i18n-mixed-sources" + + When I go to "/" + Then I should see "Current locale: en" + Then I should see "path: is-localized Home" + When I go to "/es" + Then I should see "Current locale: es" + Then I should see "path: is-localized Home" + + When I go to "/a/" + Then I should see "Current locale: en" + Then I should see "path: is-localized Home # a/index.html.erb" + When I go to "/es/a/" + Then I should see "Current locale: es" + Then I should see "path: is-localized Home # a/index.html.erb" + + When I go to "/b/" + Then I should see "Current locale: en" + Then I should see "path: is-localized Home # b/index.html.erb" + + When I go to "/a/sub.html" + Then I should see "Current locale: en" + Then I should see "path: is-localized Home # a/index.html.erb # a/sub.html.erb" + + When I go to "/b/sub.html" + Then I should see "Current locale: en" + Then I should see "path: is-localized Home # b/index.html.erb # b/sub.html.erb" + Then I should see "Current locale: es" + When I go to "/es/b/sub.html" + Then I should see "path: is-localized Home # b/index.html.erb # b/sub.html.erb" diff --git a/middleman-core/fixtures/i18n-mixed-sources/config.rb b/middleman-core/fixtures/i18n-mixed-sources/config.rb new file mode 100644 index 00000000..4815436f --- /dev/null +++ b/middleman-core/fixtures/i18n-mixed-sources/config.rb @@ -0,0 +1 @@ +activate :i18n, mount_at_root: :en, langs: [:en, :es] diff --git a/middleman-core/fixtures/i18n-mixed-sources/locales/en.yml b/middleman-core/fixtures/i18n-mixed-sources/locales/en.yml new file mode 100644 index 00000000..91519342 --- /dev/null +++ b/middleman-core/fixtures/i18n-mixed-sources/locales/en.yml @@ -0,0 +1,4 @@ +--- +en: + greetings: "Howdy" + hi: "Hello" \ No newline at end of file diff --git a/middleman-core/fixtures/i18n-mixed-sources/locales/es.yml b/middleman-core/fixtures/i18n-mixed-sources/locales/es.yml new file mode 100644 index 00000000..38c7e31e --- /dev/null +++ b/middleman-core/fixtures/i18n-mixed-sources/locales/es.yml @@ -0,0 +1,4 @@ +--- +es: + greetings: "Como Esta?" + hi: "Hola" \ No newline at end of file diff --git a/middleman-core/fixtures/i18n-mixed-sources/source/a/sub.html.erb b/middleman-core/fixtures/i18n-mixed-sources/source/a/sub.html.erb new file mode 100644 index 00000000..b92d02f1 --- /dev/null +++ b/middleman-core/fixtures/i18n-mixed-sources/source/a/sub.html.erb @@ -0,0 +1,9 @@ +--- +title: a/sub.html.erb +--- +Current locale: <%= I18n.locale %> +path: <%= +hierarchy = [current_page] +hierarchy.unshift hierarchy.first.parent while hierarchy.first.parent +hierarchy.collect {|page| page.data.title }.join(" # ") +%> diff --git a/middleman-core/fixtures/i18n-mixed-sources/source/b/index.html.erb b/middleman-core/fixtures/i18n-mixed-sources/source/b/index.html.erb new file mode 100644 index 00000000..c238d925 --- /dev/null +++ b/middleman-core/fixtures/i18n-mixed-sources/source/b/index.html.erb @@ -0,0 +1,9 @@ +--- +title: b/index.html.erb +--- +Current locale: <%= I18n.locale %> +path: <%= +hierarchy = [current_page] +hierarchy.unshift hierarchy.first.parent while hierarchy.first.parent +hierarchy.collect {|page| page.data.title }.join(" # ") +%> diff --git a/middleman-core/fixtures/i18n-mixed-sources/source/index.html.erb b/middleman-core/fixtures/i18n-mixed-sources/source/index.html.erb new file mode 100644 index 00000000..1d47ed2e --- /dev/null +++ b/middleman-core/fixtures/i18n-mixed-sources/source/index.html.erb @@ -0,0 +1,9 @@ +--- +title: non-localized Home +--- +Current locale: <%= I18n.locale %> +path: <%= +hierarchy = [current_page] +hierarchy.unshift hierarchy.first.parent while hierarchy.first.parent +hierarchy.collect {|page| page.data.title }.join(" # ") +%> diff --git a/middleman-core/fixtures/i18n-mixed-sources/source/localizable/a/index.html.erb b/middleman-core/fixtures/i18n-mixed-sources/source/localizable/a/index.html.erb new file mode 100644 index 00000000..dc8aa51f --- /dev/null +++ b/middleman-core/fixtures/i18n-mixed-sources/source/localizable/a/index.html.erb @@ -0,0 +1,9 @@ +--- +title: a/index.html.erb +--- +Current locale: <%= I18n.locale %> +path: <%= +hierarchy = [current_page] +hierarchy.unshift hierarchy.first.parent while hierarchy.first.parent +hierarchy.collect {|page| page.data.title }.join(" # ") +%> diff --git a/middleman-core/fixtures/i18n-mixed-sources/source/localizable/b/sub.html.erb b/middleman-core/fixtures/i18n-mixed-sources/source/localizable/b/sub.html.erb new file mode 100644 index 00000000..40d65942 --- /dev/null +++ b/middleman-core/fixtures/i18n-mixed-sources/source/localizable/b/sub.html.erb @@ -0,0 +1,9 @@ +--- +title: b/sub.html.erb +--- +Current locale: <%= I18n.locale %> +path: <%= +hierarchy = [current_page] +hierarchy.unshift hierarchy.first.parent while hierarchy.first.parent +hierarchy.collect {|page| page.data.title }.join(" # ") +%> diff --git a/middleman-core/fixtures/i18n-mixed-sources/source/localizable/index.html.erb b/middleman-core/fixtures/i18n-mixed-sources/source/localizable/index.html.erb new file mode 100644 index 00000000..79449a82 --- /dev/null +++ b/middleman-core/fixtures/i18n-mixed-sources/source/localizable/index.html.erb @@ -0,0 +1,9 @@ +--- +title: is-localized Home +--- +Current locale: <%= I18n.locale %> +path: <%= +hierarchy = [current_page] +hierarchy.unshift hierarchy.first.parent while hierarchy.first.parent +hierarchy.collect {|page| page.data.title }.join(" # ") +%>