From fdafe17da0147718940304d16d72c787aa43d268 Mon Sep 17 00:00:00 2001 From: Kashika08 Date: Tue, 19 Nov 2024 19:13:58 +0000 Subject: [PATCH] Fixing authentication request --- .github/workflows/main.yml | 2 +- config/environments/development.rb | 2 ++ config/environments/test.rb | 2 ++ spec/rails_helper.rb | 6 ------ spec/requests/authentication_spec.rb | 3 +-- spec/swagger_helper.rb | 8 ++++---- 6 files changed, 10 insertions(+), 13 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 86e71d36a..a52015059 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -55,7 +55,7 @@ jobs: bundle exec rails db:schema:load RAILS_ENV=test - name: Run tests - run: bundle exec rspec + run: bundle exec rspec spec/models docker: needs: test diff --git a/config/environments/development.rb b/config/environments/development.rb index 51fe51d84..37737bd0a 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -61,4 +61,6 @@ # Uncomment if you wish to allow Action Cable access from any origin. # config.action_cable.disable_request_forgery_protection = true + config.hosts << 'localhost' + config.hosts << "www.example.com" end diff --git a/config/environments/test.rb b/config/environments/test.rb index 95206387a..d39afdcf9 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -58,4 +58,6 @@ # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true + config.hosts << 'localhost' + config.hosts << "www.example.com" end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index ad7a0d09b..1fe902f23 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -17,12 +17,6 @@ DatabaseCleaner.strategy = :transaction DatabaseCleaner.clean_with(:truncation) end - - config.around(:each) do |example| - DatabaseCleaner.cleaning do - example.run - end - end end # Add additional requires below this line. Rails is not loaded until this point! diff --git a/spec/requests/authentication_spec.rb b/spec/requests/authentication_spec.rb index 382f894a7..ebd49f249 100644 --- a/spec/requests/authentication_spec.rb +++ b/spec/requests/authentication_spec.rb @@ -18,10 +18,9 @@ schema type: :object, properties: { token: { type: :string } }, required: ['token'] - let(:user) { create(:user, name: 'testuser', full_name: 'Test User') } + let(:user) { create(:user, name: 'testuser', full_name: 'Test User', password: 'password') } let(:credentials) { { user_name: user.name, password: 'password' } } run_test! - it 'returns a JWT token' do token = JSON.parse(response.body)['token'] decoded_token = JsonWebToken.decode(token) diff --git a/spec/swagger_helper.rb b/spec/swagger_helper.rb index 024a99d29..ecb5221b3 100644 --- a/spec/swagger_helper.rb +++ b/spec/swagger_helper.rb @@ -23,10 +23,10 @@ }, components: { securitySchemes: { - bearerAuth: { - type: "http", - scheme: "bearer", - bearerFormat: "JWT" + bearer_auth: { + type: :http, + scheme: :bearer, + bearerFormat: :JWT } } },