Class: TestsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/tests_controller.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) create



13
14
15
16
17
18
19
# File 'app/controllers/tests_controller.rb', line 13

def create
  if @test.save
    render json: @test, status: :created
  else
    render json: {errors: @test.errors}, status: :unprocessable_entity
  end
end

- (Object) index



8
9
10
11
# File 'app/controllers/tests_controller.rb', line 8

def index
  @tests.each &:check_readiness
  render json: @tests, status: :ok
end

- (Object) show



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/tests_controller.rb', line 21

def show
  @test.check_readiness
  if test_params[:show_all]
    render json: @test.as_json(
       include: {
           tasks: {
               include: {
                   prototype: {
                       include: {
                           mockups: {
                               methods: :elements
                           }
                       }
                   }
               }
           }
       }), status: :ok
  else
    render json: @test, status: :ok
  end
end

- (Object) update



43
44
45
46
# File 'app/controllers/tests_controller.rb', line 43

def update
  @test.update_attributes(test_params)
  render json: @test, status: :ok
end