A platform for community discussion. Free, open, simple.
DEV: themes_install_task find existing themes consistently (#9424)
Mark VanLandingham40531fc85e30
diff --git a/app/services/themes_install_task.rb b/app/services/themes_install_task.rbindex 36ece33dea5..9999de7ab80 100644--- a/app/services/themes_install_task.rb+++ b/app/services/themes_install_task.rb@@ -40,8 +40,15 @@ class ThemesInstallTaskendend+ def repo_name+ @url.gsub(Regexp.union('[email protected]:', 'https://github.com/', '.git'), '')+ end+def theme_exists?- @remote_theme = RemoteTheme.find_by(remote_url: @url, branch: @options.fetch(:branch, nil))+ @remote_theme = RemoteTheme+ .where("remote_url like ?", "%#{repo_name}%")+ .where(branch: @options.fetch(:branch, nil))+ .first@theme = @remote_theme&.theme@theme.present?enddiff --git a/spec/services/themes_spec.rb b/spec/services/themes_spec.rbindex 2410a5e04c0..bc8e8a59521 100644--- a/spec/services/themes_spec.rb+++ b/spec/services/themes_spec.rb@@ -141,4 +141,23 @@ describe ThemesInstallTask doendendend+ describe '#theme_exists?' do+ it 'can use https or ssh and find the same repo' do+ remote_theme = RemoteTheme.create!(+ remote_url: "https://github.com/org/testtheme.git",+ local_version: "a2ec030e551fc8d8579790e1954876fe769fe40a",+ remote_version: "21122230dbfed804067849393c3332083ddd0c07",+ commits_behind: 2+ )+ Fabricate(:theme, remote_theme: remote_theme)++ # https+ installer = ThemesInstallTask.new({ "url": "https://github.com/org/testtheme" })+ expect(installer.theme_exists?).to eq(true)++ # ssh+ installer = ThemesInstallTask.new({ "url": "[email protected]:org/testtheme.git" })+ expect(installer.theme_exists?).to eq(true)+ end+ endend