Move link filter into its own controller

This commit is contained in:
Karina Kwiatek 2022-07-18 22:00:21 +02:00 committed by Karina Kwiatek
parent 7abdac2d8a
commit 98d7bec924
6 changed files with 35 additions and 35 deletions

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
class StaticController < ApplicationController
def linkfilter
class LinkFilterController < ApplicationController
def index
redirect_to root_path unless params[:url]
@link = params[:url]

View File

@ -143,6 +143,13 @@ en:
share:
heading: "Share"
button: "Share on %{service}"
link_filter:
index:
heading: "You're leaving %{app_name}"
subheading: "The link you are visiting is not trusted by %{app_name}"
body: Never enter your passwords or other private information on an untrusted website. %{app_name} will only ever ask for your password on a site that is on the domain %{hostname}
url: "URL:"
confirm: "I understand the risk, proceed!"
modal:
password:
title: "Save account changes"
@ -375,13 +382,6 @@ en:
source: "Source code"
terms: "Terms of Service"
privacy: "Privacy Policy"
static:
linkfilter:
heading: "You're leaving %{app_name}"
subheading: "The link you are visiting is not trusted by %{app_name}"
body: Never enter your passwords or other private information on an untrusted website. %{app_name} will only ever ask for your password on a site that is on the domain %{hostname}
url: "URL:"
confirm: "I understand the risk, proceed!"
tabs:
notifications:
all: "All notifications"

View File

@ -45,7 +45,7 @@ Rails.application.routes.draw do
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 '/linkfilter', to: 'link_filter#index', via: 'get', as: :linkfilter
match '/manifest.json', to: 'manifests#show', via: 'get', as: :webapp_manifest
# Devise routes

View File

@ -0,0 +1,25 @@
# frozen_string_literal: true
require "rails_helper"
describe LinkFilterController, type: :controller do
describe "#index" do
context "called without an url" do
subject { get :index }
it "should redirect to the root page" do
subject
expect(response).to redirect_to(root_path)
end
end
context "called with an url" do
subject { get :index, params: { url: "https://google.com" } }
it "should show the passed url" do
subject
expect(assigns(:link)).to eq("https://google.com")
end
end
end
end

View File

@ -1,25 +0,0 @@
# frozen_string_literal: true
require "rails_helper"
describe StaticController, type: :controller do
describe "#linkfilter" do
context "called without an url" do
subject { get :linkfilter }
it 'should redirect to the root page' do
subject
expect(response).to redirect_to(root_path)
end
end
context "called with an url" do
subject { get :linkfilter, params: { url: 'https://google.com' } }
it 'should show the passed url' do
subject
expect(assigns(:link)).to eq('https://google.com')
end
end
end
end