From bc65b42b02ad38b25ec7d7f5328ce2098057cb94 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Thu, 30 Dec 2021 20:12:23 +0100 Subject: [PATCH] Add tests for `StaticController#linkfilter` --- spec/controllers/static_controller_spec.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/spec/controllers/static_controller_spec.rb b/spec/controllers/static_controller_spec.rb index 0a79ec39..e7d7036e 100644 --- a/spec/controllers/static_controller_spec.rb +++ b/spec/controllers/static_controller_spec.rb @@ -18,4 +18,24 @@ describe StaticController, type: :controller do expect(assigns(:users)).to eq(1) end end + + 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