hint of a site metafield is localized
did
committed Jan 24, 2016
commit e49fba0f520a0389e8bb42fb4bccf682197e8603
Showing 3
changed files with
5 additions
and 2 deletions
locomotive/steam/adapters/filesystem/sanitizers/site.rb b/lib/locomotive/steam/adapters/filesystem/sanitizers/site.rb
+2
-0
| @@ | @@ -27,6 +27,8 @@ module Locomotive::Steam |
| def parse_metafields(fields) | |
| fields.map do |name, attributes| | |
| if attributes # Hash | |
| + | attributes[:hint] = { default: attributes[:hint] } if attributes[:hint].is_a?(String) |
| + | |
| { name: { default: name.to_s }.merge(attributes.delete(:name)) }.merge(attributes) | |
| else # Array | |
| { name: { default: name.to_s } } | |
spec/fixtures/default/config/metafields_schema.yml
+1
-0
| @@ | @@ -13,6 +13,7 @@ Github: |
| name: | |
| fr: "Url de l'API" | |
| type: string | |
| + | hint: "API endpoint" |
| default: https://api.github.com/repos/locomotivecms/engine/issues?state=opened | |
| "Expire in": | |
| name: | |
spec/unit/adapters/filesystem/sanitizers/site_spec.rb
+2
-2
| @@ | @@ -26,7 +26,7 @@ describe Locomotive::Steam::Adapters::Filesystem::Sanitizers::Site do |
| describe 'with a schema' do | |
| # see the metafields_schema.yml in the fixtures folder | |
| - | let(:schema) { {:Social=>{:name=>{:fr=>"Social (FR)"}, :position=>1, :fields=>["Facebook ID", "Google ID"]}, :Github=>{:position=>0, :fields=>{:"API url"=>{:name=>{:fr=>"Url de l'API"}, :type=>"string", :default=>"https://api.github.com/repos/locomotivecms/engine/issues?state=opened"}, :"Expire in"=>{:name=>{:fr=>"Expire dans"}, :hint=>{:en=>"Cache - In milliseconds", :fr=>"Cache - En millisecondes"}, :type=>"integer", :min=>0, :max=>3600}}}} } |
| + | let(:schema) { {:Social=>{:name=>{:fr=>"Social (FR)"}, :position=>1, :fields=>["Facebook ID", "Google ID"]}, :Github=>{:position=>0, :fields=>{:"API url"=>{:name=>{:fr=>"Url de l'API"}, :type=>"string", :hint=>"API endpoint", :default=>"https://api.github.com/repos/locomotivecms/engine/issues?state=opened"}, :"Expire in"=>{:name=>{:fr=>"Expire dans"}, :hint=>{:en=>"Cache - In milliseconds", :fr=>"Cache - En millisecondes"}, :type=>"integer", :min=>0, :max=>3600}}}} } |
| it 'loads the full schema' do | |
| # First namespace | |
| @@ | @@ -38,7 +38,7 @@ describe Locomotive::Steam::Adapters::Filesystem::Sanitizers::Site do |
| expect(subject[1][:name]).to eq(default: 'Github') | |
| expect(subject[1][:position]).to eq 0 | |
| expect(subject[1][:fields].count).to eq 2 | |
| - | expect(subject[1][:fields][0]).to eq(name: { default: 'API url', fr: "Url de l'API" }, type: 'string', default: 'https://api.github.com/repos/locomotivecms/engine/issues?state=opened') |
| + | expect(subject[1][:fields][0]).to eq(name: { default: 'API url', fr: "Url de l'API" }, type: 'string', hint: { default: 'API endpoint' }, default: 'https://api.github.com/repos/locomotivecms/engine/issues?state=opened') |
| end | |
| end | |