mirror of
https://github.com/discourse/discourse.git
synced 2024-12-16 06:03:46 +08:00
c531f4ded5
Rails yanked out observers many many years ago, instead the functionality was yanked out to a gem that is very lightly maintained. For example: if we want to upgrade to rails 5 there is no published gem Internally the usage of observers had quite a few problem. The series of refactors renamed a bunch of classes to give us more clarity and removed some magic.
37 lines
830 B
Ruby
37 lines
830 B
Ruby
require 'rails_helper'
|
|
|
|
describe DirectoryItem do
|
|
|
|
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
|
|
|
|
context 'refresh' do
|
|
before do
|
|
UserActionCreator.enable
|
|
end
|
|
|
|
let!(:post) { create_post }
|
|
|
|
it "creates the record for the user" do
|
|
DirectoryItem.refresh!
|
|
expect(DirectoryItem.where(period_type: DirectoryItem.period_types[:all])
|
|
.where(user_id: post.user.id)
|
|
.where(topic_count: 1).count).to eq(1)
|
|
end
|
|
|
|
end
|
|
end
|