Sha256: 603d79c004f87d9c00213548a02d35459bc012149bd6b4cb6f11ab86214a2209

Contents?: true

Size: 1.11 KB

Versions: 8

Compression:

Stored size: 1.11 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe 'Namespaced settings' do
  it 'sets namespaced' do
    Settings.ns(:other).test = 'test'
  end

  it 'reads namespaced from cache' do
    ns = Settings.ns(:other)
    ns.test = 'test'
    ns.test.should eq 'test'
  end

  it 'reads namespaced from db' do
    Settings.ns(:other).test = 'test'
    Settings.ns(:other).test.should eq 'test'
  end

  it 'destroys' do
    Settings.ns(:other).test = 'test'
    Settings.ns(:other).destroy_all!
    Settings.ns(:other).test.should eq ''
  end

  it 'sets type' do
    expect {
      Settings.ns(:other).set(:phone, 'test', type: 'phone')
    }.to raise_error
    Settings.ns(:other).set(:phone, '906 111 11 11', type: 'phone')
    Settings.get(:phone, ns: 'other').phone_type?.should be_true
    Settings.get(:phone, ns: 'other').val.city.should eq '906'
    Settings.get(:phone, ns: 'other').val.formatted_subscriber.should eq '111-11-11'

    ns = Settings.ns(:other)
    ns.get(:phone).phone_type?.should be_true
    ns.get(:phone).val.city.should eq '906'
    ns.get(:phone).val.formatted_subscriber.should eq '111-11-11'
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rails_admin_settings-0.6.8 spec/namespaced_spec.rb
rails_admin_settings-0.6.7 spec/namespaced_spec.rb
rails_admin_settings-0.6.5 spec/namespaced_spec.rb
rails_admin_settings-0.6.4 spec/namespaced_spec.rb
rails_admin_settings-0.6.3 spec/namespaced_spec.rb
rails_admin_settings-0.6.2 spec/namespaced_spec.rb
rails_admin_settings-0.6.1 spec/namespaced_spec.rb
rails_admin_settings-0.6.0 spec/namespaced_spec.rb