fix the build

This commit is contained in:
Régis Hanol 2015-09-09 15:34:53 +02:00
parent 31e8309f05
commit 3ee5cea9e2
3 changed files with 15 additions and 18 deletions

View file

@ -13,16 +13,14 @@ class SiteSettings::DbProvider
def all
return [] unless table_exists?
# note, not leaking out AR records, cause I want all editing to happen
# via this API
SqlBuilder.new("select name, data_type, value from #{@model.table_name}").map_exec(OpenStruct)
# Not leaking out AR records, cause I want all editing to happen via this API
SqlBuilder.new("SELECT name, data_type, value FROM #{@model.table_name}").map_exec(OpenStruct)
end
def find(name)
return nil unless table_exists?
# note, not leaking out AR records, cause I want all editing to happen
# via this API
# Not leaking out AR records, cause I want all editing to happen via this API
SqlBuilder.new("SELECT name, data_type, value FROM #{@model.table_name} WHERE name = :name")
.map_exec(OpenStruct, name: name)
.first

View file

@ -24,6 +24,9 @@ class SiteSettings::LocalProcessProvider
end
def save(name, value, data_type)
# NOTE: convert to string to simulate the conversion that is happening
# when using DbProvider
value = value.to_s
settings[name] = Setting.new(name, value, data_type)
end

View file

@ -3,27 +3,23 @@ require_dependency 'site_setting_extension'
require_dependency 'site_settings/local_process_provider'
describe SiteSettingExtension do
let :provider do
let :provider_local do
SiteSettings::LocalProcessProvider.new
end
def new_settings(provider=nil)
def new_settings(provider)
Class.new do
extend SiteSettingExtension
self.provider = provider if provider
self.provider = provider
end
end
let :settings do
new_settings(provider)
new_settings(provider_local)
end
let :settings2 do
new_settings(provider)
end
let :settings_db do
new_settings
new_settings(provider_local)
end
describe "refresh!" do
@ -238,10 +234,10 @@ describe SiteSettingExtension do
end
it 'should coerce correctly' do
settings_db.setting(:test_int_enum, 1, enum: TestIntEnumClass)
settings_db.test_int_enum = "2"
settings_db.refresh!
expect(settings_db.test_int_enum).to eq(2)
settings.setting(:test_int_enum, 1, enum: TestIntEnumClass)
settings.test_int_enum = "2"
settings.refresh!
expect(settings.test_int_enum).to eq(2)
end
end