diff --git a/app/controllers/static_controller.rb b/app/controllers/link_filter_controller.rb similarity index 64% rename from app/controllers/static_controller.rb rename to app/controllers/link_filter_controller.rb index 26798688..fac0b4e9 100644 --- a/app/controllers/static_controller.rb +++ b/app/controllers/link_filter_controller.rb @@ -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] diff --git a/app/views/static/linkfilter.haml b/app/views/link_filter/index.haml similarity index 100% rename from app/views/static/linkfilter.haml rename to app/views/link_filter/index.haml diff --git a/config/locales/views.en.yml b/config/locales/views.en.yml index d31cc759..9f5d46ed 100644 --- a/config/locales/views.en.yml +++ b/config/locales/views.en.yml @@ -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" diff --git a/config/routes.rb b/config/routes.rb index f43b0185..ddd11311 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/spec/controllers/link_filter_controller_spec.rb b/spec/controllers/link_filter_controller_spec.rb new file mode 100644 index 00000000..51f34a7c --- /dev/null +++ b/spec/controllers/link_filter_controller_spec.rb @@ -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 \ No newline at end of file diff --git a/spec/controllers/static_controller_spec.rb b/spec/controllers/static_controller_spec.rb deleted file mode 100644 index 8c97c3f1..00000000 --- a/spec/controllers/static_controller_spec.rb +++ /dev/null @@ -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 \ No newline at end of file