Sha256: 6bfc6bb06e0bf57565a4ef3d400b0d1ff97c1d2b8306d214443d7e94bde2ce11

Contents?: true

Size: 918 Bytes

Versions: 7

Compression:

Stored size: 918 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!(:title => 'post1')
      @post2 = Post.create!(:title => 'post2')
    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

7 entries across 7 versions & 2 rubygems

Version Path
rs_voteable_mongo-1.3.0 spec/voteable_mongo/tasks_spec.rb
rs_voteable_mongo-1.2.0 spec/voteable_mongo/tasks_spec.rb
rs_voteable_mongo-1.1.0 spec/voteable_mongo/tasks_spec.rb
rs_voteable_mongo-1.0.2 spec/voteable_mongo/tasks_spec.rb
rs_voteable_mongo-1.0.1 spec/voteable_mongo/tasks_spec.rb
rs_voteable_mongo-1.0.0 spec/voteable_mongo/tasks_spec.rb
voteable_mongo-0.9.3 spec/voteable_mongo/tasks_spec.rb