diff options
Diffstat (limited to 'test/controllers/backends/terraform_aws_controller_test.rb')
-rw-r--r-- | test/controllers/backends/terraform_aws_controller_test.rb | 85 |
1 files changed, 80 insertions, 5 deletions
diff --git a/test/controllers/backends/terraform_aws_controller_test.rb b/test/controllers/backends/terraform_aws_controller_test.rb index 0c574fa..41373b8 100644 --- a/test/controllers/backends/terraform_aws_controller_test.rb +++ b/test/controllers/backends/terraform_aws_controller_test.rb @@ -1,14 +1,89 @@ -require 'test_helper' +require 'integration_test_helper' class Backends::TerraformAwsControllerTest < ActionDispatch::IntegrationTest - test "should get new" do - get backends_terraform_aws_new_url + setup do + login_as User.new(name: 'Test', email: 'test@example.com') + end + + test 'new' do + get new_terraform_aws_backend_path + assert_response :success + end + + test 'create' do + attributes = { + label: 'Test Backend', + aws_region: 'test-region', + aws_access_key_id: 'test-access-key-id', + aws_secret_access_key: 'test-secret-access-key' + } + + post( + terraform_aws_backends_path, + params: { + backends_terraform_aws: attributes + } + ) + + assert_response :redirect + follow_redirect! + assert_response :success + + backend = Backends::TerraformAws.last + attributes.each do |(key, value)| + assert_equal backend.send(key), value + end + end + + test 'update' do + backend = Backends::TerraformAws.create( + label: 'Old label', + aws_region: 'old-test-region', + aws_access_key_id: 'old-test-access-key-id', + aws_secret_access_key: 'old-test-secret-access-key' + ) + + new_attributes = { + label: 'New label', + aws_access_key_id: 'new-test-access-key-id', + aws_secret_access_key: 'new-test-secret-access-key' + } + + put( + terraform_aws_backend_path(backend), + params: { + backends_terraform_aws: new_attributes + } + ) + assert_response :success + + backend.reload end - test "should get show" do - get backends_terraform_aws_show_url + test 'show' do + backend = Backends::TerraformAws.create( + label: 'Test Backend', + aws_region: 'old-test-region', + aws_access_key_id: 'old-test-access-key-id', + aws_secret_access_key: 'old-test-secret-access-key' + ) + + get terraform_aws_backend_path(backend) + assert_response :success end + test 'destroy' do + backend = Backends::TerraformAws.create( + label: 'Test Backend', + aws_region: 'old-test-region', + aws_access_key_id: 'old-test-access-key-id', + aws_secret_access_key: 'old-test-secret-access-key' + ) + + delete terraform_aws_backend_path(backend) + + assert_response :redirect + end end |