FEATURE: add redirect_users_to_top_page site setting (default to true)

This commit is contained in:
Régis Hanol 2014-03-31 21:53:38 +02:00
parent 7baa8ea0af
commit ef24a4c71c
4 changed files with 45 additions and 31 deletions

View File

@ -560,6 +560,8 @@ class User < ActiveRecord::Base
end end
def redirected_to_top_reason def redirected_to_top_reason
# redirect is enabled
return unless SiteSetting.redirect_users_to_top_page
# top must be in the top_menu # top must be in the top_menu
return unless SiteSetting.top_menu =~ /top/i return unless SiteSetting.top_menu =~ /top/i
# there should be enough topics # there should be enough topics

View File

@ -665,6 +665,7 @@ en:
topics_per_period_in_top_summary: "How many topics loaded on the top topics summary" topics_per_period_in_top_summary: "How many topics loaded on the top topics summary"
topics_per_period_in_top_page: "How many topics loaded on the top topics page" topics_per_period_in_top_page: "How many topics loaded on the top topics page"
redirect_users_to_top_page: "Automatically redirect new & long-time-no-see users to top page"
redirect_new_users_to_top_page_duration: "Number of days during which new users are automatically redirect to the top page" redirect_new_users_to_top_page_duration: "Number of days during which new users are automatically redirect to the top page"
enable_badges: "Enable the badge system (experimental)" enable_badges: "Enable the badge system (experimental)"

View File

@ -148,6 +148,7 @@ users:
client: true client: true
default: 60 default: 60
delete_all_posts_max: 15 delete_all_posts_max: 15
redirect_users_to_top_page: true
posting: posting:
min_post_length: min_post_length:

View File

@ -1093,6 +1093,14 @@ describe User do
describe "redirected_to_top_reason" do describe "redirected_to_top_reason" do
let!(:user) { Fabricate(:user) } let!(:user) { Fabricate(:user) }
it "should have no reason when redirect_users_to_top_page is disabled" do
SiteSetting.expects(:redirect_users_to_top_page).returns(false)
user.redirected_to_top_reason.should == nil
end
context "redirect_users_to_top_page is enabled" do
before { SiteSetting.stubs(:redirect_users_to_top_page).returns(true) }
it "should have no reason when top is not in the top_menu" do it "should have no reason when top is not in the top_menu" do
SiteSetting.expects(:top_menu).returns("latest") SiteSetting.expects(:top_menu).returns("latest")
user.redirected_to_top_reason.should == nil user.redirected_to_top_reason.should == nil
@ -1140,3 +1148,5 @@ describe User do
end end
end end
end