Class: Primer::ViewComponents::AutoCheckController

Inherits:
ApplicationController show all
Defined in:
app/controllers/primer/view_components/auto_check_controller.rb

Overview

For auto-check previews :nocov:

Instance Method Summary collapse

Instance Method Details

#acceptedObject



19
20
21
22
23
24
# File 'app/controllers/primer/view_components/auto_check_controller.rb', line 19

def accepted
  render partial: "primer/view_components/auto_check/warning_message",
    locals: { input_value: params[:value] },
    status: :accepted,
    formats: :html
end

#errorObject



8
9
10
11
12
13
# File 'app/controllers/primer/view_components/auto_check_controller.rb', line 8

def error
  render partial: "primer/view_components/auto_check/error_message",
    locals: { input_value: params[:value] },
    status: :unprocessable_entity,
    formats: :html
end

#okObject



15
16
17
# File 'app/controllers/primer/view_components/auto_check_controller.rb', line 15

def ok
  head :ok
end

#randomObject



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/primer/view_components/auto_check_controller.rb', line 26

def random
  roll = rand
  if roll < 0.33
    head :ok
  elsif roll < 0.66
    render partial: "primer/view_components/auto_check/success_message",
      locals: { input_value: params[:value] },
      status: :ok,
      formats: :html
  else
    render status: :unprocessable_entity, plain: "Random error!"
  end
end