Sha256: 7d64d3825a308de2279b00fa8d24f049020b462c89fb3a807cda6231bf22b8ad

Contents?: true

Size: 1.87 KB

Versions: 58

Compression:

Stored size: 1.87 KB

Contents

# frozen_string_literal: true

require "spec_helper"

shared_examples_for "amendable proposals interface" do
  describe "amendments" do
    let(:query) do
      '{ amendments {
      state
      amendable { ...on Proposal { title { translation(locale: "en") } } }
      amendableType
      emendation { ...on Proposal { title { translation(locale: "en") } } }
      emendationType
      amender { name }
    } }'
    end

    it "includes the amendments states" do
      amendments_states = response["amendments"].map { |amendment| amendment["state"] }
      expect(amendments_states).to include(*model.amendments.map(&:state))
    end

    it "amendable types matches Proposals Type" do
      response["amendments"].each do |amendment|
        expect(amendment["amendableType"]).to eq("Decidim::Proposals::Proposal")
      end
    end

    it "emendation types matches Proposals Type" do
      response["amendments"].each do |amendment|
        expect(amendment["emendationType"]).to eq("Decidim::Proposals::Proposal")
      end
    end

    it "returns amendable as parent proposal" do
      amendment_amendables = response["amendments"].map { |amendment| amendment["amendable"] }.map { |title| title["title"]["translation"] }
      expect(amendment_amendables).to include(*model.amendments.map(&:amendable).map { |p| p.title["en"] })
    end

    it "returns emendations received" do
      amendment_emendations = response["amendments"].map { |amendment| amendment["emendation"] }.map { |title| title["title"]["translation"] }
      expect(amendment_emendations).to include(*model.amendments.map(&:emendation).map { |p| p.title["en"] })
    end

    it "returns amender as emendation author" do
      amendment_amenders = response["amendments"].map { |amendment| amendment["amender"] }
      expect(amendment_amenders).to include(*model.amendments.map(&:amender).map { |p| { "name" => p.name } })
    end
  end
end

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
decidim-core-0.29.1 lib/decidim/core/test/shared_examples/amendable_proposals_interface_examples.rb
decidim-core-0.28.4 lib/decidim/core/test/shared_examples/amendable_proposals_interface_examples.rb
decidim-core-0.27.9 lib/decidim/core/test/shared_examples/amendable_proposals_interface_examples.rb
decidim-core-0.29.0 lib/decidim/core/test/shared_examples/amendable_proposals_interface_examples.rb
decidim-core-0.28.3 lib/decidim/core/test/shared_examples/amendable_proposals_interface_examples.rb
decidim-core-0.27.8 lib/decidim/core/test/shared_examples/amendable_proposals_interface_examples.rb
decidim-core-0.29.0.rc4 lib/decidim/core/test/shared_examples/amendable_proposals_interface_examples.rb
decidim-core-0.29.0.rc3 lib/decidim/core/test/shared_examples/amendable_proposals_interface_examples.rb
decidim-core-0.29.0.rc2 lib/decidim/core/test/shared_examples/amendable_proposals_interface_examples.rb
decidim-core-0.29.0.rc1 lib/decidim/core/test/shared_examples/amendable_proposals_interface_examples.rb
decidim-core-0.28.2 lib/decidim/core/test/shared_examples/amendable_proposals_interface_examples.rb
decidim-core-0.27.7 lib/decidim/core/test/shared_examples/amendable_proposals_interface_examples.rb
decidim-core-0.28.1 lib/decidim/core/test/shared_examples/amendable_proposals_interface_examples.rb
decidim-core-0.27.6 lib/decidim/core/test/shared_examples/amendable_proposals_interface_examples.rb
decidim-core-0.26.10 lib/decidim/core/test/shared_examples/amendable_proposals_interface_examples.rb
decidim-core-0.26.9 lib/decidim/core/test/shared_examples/amendable_proposals_interface_examples.rb
decidim-core-0.28.0 lib/decidim/core/test/shared_examples/amendable_proposals_interface_examples.rb
decidim-core-0.27.5 lib/decidim/core/test/shared_examples/amendable_proposals_interface_examples.rb
decidim-core-0.28.0.rc5 lib/decidim/core/test/shared_examples/amendable_proposals_interface_examples.rb
decidim-core-0.28.0.rc4 lib/decidim/core/test/shared_examples/amendable_proposals_interface_examples.rb