Browse Source

lint

pull/863/head
Ted-U 3 years ago committed by baarkerlounger
parent
commit
b273ae2583
  1. 2
      app/controllers/lettings_logs_controller.rb
  2. 2
      app/controllers/logs_controller.rb
  3. 2
      app/controllers/sales_logs_controller.rb
  4. 4
      app/models/sales_log.rb
  5. 2
      config/initializers/feature_toggle.rb
  6. 5
      spec/features/log_spec.rb

2
app/controllers/lettings_logs_controller.rb

@ -86,7 +86,7 @@ private
def permitted_log_params
params.require(:lettings_log).permit(LettingsLog.editable_fields)
end
end
def find_resource
@lettings_log = LettingsLog.find_by(id: params[:id])

2
app/controllers/logs_controller.rb

@ -44,7 +44,7 @@ private
api_log_params
end
end
def api_log_params
return {} unless params[:lettings_log] || params[:sales_log]

2
app/controllers/sales_logs_controller.rb

@ -24,5 +24,5 @@ class SalesLogsController < LogsController
def permitted_log_params
params.require(:sales_log).permit(SalesLog.editable_fields)
end
end
end

4
app/models/sales_log.rb

@ -9,7 +9,7 @@ class SalesLog < Log
before_save :update_status!
scope :filter_by_organisation, ->(org, _user = nil) { where(owning_organisation: org).or(where(managing_organisation: org)) }
STATUS = { "not_started" => 0, "in_progress" => 1, "completed" => 2 }.freeze
enum status: STATUS
@ -47,7 +47,7 @@ class SalesLog < Log
status == "completed"
end
private
private
def update_status!
self.status = if all_fields_completed? && errors.empty?

2
config/initializers/feature_toggle.rb

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

5
spec/features/log_spec.rb

@ -155,14 +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
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")
expect(page).not_to have_content("Create a new sales log")
end
end
end

Loading…
Cancel
Save