Sha256: 72cb1598af871cecc8457709017b812c5ef61c4aa3bd8a75433fbe9af8f2afc0

Contents?: true

Size: 1.39 KB

Versions: 14

Compression:

Stored size: 1.39 KB

Contents

require 'spec_helper'

module Crowdblog
  describe User do

    describe '#gravatar_email' do
      context 'when using a Gravatar' do
        before { subject.should_receive(:gravatar_alias).and_return 'GRAVATAR' }

        it 'should use the alias' do
          subject.gravatar_email.should == 'GRAVATAR'
        end
      end

      context 'when not using a Gravatar' do
        before do
          subject.should_receive(:gravatar_alias)
          subject.should_receive(:email).and_return 'EMAIL'
        end

        it 'should use the email' do
          subject.gravatar_email.should == 'EMAIL'
        end
      end
    end

    describe '#last_post_at' do
      context 'when has posts' do
        let(:post) { mock_model Post }

        before do
          subject.should_receive(:last_post).and_return post
          post.should_receive(:published_at).and_return '2012-06-31'
        end

        it 'should be the published post date' do
          subject.last_post_at.should == '2012-06-31'
        end
      end

      context 'when no posts' do
        it 'should be nil' do
          subject.should_receive(:last_post)
          subject.last_post_at.should be_nil
        end
      end
    end

    describe '#publisher!' do
      it 'should make User a Publisher' do
        subject.should_receive(:update_attribute).with(:is_publisher, true)
        subject.publisher!
      end
    end

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
crowdblog-0.0.16 spec/models/user_spec.rb
crowdblog-0.0.15 spec/models/user_spec.rb
crowdblog-0.0.14 spec/models/user_spec.rb
crowdblog-0.0.13 spec/models/user_spec.rb
crowdblog-0.0.12 spec/models/user_spec.rb
crowdblog-0.0.10 spec/models/user_spec.rb
crowdblog-0.0.9 spec/models/user_spec.rb
crowdblog-0.0.8 spec/models/user_spec.rb
crowdblog-0.0.7 spec/models/user_spec.rb
crowdblog-0.0.6 spec/models/user_spec.rb
crowdblog-0.0.5 spec/models/user_spec.rb
crowdblog-0.0.4 spec/models/user_spec.rb
crowdblog-0.0.3 spec/models/user_spec.rb
crowdblog-0.0.2 spec/models/user_spec.rb