add top page

This commit is contained in:
Régis Hanol
2013-12-24 00:50:36 +01:00
parent b90e811825
commit 567d2bd23c
57 changed files with 532 additions and 324 deletions

View File

@@ -13,14 +13,14 @@ describe ListController do
describe 'indexes' do
[:latest, :hot].each do |filter|
Discourse.anonymous_filters.each do |filter|
context "#{filter}" do
before { xhr :get, filter }
it { should respond_with(:success) }
end
end
[:favorited, :read, :posted, :unread, :new].each do |filter|
Discourse.logged_in_filters.each do |filter|
context "#{filter}" do
it { expect { xhr :get, filter }.to raise_error(Discourse::NotLoggedIn) }
end
@@ -39,7 +39,7 @@ describe ListController do
describe 'RSS feeds' do
[:latest, :hot].each do |filter|
Discourse.anonymous_filters.each do |filter|
it 'renders RSS' do
get "#{filter}_feed", format: :rss
@@ -175,14 +175,6 @@ describe ListController do
end
end
context 'hot' do
before do
xhr :get, :hot
end
it { should respond_with(:success) }
end
context 'favorited' do
it 'raises an error when not logged in' do
lambda { xhr :get, :favorited }.should raise_error(Discourse::NotLoggedIn)

View File

@@ -0,0 +1,30 @@
require 'spec_helper'
describe TopTopic do
it { should belong_to :topic }
context "refresh!" do
let!(:t1) { Fabricate(:topic) }
let!(:t2) { Fabricate(:topic) }
it "begins blank" do
TopTopic.all.should be_blank
end
context "after calculating" do
before do
TopTopic.refresh!
end
it "should have top topics" do
TopTopic.pluck(:topic_id).should =~ [t1.id, t2.id]
end
end
end
end