Move About, ToS & Privacy Policy into `AboutController`
This commit is contained in:
parent
f3b58c1d33
commit
7abdac2d8a
|
@ -2,4 +2,30 @@
|
|||
|
||||
class AboutController < ApplicationController
|
||||
def index; end
|
||||
|
||||
def about
|
||||
user_count = User
|
||||
.where.not(confirmed_at: nil)
|
||||
.where("answered_count > 0")
|
||||
.count
|
||||
|
||||
current_ban_count = UserBan
|
||||
.current
|
||||
.joins(:user)
|
||||
.where.not("users.confirmed_at": nil)
|
||||
.where("users.answered_count > 0")
|
||||
.count
|
||||
|
||||
@users = user_count - current_ban_count
|
||||
@questions = Question.count
|
||||
@answers = Answer.count
|
||||
@comments = Comment.count
|
||||
@smiles = Appendable::Reaction.count
|
||||
end
|
||||
|
||||
def faq; end
|
||||
|
||||
def privacy_policy; end
|
||||
|
||||
def terms; end
|
||||
end
|
||||
|
|
|
@ -1,41 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class StaticController < ApplicationController
|
||||
def about
|
||||
user_count = User
|
||||
.where.not(confirmed_at: nil)
|
||||
.where("answered_count > 0")
|
||||
.count
|
||||
|
||||
current_ban_count = UserBan
|
||||
.current
|
||||
.joins(:user)
|
||||
.where.not("users.confirmed_at": nil)
|
||||
.where("users.answered_count > 0")
|
||||
.count
|
||||
|
||||
@users = user_count - current_ban_count
|
||||
@questions = Question.count
|
||||
@answers = Answer.count
|
||||
@comments = Comment.count
|
||||
@smiles = Appendable::Reaction.count
|
||||
end
|
||||
|
||||
def linkfilter
|
||||
redirect_to root_path unless params[:url]
|
||||
|
||||
@link = params[:url]
|
||||
end
|
||||
|
||||
def faq
|
||||
|
||||
end
|
||||
|
||||
def privacy_policy
|
||||
|
||||
end
|
||||
|
||||
def terms
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,4 +3,3 @@
|
|||
.card
|
||||
.card-body
|
||||
= raw_markdown_io 'service-docs/en/policy/privacy.md'
|
||||
|
|
@ -3,4 +3,3 @@
|
|||
.card
|
||||
.card-body
|
||||
= raw_markdown_io 'service-docs/en/policy/terms.md'
|
||||
|
|
@ -57,6 +57,13 @@ en:
|
|||
prompt:
|
||||
header: "What are you waiting for?"
|
||||
body: "Registering takes less than 5 minutes!"
|
||||
about:
|
||||
title: "About"
|
||||
subtitle: "About our service, features and other information"
|
||||
about_missing: "The site owner decided not to describe this Retrospring instance, how mysterious!"
|
||||
statistics:
|
||||
header: "Statistics"
|
||||
body: "All-time statistics for %{app_name}, updated every time you refresh the page!"
|
||||
auth:
|
||||
two_factor_authentication:
|
||||
heading: "Two-factor authentication"
|
||||
|
@ -369,13 +376,6 @@ en:
|
|||
terms: "Terms of Service"
|
||||
privacy: "Privacy Policy"
|
||||
static:
|
||||
about:
|
||||
title: "About"
|
||||
subtitle: "About our service, features and other information"
|
||||
about_missing: "The site owner decided not to describe this Retrospring instance, how mysterious!"
|
||||
statistics:
|
||||
header: "Statistics"
|
||||
body: "All-time statistics for %{app_name}, updated every time you refresh the page!"
|
||||
linkfilter:
|
||||
heading: "You're leaving %{app_name}"
|
||||
subheading: "The link you are visiting is not trusted by %{app_name}"
|
||||
|
|
|
@ -42,9 +42,9 @@ Rails.application.routes.draw do
|
|||
root to: 'timeline#index', as: :timeline
|
||||
end
|
||||
|
||||
match '/about', to: 'static#about', via: 'get'
|
||||
match '/privacy', to: 'static#privacy_policy', via: 'get', as: :privacy_policy
|
||||
match '/terms', to: 'static#terms', via: 'get', as: :terms
|
||||
match '/about', to: 'about#about', via: 'get'
|
||||
match '/privacy', to: 'about#privacy_policy', via: 'get', as: :privacy_policy
|
||||
match '/terms', to: 'about#terms', via: 'get', as: :terms
|
||||
match '/linkfilter', to: 'static#linkfilter', via: 'get', as: :linkfilter
|
||||
match '/manifest.json', to: 'manifests#show', via: 'get', as: :webapp_manifest
|
||||
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "rails_helper"
|
||||
|
||||
describe AboutController, type: :controller do
|
||||
describe "#about" do
|
||||
subject { get :about }
|
||||
|
||||
before(:each) {
|
||||
FactoryBot.create(:user, { confirmed_at: Time.current, answered_count: 1 })
|
||||
FactoryBot.create(:user, { confirmed_at: Time.current, answered_count: 1 }).ban
|
||||
FactoryBot.create(:user, { confirmed_at: Time.current })
|
||||
FactoryBot.create(:user, { confirmed_at: Time.current }).ban
|
||||
}
|
||||
|
||||
it "shows the correct user count" do
|
||||
subject
|
||||
expect(assigns(:users)).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -3,22 +3,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
describe StaticController, type: :controller do
|
||||
describe "#about" do
|
||||
subject { get :about }
|
||||
|
||||
before(:each) {
|
||||
FactoryBot.create(:user, { confirmed_at: Time.current, answered_count: 1 })
|
||||
FactoryBot.create(:user, { confirmed_at: Time.current, answered_count: 1 }).ban
|
||||
FactoryBot.create(:user, { confirmed_at: Time.current })
|
||||
FactoryBot.create(:user, { confirmed_at: Time.current }).ban
|
||||
}
|
||||
|
||||
it "shows the correct user count" do
|
||||
subject
|
||||
expect(assigns(:users)).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#linkfilter" do
|
||||
context "called without an url" do
|
||||
subject { get :linkfilter }
|
||||
|
|
Loading…
Reference in New Issue