Sha256: f2594a1064d07b5fd7fc865b2ccf519273c48cc58b3ef499bda4294004f578e1
Contents?: true
Size: 1.96 KB
Versions: 2
Compression:
Stored size: 1.96 KB
Contents
# frozen_string_literal: true require 'test_helper' module Shipit module Api class LocksControllerTest < ApiControllerTestCase setup do authenticate! @stack = shipit_stacks(:shipit) end test "#create sets a lock" do post :create, params: { stack_id: @stack.to_param, reason: 'Just for fun!' } assert_response :ok assert_json 'is_locked', true assert_json 'lock_reason', 'Just for fun!' assert_json { |json| assert_not_nil json['locked_since'] } end test "#create fails if already locked" do @stack.update!(lock_reason: "Don't forget me") post :create, params: { stack_id: @stack.to_param, reason: 'Just for fun!' } assert_response :conflict end test "#update sets a lock" do put :update, params: { stack_id: @stack.to_param, reason: 'Just for fun!' } assert_response :ok assert_json 'is_locked', true assert_json 'lock_reason', 'Just for fun!' end test "#update can override a previous lock" do @stack.update!(lock_reason: 'Meh...') put :update, params: { stack_id: @stack.to_param, reason: 'Just for fun!' } assert_response :ok assert_json 'is_locked', true assert_json 'lock_reason', 'Just for fun!' end test "#update does not override previous locked_since" do since = Time.current.round @stack.update!(lock_reason: 'Meh...', locked_since: since) put :update, params: { stack_id: @stack.to_param, reason: 'Just for fun!' } assert_response :ok assert_json 'locked_since', since.utc.iso8601(3) end test "#destroy clears the lock" do @stack.update!(lock_reason: 'Meh...', locked_since: Time.current) delete :destroy, params: { stack_id: @stack.to_param } assert_response :ok assert_json 'is_locked', false assert_json { |json| assert_nil json['locked_since'] } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
shipit-engine-0.39.0 | test/controllers/api/locks_controller_test.rb |
shipit-engine-0.38.0 | test/controllers/api/locks_controller_test.rb |