2019-04-30 08:27:42 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-03-08 15:42:24 +08:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe AboutController do
|
|
|
|
|
|
|
|
context '.index' do
|
|
|
|
|
|
|
|
it "should display the about page for anonymous user when login_required is false" do
|
|
|
|
SiteSetting.login_required = false
|
2018-05-22 11:40:50 +08:00
|
|
|
get "/about"
|
2017-08-31 12:06:56 +08:00
|
|
|
|
2018-06-07 16:11:09 +08:00
|
|
|
expect(response.status).to eq(200)
|
2018-11-28 10:36:14 +08:00
|
|
|
expect(response.body).to include("<title>About - Discourse</title>")
|
2017-03-08 15:42:24 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should redirect to login page for anonymous user when login_required is true' do
|
|
|
|
SiteSetting.login_required = true
|
2018-05-22 11:40:50 +08:00
|
|
|
get "/about"
|
2017-08-31 12:06:56 +08:00
|
|
|
|
2017-03-08 15:42:24 +08:00
|
|
|
expect(response).to redirect_to '/login'
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should display the about page for logged in user when login_required is true" do
|
|
|
|
SiteSetting.login_required = true
|
2018-05-22 11:40:50 +08:00
|
|
|
sign_in(Fabricate(:user))
|
|
|
|
get "/about"
|
2017-08-31 12:06:56 +08:00
|
|
|
|
2018-06-07 16:11:09 +08:00
|
|
|
expect(response.status).to eq(200)
|
2017-03-08 15:42:24 +08:00
|
|
|
end
|
2018-11-28 10:36:14 +08:00
|
|
|
|
|
|
|
context "crawler view" do
|
|
|
|
it "should include correct title" do
|
|
|
|
get '/about', headers: { 'HTTP_USER_AGENT' => 'Googlebot' }
|
|
|
|
expect(response.status).to eq(200)
|
|
|
|
expect(response.body).to include("<title>About - Discourse</title>")
|
|
|
|
end
|
|
|
|
end
|
2017-03-08 15:42:24 +08:00
|
|
|
end
|
|
|
|
end
|