From 2eb2839ab09c4df6919c0ebf2119f7fcef49635d Mon Sep 17 00:00:00 2001 From: Julian Herrero Date: Sat, 19 Jan 2019 15:45:37 +0100 Subject: [PATCH] Reload path for sluggable models Sluggable models can update the slug when updating new translations, so we make sure the path is correct before using it. --- spec/shared/features/translatable.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spec/shared/features/translatable.rb b/spec/shared/features/translatable.rb index 4994ab1d5..7ce96e54e 100644 --- a/spec/shared/features/translatable.rb +++ b/spec/shared/features/translatable.rb @@ -12,6 +12,7 @@ shared_examples "translatable" do |factory_name, path_name, input_fields, textar let(:input_fields) { input_fields } # So it's accessible by methods let(:textarea_fields) { textarea_fields } # So it's accessible by methods + let(:path_name) { path_name } # So it's accessible by methods let(:fields) { input_fields + textarea_fields.keys } @@ -136,6 +137,7 @@ shared_examples "translatable" do |factory_name, path_name, input_fields, textar expect(page).not_to have_css "#error_explanation" expect(page).not_to have_link "English" + path = updated_path_for(translatable) visit path expect(page).not_to have_link "English" @@ -257,6 +259,10 @@ shared_examples "translatable" do |factory_name, path_name, input_fields, textar end end +def updated_path_for(resource) + send(path_name, *resource_hierarchy_for(resource.reload)) +end + def text_for(field, locale) I18n.with_locale(locale) do "#{translatable_class.human_attribute_name(field)} #{language_texts[locale]}"