mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
On sites with login_required enabled, after signup, don't show the /login page again
This commit is contained in:
parent
704adc00ca
commit
ce5ebc3eb5
2 changed files with 44 additions and 33 deletions
|
@ -5,6 +5,8 @@ class StaticController < ApplicationController
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
|
||||||
|
return redirect_to('/') if current_user && params[:id] == 'login'
|
||||||
|
|
||||||
map = {
|
map = {
|
||||||
"faq" => "faq_url",
|
"faq" => "faq_url",
|
||||||
"tos" => "tos_url",
|
"tos" => "tos_url",
|
||||||
|
|
|
@ -2,56 +2,65 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe StaticController do
|
describe StaticController do
|
||||||
|
|
||||||
context "with a static file that's present" do
|
context 'show' do
|
||||||
|
context "with a static file that's present" do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
xhr :get, :show, id: 'faq'
|
xhr :get, :show, id: 'faq'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'renders the static file if present' do
|
it 'renders the static file if present' do
|
||||||
response.should be_success
|
response.should be_success
|
||||||
end
|
end
|
||||||
|
|
||||||
it "renders the file" do
|
it "renders the file" do
|
||||||
if rails4?
|
if rails4?
|
||||||
response.should render_template('static/faq.en')
|
response.should render_template('static/faq.en')
|
||||||
else
|
else
|
||||||
response.should render_template('faq')
|
response.should render_template('faq')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
[ ['tos', :tos_url], ['privacy', :privacy_policy_url] ].each do |id, setting_name|
|
[ ['tos', :tos_url], ['privacy', :privacy_policy_url] ].each do |id, setting_name|
|
||||||
context "#{id}" do
|
context "#{id}" do
|
||||||
subject { xhr :get, :show, id: id }
|
subject { xhr :get, :show, id: id }
|
||||||
|
|
||||||
context "when #{setting_name} site setting is NOT set" do
|
context "when #{setting_name} site setting is NOT set" do
|
||||||
it "renders the #{id} page" do
|
it "renders the #{id} page" do
|
||||||
if rails4?
|
if rails4?
|
||||||
expect(subject).to render_template("static/#{id}.en")
|
expect(subject).to render_template("static/#{id}.en")
|
||||||
else
|
else
|
||||||
expect(subject).to render_template(id)
|
expect(subject).to render_template(id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when #{setting_name} site setting is set" do
|
||||||
|
before { SiteSetting.stubs(setting_name).returns('http://example.com/page') }
|
||||||
|
|
||||||
|
it "redirects to the #{setting_name}" do
|
||||||
|
expect(subject).to redirect_to('http://example.com/page')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "when #{setting_name} site setting is set" do
|
context "with a missing file" do
|
||||||
before { SiteSetting.stubs(setting_name).returns('http://example.com/page') }
|
it "should respond 404" do
|
||||||
|
xhr :get, :show, id: 'does-not-exist'
|
||||||
it "redirects to the #{setting_name}" do
|
response.response_code.should == 404
|
||||||
expect(subject).to redirect_to('http://example.com/page')
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context "with a missing file" do
|
it 'should redirect to / when logged in and path is /login' do
|
||||||
it "should respond 404" do
|
log_in
|
||||||
xhr :get, :show, id: 'does-not-exist'
|
xhr :get, :show, id: 'login'
|
||||||
response.response_code.should == 404
|
response.should redirect_to '/'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
describe '#enter' do
|
describe '#enter' do
|
||||||
context 'without a redirect path' do
|
context 'without a redirect path' do
|
||||||
it 'redirects to the root url' do
|
it 'redirects to the root url' do
|
||||||
|
|
Loading…
Reference in a new issue