Skip to content

Commit

Permalink
Merge pull request #69 from etalab/features/frontal
Browse files Browse the repository at this point in the history
Introduce frontal env var & endpoint
  • Loading branch information
skelz0r authored Jul 4, 2024
2 parents 5bf781c + ebc9075 commit 238b985
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 1 deletion.
19 changes: 19 additions & 0 deletions app/controllers/api/frontal_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class Api::FrontalController < Api::ApplicationController
def index
if frontal?
render json: {
frontal: true,
}, status: :ok
else
render json: {
frontal: false,
}, status: 418
end
end

private

def frontal?
ENV["FRONTAL"] == "true"
end
end
1 change: 1 addition & 0 deletions config/initializers/frontal.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ENV["FRONTAL"] = "true"
1 change: 1 addition & 0 deletions config/initializers/frontal_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Rails.application.config.action_mailer.perform_deliveries = (ENV["FRONTAL"] == "true")
2 changes: 1 addition & 1 deletion config/initializers/good_job.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Rails.application.configure do
config.good_job.dashboard_default_locale = :fr
config.good_job.enable_cron = true
config.good_job.enable_cron = ENV["FRONTAL"] == "true"
config.good_job.cron = {
populate_hubee_sandbox: {cron: "0 4 * * *", class: "PopulateHubEESandboxJob"},
}
Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@

scope module: :api, path: "/api" do
resources :collectivities, only: :index, path: "collectivites"

resources :frontal, only: :index
end

mount GoodJob::Engine => "good_job"
Expand Down
25 changes: 25 additions & 0 deletions spec/controllers/api/frontal_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
RSpec.describe Api::FrontalController, type: :controller do
describe "GET #index" do
subject { get :index }

after do
ENV["FRONTAL"] = "false"
end

context "when it is frontal" do
before do
ENV["FRONTAL"] = "true"
end

it { is_expected.to have_http_status(:ok) }
end

context "when it is not frontal" do
before do
ENV["FRONTAL"] = "false"
end

it { is_expected.to have_http_status(418) }
end
end
end

0 comments on commit 238b985

Please sign in to comment.