diff --git a/.github/workflows/brakeman-analysis.yml b/.github/workflows/brakeman-analysis.yml index ac51638..26ad7b1 100644 --- a/.github/workflows/brakeman-analysis.yml +++ b/.github/workflows/brakeman-analysis.yml @@ -6,39 +6,39 @@ name: Brakeman Scan # This section configures the trigger for the workflow. Feel free to customize depending on your convention on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] jobs: brakeman-scan: name: Brakeman Scan runs-on: ubuntu-latest steps: - # Checkout the repository to the GitHub Actions runner - - name: Checkout - uses: actions/checkout@v2 + # Checkout the repository to the GitHub Actions runner + - name: Checkout + uses: actions/checkout@v2 - # Customize the ruby version depending on your needs - - name: Setup Ruby - uses: actions/setup-ruby@v1 - with: - ruby-version: '2.7' + # Customize the ruby version depending on your needs + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: "3.0" - - name: Setup Brakeman - env: - BRAKEMAN_VERSION: '4.10' # SARIF support is provided in Brakeman version 4.10+ - run: | - gem install brakeman --version $BRAKEMAN_VERSION + - name: Setup Brakeman + env: + BRAKEMAN_VERSION: "5.4" # SARIF support is provided in Brakeman version 4.10+ + run: | + gem install brakeman --version $BRAKEMAN_VERSION - # Execute Brakeman CLI and generate a SARIF output with the security issues identified during the analysis - - name: Scan - continue-on-error: true - run: | - brakeman -f sarif -o output.sarif.json . + # Execute Brakeman CLI and generate a SARIF output with the security issues identified during the analysis + - name: Scan + continue-on-error: true + run: | + brakeman -f sarif -o output.sarif.json . - # Upload the SARIF file generated in the previous step - - name: Upload SARIF - uses: github/codeql-action/upload-sarif@v1 - with: - sarif_file: output.sarif.json + # Upload the SARIF file generated in the previous step + - name: Upload SARIF + uses: github/codeql-action/upload-sarif@v1 + with: + sarif_file: output.sarif.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7e6c588..ac8d48e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,15 +11,21 @@ jobs: fail-fast: false matrix: alchemy_branch: + - 6.0-stable - main + ruby: + - "2.7" + - "3.0" + - "3.1" env: ALCHEMY_BRANCH: ${{ matrix.alchemy_branch }} steps: - uses: actions/checkout@v1 - - name: Set up Ruby 2.6 - uses: actions/setup-ruby@v1 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 with: - ruby-version: 2.6.x + ruby-version: ${{ matrix.ruby }} + bundler-cache: true - name: Restore apt cache id: apt-cache uses: actions/cache@v1 @@ -32,21 +38,6 @@ jobs: sudo apt-get update -qq sudo apt-get install -qq --fix-missing libsqlite3-dev -o dir::cache::archives="/home/runner/apt/cache" sudo chown -R runner /home/runner/apt/cache - - name: Install bundler - run: | - gem install bundler - - name: Restore Ruby Gems cache - id: cache - uses: actions/cache@v1 - with: - path: vendor/bundle - key: bundle-${{ hashFiles('**/Gemfile.lock') }}-${{ matrix.alchemy_branch }} - restore-keys: | - bundle- - - name: Install bundle - timeout-minutes: 10 - run: | - bundle install --jobs 4 --retry 3 --path vendor/bundle - name: Build and test with RSpec env: RAILS_ENV: test diff --git a/app/serializers/alchemy/json_api/ingredient_headline_serializer.rb b/app/serializers/alchemy/json_api/ingredient_headline_serializer.rb index cd33a77..ec7b153 100644 --- a/app/serializers/alchemy/json_api/ingredient_headline_serializer.rb +++ b/app/serializers/alchemy/json_api/ingredient_headline_serializer.rb @@ -8,6 +8,11 @@ class IngredientHeadlineSerializer < BaseSerializer include IngredientSerializer attributes :level, :size + + # Introduced in Alchemy 6.1 + if Alchemy::Ingredients::Headline.stored_attributes[:data].include?(:dom_id) + attribute :dom_id + end end end end diff --git a/app/serializers/alchemy/json_api/ingredient_text_serializer.rb b/app/serializers/alchemy/json_api/ingredient_text_serializer.rb index 0bd068c..054c04d 100644 --- a/app/serializers/alchemy/json_api/ingredient_text_serializer.rb +++ b/app/serializers/alchemy/json_api/ingredient_text_serializer.rb @@ -17,6 +17,11 @@ class IngredientTextSerializer < BaseSerializer # maintain compatibility with EssenceText attribute :body, &:value attribute :link_url, &:link + + # Introduced in Alchemy 6.1 + if Alchemy::Ingredients::Text.stored_attributes[:data].include?(:dom_id) + attribute :dom_id + end end end end diff --git a/spec/serializers/alchemy/json_api/ingredient_file_serializer_spec.rb b/spec/serializers/alchemy/json_api/ingredient_file_serializer_spec.rb index 268aff7..7eea312 100644 --- a/spec/serializers/alchemy/json_api/ingredient_file_serializer_spec.rb +++ b/spec/serializers/alchemy/json_api/ingredient_file_serializer_spec.rb @@ -18,7 +18,7 @@ end it "has the right keys and values" do - expect(subject[:value]).to eq("/attachment/#{attachment.id}/show") + expect(subject[:value]).to eq("/attachment/#{attachment.id}/show.png") expect(subject[:link_title]).to eq("File") expect(subject[:attachment_name]).to eq("image") expect(subject[:attachment_file_name]).to eq("image.png") diff --git a/spec/serializers/alchemy/json_api/ingredient_headline_serializer_spec.rb b/spec/serializers/alchemy/json_api/ingredient_headline_serializer_spec.rb index 4cfa66b..189dc4f 100644 --- a/spec/serializers/alchemy/json_api/ingredient_headline_serializer_spec.rb +++ b/spec/serializers/alchemy/json_api/ingredient_headline_serializer_spec.rb @@ -30,4 +30,14 @@ ) ) end + + context "with dom_id", if: Alchemy::Ingredients::Headline.stored_attributes[:data].include?(:dom_id) do + before do + ingredient.dom_id = "hello-you-world" + end + + it "is included in the response" do + expect(subject[:dom_id]).to eq "hello-you-world" + end + end end diff --git a/spec/serializers/alchemy/json_api/ingredient_text_serializer_spec.rb b/spec/serializers/alchemy/json_api/ingredient_text_serializer_spec.rb index b69d786..9233f22 100644 --- a/spec/serializers/alchemy/json_api/ingredient_text_serializer_spec.rb +++ b/spec/serializers/alchemy/json_api/ingredient_text_serializer_spec.rb @@ -37,5 +37,15 @@ expect(subject[:link_url]).to eq "https://alchemy-cms.com" end end + + context "with dom_id", if: Alchemy::Ingredients::Text.stored_attributes[:data].include?(:dom_id) do + before do + ingredient.dom_id = "welcome" + end + + it "is included in the response" do + expect(subject[:dom_id]).to eq "welcome" + end + end end end