FEATURE: allow themes to share color schemes

This commit is contained in:
Sam
2017-04-17 15:56:13 -04:00
parent 1872a1714f
commit 5e3a0846f7
14 changed files with 137 additions and 16 deletions

View File

@ -18,13 +18,26 @@ describe RemoteTheme do
repo_dir
end
let :initial_repo do
setup_git_repo(
"about.json" => '{
def about_json(options = {})
options[:love] ||= "FAFAFA"
<<JSON
{
"name": "awesome theme",
"about_url": "https://www.site.com/about",
"license_url": "https://www.site.com/license"
}',
"license_url": "https://www.site.com/license",
"color_schemes": {
"Amazing": {
"love": "#{options[:love]}"
}
}
}
JSON
end
let :initial_repo do
setup_git_repo(
"about.json" => about_json,
"desktop/desktop.scss" => "body {color: red;}",
"common/header.html" => "I AM HEADER",
"common/random.html" => "I AM SILLY",
@ -62,9 +75,16 @@ describe RemoteTheme do
expect(remote.remote_updated_at).to eq(time)
scheme = ColorScheme.find_by(theme_id: @theme.id)
expect(scheme.name).to eq("Amazing")
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: "EAEAEA"))
`cd #{initial_repo} && git commit -am "update"`
time = Time.new('2001')
freeze_time time
@ -77,6 +97,10 @@ describe RemoteTheme do
@theme.save
@theme.reload
scheme = ColorScheme.find_by(theme_id: @theme.id)
expect(scheme.name).to eq("Amazing")
expect(scheme.colors.find_by(name: 'love').hex).to eq('eaeaea')
mapped = Hash[*@theme.theme_fields.map{|f| ["#{f.target}-#{f.name}", f.value]}.flatten]
expect(mapped["0-header"]).to eq("I AM UPDATED")