Sha256: 758662a9a6fc85a08b4a129ed9da613a2dba6aea83279f4e895e5e5a0fde7c63

Contents?: true

Size: 880 Bytes

Versions: 3

Compression:

Stored size: 880 Bytes

Contents

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

describe Mongo::Voteable::Tasks do
  describe 'Mongo::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 == ::Mongo::Voteable::DEFAULT_VOTES
      @post2.votes.should == ::Mongo::Voteable::DEFAULT_VOTES
    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
      ::Mongo::Voteable::Tasks.init_stats
      ::Mongo::Voteable::Tasks.migrate_old_votes

      @post1.reload
      @post2.reload

      @post1.votes.should == ::Mongo::Voteable::DEFAULT_VOTES
      @post2.votes.should == ::Mongo::Voteable::DEFAULT_VOTES
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
voteable_mongo-0.9.2 spec/voteable_mongo/tasks_spec.rb
voteable_mongo-0.9.1 spec/voteable_mongo/tasks_spec.rb
voteable_mongo-0.9.0 spec/voteable_mongo/tasks_spec.rb