A platform for community discussion. Free, open, simple.
DEV: Add a spec helper to upload a theme or a component
Loïc Guitautebed9cd013c4
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rbindex efc714b2116..ee345027b31 100644--- a/spec/support/helpers.rb+++ b/spec/support/helpers.rb@@ -6,6 +6,11 @@ GIT_INITIAL_BRANCH_SUPPORTED =module Helpersextend ActiveSupport::Concern+ class NotAThemeError < StandardError+ end+ class NotAComponentThemeError < StandardError+ end+def self.next_seq@next_seq = (@next_seq || 0) + 1end@@ -244,7 +249,8 @@ module Helperstheme = RemoteTheme.import_theme_from_directory(directory_from_caller)if theme.component- raise "Uploaded theme is a theme component, please use the `upload_theme_component` method instead."+ raise NotAThemeError,+ "Uploaded theme is a theme component, please use the `upload_theme_component` method instead."endtheme.set_default! if set_theme_as_default@@ -273,13 +279,20 @@ module Helperstheme = RemoteTheme.import_theme_from_directory(directory_from_caller)if !theme.component- raise "Uploaded theme is not a theme component, please use the `upload_theme` method instead."+ raise NotAComponentThemeError,+ "Uploaded theme is not a theme component, please use the `upload_theme` method instead."endTheme.find(parent_theme_id).child_themes << themethemeend+ def upload_theme_or_component+ upload_theme+ rescue NotAThemeError+ upload_theme_component+ end+# Runs named migration for a given theme.## @params [Theme] theme The theme to run the migration for.