2016-08-12 15:10:08 +08:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe SiteController do
|
|
|
|
describe '.basic_info' do
|
|
|
|
it 'is visible always even for sites requiring login' do
|
|
|
|
SiteSetting.login_required = true
|
|
|
|
|
|
|
|
SiteSetting.title = "Hammer Time"
|
2017-07-28 09:20:09 +08:00
|
|
|
SiteSetting.site_description = "A time for Hammer"
|
2016-08-12 15:10:08 +08:00
|
|
|
SiteSetting.logo_url = "/uploads/logo.png"
|
|
|
|
SiteSetting.logo_small_url = "http://boom.com/uploads/logo_small.png"
|
|
|
|
SiteSetting.apple_touch_icon_url = "https://boom.com/apple/logo.png"
|
|
|
|
SiteSetting.mobile_logo_url = "https://a.a/a.png"
|
|
|
|
|
2018-06-06 11:32:03 +08:00
|
|
|
get "/site/basic-info.json"
|
2016-08-12 15:10:08 +08:00
|
|
|
json = JSON.parse(response.body)
|
|
|
|
|
|
|
|
expect(json["title"]).to eq("Hammer Time")
|
|
|
|
expect(json["description"]).to eq("A time for Hammer")
|
|
|
|
expect(json["logo_url"]).to eq("http://test.localhost/uploads/logo.png")
|
|
|
|
expect(json["apple_touch_icon_url"]).to eq("https://boom.com/apple/logo.png")
|
|
|
|
expect(json["logo_small_url"]).to eq("http://boom.com/uploads/logo_small.png")
|
|
|
|
expect(json["mobile_logo_url"]).to eq("https://a.a/a.png")
|
2018-10-08 17:52:57 +08:00
|
|
|
expect(json["header_primary_color"]).to eq("333333")
|
|
|
|
expect(json["header_background_color"]).to eq("ffffff")
|
2016-08-12 15:10:08 +08:00
|
|
|
end
|
|
|
|
end
|
2017-03-10 21:16:00 +08:00
|
|
|
|
|
|
|
describe '.statistics' do
|
|
|
|
it 'is visible for sites requiring login' do
|
|
|
|
SiteSetting.login_required = true
|
|
|
|
SiteSetting.share_anonymized_statistics = true
|
|
|
|
|
2018-06-06 11:32:03 +08:00
|
|
|
get "/site/statistics.json"
|
2017-03-10 21:16:00 +08:00
|
|
|
json = JSON.parse(response.body)
|
|
|
|
|
2018-06-07 16:11:09 +08:00
|
|
|
expect(response.status).to eq(200)
|
2017-03-10 21:16:00 +08:00
|
|
|
expect(json["topic_count"]).to be_present
|
|
|
|
expect(json["post_count"]).to be_present
|
|
|
|
expect(json["user_count"]).to be_present
|
|
|
|
expect(json["topics_7_days"]).to be_present
|
|
|
|
expect(json["topics_30_days"]).to be_present
|
|
|
|
expect(json["posts_7_days"]).to be_present
|
|
|
|
expect(json["posts_30_days"]).to be_present
|
|
|
|
expect(json["users_7_days"]).to be_present
|
|
|
|
expect(json["users_30_days"]).to be_present
|
|
|
|
expect(json["active_users_7_days"]).to be_present
|
|
|
|
expect(json["active_users_30_days"]).to be_present
|
|
|
|
expect(json["like_count"]).to be_present
|
|
|
|
expect(json["likes_7_days"]).to be_present
|
|
|
|
expect(json["likes_30_days"]).to be_present
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'is not visible if site setting share_anonymized_statistics is disabled' do
|
|
|
|
SiteSetting.share_anonymized_statistics = false
|
|
|
|
|
2018-06-06 11:32:03 +08:00
|
|
|
get "/site/statistics.json"
|
2017-03-10 21:16:00 +08:00
|
|
|
expect(response).to redirect_to '/'
|
|
|
|
end
|
|
|
|
end
|
2018-07-18 18:57:43 +08:00
|
|
|
|
|
|
|
describe '.selectable_avatars' do
|
|
|
|
before do
|
|
|
|
SiteSetting.selectable_avatars = "https://www.discourse.org\nhttps://meta.discourse.org"
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns empty array when selectable avatars is disabled' do
|
|
|
|
SiteSetting.selectable_avatars_enabled = false
|
|
|
|
|
|
|
|
get "/site/selectable-avatars.json"
|
|
|
|
json = JSON.parse(response.body)
|
|
|
|
|
|
|
|
expect(response.status).to eq(200)
|
|
|
|
expect(json).to eq([])
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns an array when selectable avatars is enabled' do
|
|
|
|
SiteSetting.selectable_avatars_enabled = true
|
|
|
|
|
|
|
|
get "/site/selectable-avatars.json"
|
|
|
|
json = JSON.parse(response.body)
|
|
|
|
|
|
|
|
expect(response.status).to eq(200)
|
|
|
|
expect(json).to contain_exactly("https://www.discourse.org", "https://meta.discourse.org")
|
|
|
|
end
|
|
|
|
end
|
2016-08-12 15:10:08 +08:00
|
|
|
end
|