2019-04-29 20:27:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-27 22:27:38 -04:00
|
|
|
RSpec.describe SiteController do
|
2018-11-14 02:03:02 -05:00
|
|
|
describe '#basic_info' do
|
2016-08-12 03:10:08 -04:00
|
|
|
it 'is visible always even for sites requiring login' do
|
2018-11-14 02:03:02 -05:00
|
|
|
upload = Fabricate(:upload)
|
2016-08-12 03:10:08 -04:00
|
|
|
|
2018-11-14 02:03:02 -05:00
|
|
|
SiteSetting.login_required = true
|
2016-08-12 03:10:08 -04:00
|
|
|
SiteSetting.title = "Hammer Time"
|
|
|
|
SiteSetting.site_description = "A time for Hammer"
|
2018-11-14 02:03:02 -05:00
|
|
|
SiteSetting.logo = upload
|
|
|
|
SiteSetting.logo_small = upload
|
|
|
|
SiteSetting.apple_touch_icon = upload
|
|
|
|
SiteSetting.mobile_logo = upload
|
2018-10-08 19:03:05 -04:00
|
|
|
Theme.clear_default!
|
2016-08-12 03:10:08 -04:00
|
|
|
|
2018-06-05 23:32:03 -04:00
|
|
|
get "/site/basic-info.json"
|
2020-05-07 11:04:12 -04:00
|
|
|
json = response.parsed_body
|
2016-08-12 03:10:08 -04:00
|
|
|
|
2018-11-14 02:03:02 -05:00
|
|
|
expected_url = UrlHelper.absolute(upload.url)
|
|
|
|
|
2016-08-12 03:10:08 -04:00
|
|
|
expect(json["title"]).to eq("Hammer Time")
|
|
|
|
expect(json["description"]).to eq("A time for Hammer")
|
2018-11-14 02:03:02 -05:00
|
|
|
expect(json["logo_url"]).to eq(expected_url)
|
|
|
|
expect(json["apple_touch_icon_url"]).to eq(expected_url)
|
|
|
|
expect(json["logo_small_url"]).to eq(expected_url)
|
|
|
|
expect(json["mobile_logo_url"]).to eq(expected_url)
|
2018-10-08 05:52:57 -04:00
|
|
|
expect(json["header_primary_color"]).to eq("333333")
|
|
|
|
expect(json["header_background_color"]).to eq("ffffff")
|
2021-08-17 14:05:51 -04:00
|
|
|
expect(json["login_required"]).to eq(true)
|
2016-08-12 03:10:08 -04:00
|
|
|
end
|
|
|
|
end
|
2017-03-10 08:16:00 -05:00
|
|
|
|
2018-11-14 02:03:02 -05:00
|
|
|
describe '#statistics' do
|
2017-03-10 08:16:00 -05:00
|
|
|
it 'is visible for sites requiring login' do
|
|
|
|
SiteSetting.login_required = true
|
|
|
|
SiteSetting.share_anonymized_statistics = true
|
|
|
|
|
2018-06-05 23:32:03 -04:00
|
|
|
get "/site/statistics.json"
|
2020-05-07 11:04:12 -04:00
|
|
|
json = response.parsed_body
|
2017-03-10 08:16:00 -05:00
|
|
|
|
2018-06-07 04:11:09 -04:00
|
|
|
expect(response.status).to eq(200)
|
2017-03-10 08:16:00 -05: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-05 23:32:03 -04:00
|
|
|
get "/site/statistics.json"
|
2017-03-10 08:16:00 -05:00
|
|
|
expect(response).to redirect_to '/'
|
|
|
|
end
|
|
|
|
end
|
2016-08-12 03:10:08 -04:00
|
|
|
end
|