Browse Source

hide create sales log button in production

pull/863/head
Ted-U 3 years ago committed by baarkerlounger
parent
commit
9663f44160
  1. 2
      app/views/layouts/application.html.erb
  2. 4
      app/views/lettings_logs/index.html.erb
  3. 6
      config/initializers/feature_toggle.rb
  4. 10
      spec/features/log_spec.rb

2
app/views/layouts/application.html.erb

@ -34,7 +34,7 @@
</script>
<% end %>
<% if Rails.env.production? %>
<% if Rails.env.production? && ENV["APP_HOST"].present? %>
<script defer data-domain="<%= ENV["APP_HOST"].split("https://")[1] %>" src="https://plausible.io/js/plausible.js"></script>
<% end %>
</head>

4
app/views/lettings_logs/index.html.erb

@ -8,7 +8,9 @@
<div class="app-filter-layout" data-controller="filter-layout">
<div class="govuk-button-group app-filter-toggle">
<%= govuk_button_to "Create a new lettings log", lettings_logs_path %>
<%= govuk_button_to "Create a new sales log", sales_logs_path %>
<% if FeatureToggle.sales_log_enabled? %>
<%= govuk_button_to "Create a new sales log", sales_logs_path %>
<% end %>
<%#= govuk_link_to "Upload logs", bulk_upload_lettings_logs_path %>
</div>

6
config/initializers/feature_toggle.rb

@ -2,4 +2,10 @@ class FeatureToggle
def self.startdate_two_week_validation_enabled?
true
end
def self.sales_log_enabled?
return true unless Rails.env.production?
false
end
end

10
spec/features/log_spec.rb

@ -155,5 +155,15 @@ RSpec.describe "Log Features" do
expect(page).to have_content("2022")
end
end
context "When the sales log feature flag is toggled" do
before do
allow(Rails.env).to receive(:production?).and_return(true)
end
it "hides the create sales log button in production" do
visit("/logs")
expect(page).to_not have_content("Create a new sales log")
end
end
end
end

Loading…
Cancel
Save