2015-10-11 17:41:23 +08:00
|
|
|
require 'rails_helper'
|
2015-03-17 03:14:33 +08:00
|
|
|
|
|
|
|
describe DirectoryItem do
|
2016-01-08 18:53:52 +08:00
|
|
|
|
|
|
|
describe '#period_types' do
|
|
|
|
context "verify enum sequence" do
|
|
|
|
before do
|
|
|
|
@period_types = DirectoryItem.period_types
|
|
|
|
end
|
|
|
|
|
|
|
|
it "'all' should be at 1st position" do
|
|
|
|
expect(@period_types[:all]).to eq(1)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "'quarterly' should be at 6th position" do
|
|
|
|
expect(@period_types[:quarterly]).to eq(6)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-03-17 03:14:33 +08:00
|
|
|
context 'refresh' do
|
2016-03-02 15:23:29 +08:00
|
|
|
before do
|
2016-12-22 12:03:40 +08:00
|
|
|
UserActionCreator.enable
|
2016-03-02 15:23:29 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
let!(:post) { create_post }
|
2015-03-17 03:14:33 +08:00
|
|
|
|
|
|
|
it "creates the record for the user" do
|
|
|
|
DirectoryItem.refresh!
|
|
|
|
expect(DirectoryItem.where(period_type: DirectoryItem.period_types[:all])
|
2015-03-21 01:24:03 +08:00
|
|
|
.where(user_id: post.user.id)
|
2016-03-02 15:23:29 +08:00
|
|
|
.where(topic_count: 1).count).to eq(1)
|
2015-03-17 03:14:33 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|