Sha256: 61a1285ef431f4037cb77f534e731fc0c5560c2b637a85baf575487d49ec14b3

Contents?: true

Size: 1.23 KB

Versions: 8

Compression:

Stored size: 1.23 KB

Contents

require 'spec_helper'

describe "Serialization" do
  let!(:user) do
    User.create! :name => 'Mr. White' do |user|
      user.settings(:dashboard).theme = 'white'
      user.settings(:calendar).scope = 'all'
    end
  end

  describe 'created settings' do
    it 'should be serialized' do
      user.reload

      dashboard_settings = user.setting_objects.where(:var => 'dashboard').first
      calendar_settings = user.setting_objects.where(:var => 'calendar').first

      dashboard_settings.var.should == 'dashboard'
      dashboard_settings.value.should eq({'theme' => 'white'})

      calendar_settings.var.should == 'calendar'
      calendar_settings.value.should eq({'scope' => 'all'})
    end
  end

  describe 'updated settings' do
    it 'should be serialized' do
      user.settings(:dashboard).update_attributes! :smart => true

      dashboard_settings = user.setting_objects.where(:var => 'dashboard').first
      calendar_settings = user.setting_objects.where(:var => 'calendar').first

      dashboard_settings.var.should == 'dashboard'
      dashboard_settings.value.should eq({'theme' => 'white', 'smart' => true})

      calendar_settings.var.should == 'calendar'
      calendar_settings.value.should eq({'scope' => 'all'})
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ledermann-rails-settings-2.3.0 spec/serialize_spec.rb
ledermann-rails-settings-2.2.1 spec/serialize_spec.rb
ledermann-rails-settings-2.2.0 spec/serialize_spec.rb
ledermann-rails-settings-2.1.0 spec/serialize_spec.rb
ledermann-rails-settings-2.0.3 spec/serialize_spec.rb
ledermann-rails-settings-2.0.2 spec/serialize_spec.rb
ledermann-rails-settings-2.0.1 spec/serialize_spec.rb
ledermann-rails-settings-2.0.0 spec/serialize_spec.rb