From 59028035df703eb58dba133cd399f8bfda2841b0 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Fri, 18 Jan 2019 17:46:57 +0000 Subject: [PATCH] FIX: Update about/license URLs when updating theme from remote source --- app/models/remote_theme.rb | 4 ++-- spec/models/remote_theme_spec.rb | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/models/remote_theme.rb b/app/models/remote_theme.rb index 70ac5160937..6b2e84de72d 100644 --- a/app/models/remote_theme.rb +++ b/app/models/remote_theme.rb @@ -139,8 +139,8 @@ class RemoteTheme < ActiveRecord::Base theme.set_field(target: :translations, name: locale, value: value) end - self.license_url ||= theme_info["license_url"] - self.about_url ||= theme_info["about_url"] + self.license_url = theme_info["license_url"] + self.about_url = theme_info["about_url"] if !skip_update self.remote_updated_at = Time.zone.now diff --git a/spec/models/remote_theme_spec.rb b/spec/models/remote_theme_spec.rb index 9e7789bc01f..490ac1694ea 100644 --- a/spec/models/remote_theme_spec.rb +++ b/spec/models/remote_theme_spec.rb @@ -18,11 +18,11 @@ describe RemoteTheme do repo_dir end - def about_json(love_color: "FAFAFA", color_scheme_name: "Amazing") + def about_json(love_color: "FAFAFA", color_scheme_name: "Amazing", about_url: "https://www.site.com/about") <<~JSON { "name": "awesome theme", - "about_url": "https://www.site.com/about", + "about_url": "#{about_url}", "license_url": "https://www.site.com/license", "assets": { "font": "assets/awesome.woff2" @@ -99,7 +99,7 @@ describe RemoteTheme do expect(scheme.colors.find_by(name: 'love').hex).to eq('fafafa') File.write("#{initial_repo}/common/header.html", "I AM UPDATED") - File.write("#{initial_repo}/about.json", about_json(love_color: "EAEAEA")) + File.write("#{initial_repo}/about.json", about_json(love_color: "EAEAEA", about_url: "https://newsite.com/about")) File.write("#{initial_repo}/settings.yml", "integer_setting: 32") `cd #{initial_repo} && git add settings.yml` @@ -131,6 +131,7 @@ describe RemoteTheme do expect(@theme.settings.first.value).to eq(32) expect(remote.remote_updated_at).to eq(time) + expect(remote.about_url).to eq("https://newsite.com/about") # It should be able to remove old colors as well File.write("#{initial_repo}/about.json", about_json(love_color: "BABABA", color_scheme_name: "Amazing 2"))