Skip to content

Commit

Permalink
Merge pull request #3260 from betagouv/lucien/debug/30-11
Browse files Browse the repository at this point in the history
correction redirections des vieux sujet, couleurs des stats
  • Loading branch information
LucienMLD authored Dec 5, 2023
2 parents 52396b8 + f328330 commit 09b3be8
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 11 deletions.
6 changes: 3 additions & 3 deletions app/controllers/concerns/iframe_prefix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ def retrieve_main_objects
landing_slug = params[:landing_slug]
if landing_slug.present?
@landing = Landing.not_archived.find_by(slug: landing_slug)
redirect_to root_path, status: :moved_permanently if @landing.nil?
redirect_to root_path, status: :moved_permanently and return if @landing.nil?
end
landing_subject_slug = params[:landing_subject_slug]
if landing_subject_slug.present?
@landing_subject = LandingSubject.not_archived.find_by(slug: landing_subject_slug)
redirect_to root_path, status: :moved_permanently && return if @landing_subject.nil?
redirect_to root_path, status: :moved_permanently and return if @landing_subject.nil?
end
# Controller Solicitation#other_methods
solicitation_uuid = params[:uuid]
if solicitation_uuid.present?
@solicitation ||= Solicitation.find_by(uuid: solicitation_uuid)
redirect_to root_path if @solicitation.nil?
redirect_to root_path, status: :moved_permanently and return if @solicitation.nil?
@landing = @solicitation.landing
@landing_subject = @solicitation.landing_subject
end
Expand Down
1 change: 1 addition & 0 deletions app/jobs/application_job.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class ApplicationJob < ActiveJob::Base
retry_on Net::SMTPServerBusy
end
4 changes: 0 additions & 4 deletions app/services/stats/needs/themes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,5 @@ def category_order_attribute
def count
false
end

def colors
%w[#9F3BCA #F15C80 #E78016 #F2DD68 #2D908F #62E0D3 #88c479 #A7FF96 #946D47 #64609B #63DDDB #F45A5A]
end
end
end
23 changes: 19 additions & 4 deletions spec/controllers/landings/landings_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,31 @@

RSpec.describe Landings::LandingsController do
describe 'GET #show' do
before do
create :landing, slug: 'accueil'
end

context 'existing home landing page' do
let!(:landing) { create :landing, slug: 'accueil' }

it do
get :home
expect(response).to be_successful
end
end

context 'with existing landing' do
let(:landing) { create :landing }

it do
get :show, params: { landing_slug: landing.slug }
expect(response).to be_successful
end
end

context 'without existing landing' do
it do
get :show, params: { landing_slug: 'unknown' }
expect(response).to redirect_to root_path
expect(response).to have_http_status(:moved_permanently)
end
end
end

describe "iframes" do
Expand Down
39 changes: 39 additions & 0 deletions spec/controllers/solicitations_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,45 @@
require 'rails_helper'

RSpec.describe SolicitationsController do
describe 'GET #new' do
let(:landing) { create(:landing) }
let(:landing_subject) { create(:landing_subject) }

context 'with existing landing and landing subject' do
it do
get :new, params: { landing_slug: landing.slug, landing_subject_slug: landing_subject.slug }
expect(response).to be_successful
end
end

context 'with existing landing but without landing subject' do
let(:landing) { create(:landing) }

it do
get :new, params: { landing_slug: landing.slug, landing_subject_slug: 'unknown' }
expect(response).to redirect_to root_path
expect(response).to have_http_status(:moved_permanently)
end
end

context 'with a good solicitation uuid' do
let(:solicitation) { create(:solicitation, uuid: 'good-solicitation-uuid') }

it do
get :new, params: { uuid: solicitation.uuid, landing_slug: landing.slug, landing_subject_slug: landing_subject.slug }
expect(response).to be_successful
end
end

context 'with a bad solicitation uuid' do
it do
get :new, params: { uuid: 'bad-solicitation-uuid', landing_slug: landing.slug, landing_subject_slug: landing_subject.slug }
expect(response).to redirect_to root_path
expect(response).to have_http_status(:moved_permanently)
end
end
end

describe 'POST #create' do
let(:landing) { create(:landing) }
let(:landing_subject) { create(:landing_subject) }
Expand Down

0 comments on commit 09b3be8

Please sign in to comment.