Sha256: 772a9671dd053eac08dfbc02c57a4fe23333f17fb4636a3caf2373d7987f6a99

Contents?: true

Size: 1.68 KB

Versions: 1

Compression:

Stored size: 1.68 KB

Contents

require 'spec_helper'

module Refinery
  module Tweets
    describe TwitterAccount do
      describe "validations" do
        let(:subject) {
          FactoryGirl.build(:twitter_account,
            :username => "twitter",
            :tweet_count => "5")
        }

        it { should be_valid }
        it { expect(subject.errors).to be_empty }
        it { expect(subject.username).to eq 'twitter' }
        it { expect(subject.tweet_count).to eq 5 }
        it { expect(subject.visible).to eq true }
      end

      describe "account settings" do

        before(:each) do
          Rails.cache.clear
        end

        it "stores the settings in the rails cache" do
          Rails.cache.read('refinery-twitter-account-settings').should be_nil
          twitter_account = FactoryGirl.create(:twitter_account)

          Rails.cache.read('refinery-twitter-account-settings').should == settings_hash(twitter_account)
        end

        it "reads the settings from the rails cache" do
          twitter_account = FactoryGirl.create(:twitter_account)

          TwitterAccount.account_settings.should == settings_hash(twitter_account)
        end

        it "updates the cache when the settings are changed" do
          twitter_account = FactoryGirl.create(:twitter_account)

          TwitterAccount.account_settings.should == settings_hash(twitter_account)
          TwitterAccount.account_settings["username"].should == "twitter"

          twitter_account.update_attribute(:username, "new_username")

          TwitterAccount.account_settings.should == settings_hash(twitter_account)
          TwitterAccount.account_settings["username"].should == "new_username"
        end

      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
refinerycms-tweets-2.1.0 spec/models/refinery/tweets/twitter_account_spec.rb