From 91c204a6e8802e220fccf62f20f7c90f61a15640 Mon Sep 17 00:00:00 2001 From: Clyde Date: Mon, 16 Sep 2024 14:17:12 -0700 Subject: [PATCH] now accessing api key via env variable instead of credentials file --- .github/workflows/rubyonrails.yml | 18 +++++++++--------- Gemfile | 1 + spec/services/ticket_master_service_spec.rb | 4 ++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/workflows/rubyonrails.yml b/.github/workflows/rubyonrails.yml index 27c3921..c18637d 100644 --- a/.github/workflows/rubyonrails.yml +++ b/.github/workflows/rubyonrails.yml @@ -86,10 +86,10 @@ jobs: POSTGRES_USER: rails POSTGRES_PASSWORD: password - env: - RAILS_ENV: test - DATABASE_URL: "postgres://rails:password@localhost:5432/rails_test" - TICKETMASTER_API_KEY: ${{ secrets.TICKETMASTER_API_KEY }} + env: + RAILS_ENV: test + DATABASE_URL: "postgres://rails:password@localhost:5432/rails_test" + RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} steps: - name: Checkout code @@ -103,11 +103,11 @@ jobs: - name: Set up database run: bin/rails db:create db:schema:load - - name: Set up Rails credentials - run: | - mkdir -p ~/.rails - echo "${{ secrets.RAILS_CREDENTIALS_CONTENT }}" > ~/.rails/credentials.yml.enc - echo "${{ secrets.RAILS_MASTER_KEY }}" > ~/.rails/master.key + # - name: Set up Rails credentials + # run: | + # mkdir -p ~/.rails + # echo "${{ secrets.RAILS_CREDENTIALS_CONTENT }}" > ~/.rails/credentials.yml.enc + # echo "${{ secrets.RAILS_MASTER_KEY }}" > ~/.rails/master.key - name: Run tests run: bundle exec rspec diff --git a/Gemfile b/Gemfile index 9dba497..92b6d84 100644 --- a/Gemfile +++ b/Gemfile @@ -44,6 +44,7 @@ group :development, :test do gem "factory_bot_rails" gem 'bundler-audit' gem 'brakeman' + gem 'dotenv-rails' gem "rspec" gem "shoulda-matchers", "~> 5.0" gem 'rswag' diff --git a/spec/services/ticket_master_service_spec.rb b/spec/services/ticket_master_service_spec.rb index 721fdcb..626946c 100644 --- a/spec/services/ticket_master_service_spec.rb +++ b/spec/services/ticket_master_service_spec.rb @@ -7,8 +7,8 @@ base_url = "https://app.ticketmaster.com/discovery/v2/events.json" json_response_drake = File.read("spec/fixtures/drake_events.json") - api_key = Rails.application.credentials.ticket_master[:api_key] - # api_key = ENV['TICKETMASTER_API_KEY'] + # api_key = Rails.application.credentials.ticket_master[:api_key] + api_key = ENV['TICKETMASTER_API_KEY'] artist = "Drake" stub_request(:get, "#{base_url}?keyword=#{artist}&apikey=#{api_key}")