Sha256: 929fe6b459adc5c271e83500d0a526028370a81ab400a3efe2fe6e6987004814

Contents?: true

Size: 887 Bytes

Versions: 4

Compression:

Stored size: 887 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe Mongoid::Voteable::Tasks do
  describe 'Mongoid::Voteable::Tasks.init_stats' do
    before :all do
      @post1 = Post.create!
      @post2 = Post.create!
    end

    it 'after create votes has default value' do
      @post1.votes.should == Mongoid::Voteable::Votes::DEFAULT_ATTRIBUTES
      @post2.votes.should == Mongoid::Voteable::Votes::DEFAULT_ATTRIBUTES
    end
    
    it 'reset votes data' do
      @post1.votes = nil
      @post1.save

      @post2.votes = nil
      @post2.save
    end
    
    it 'init_stats recover votes default value' do
      Mongoid::Voteable::Tasks.init_stats

      @post1.reload
      @post2.reload
    
      @post1.votes.should == Mongoid::Voteable::Votes::DEFAULT_ATTRIBUTES
      @post2.votes.should == Mongoid::Voteable::Votes::DEFAULT_ATTRIBUTES
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
voteable_mongoid-0.7.6 spec/voteable_mongoid/tasks_spec.rb
voteable_mongoid-0.7.5 spec/voteable_mongoid/tasks_spec.rb
voteable_mongoid-0.7.4 spec/voteable_mongoid/tasks_spec.rb
voteable_mongoid-0.7.3 spec/voteable_mongoid/tasks_spec.rb