Sha256: 23a9c79811eebf26fb6879cd90ce0c205025af95eada0f734b8f951db52a083a

Contents?: true

Size: 1.15 KB

Versions: 35

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

require "spec_helper"

shared_examples_for "authorable interface" do
  describe "author" do
    describe "when author is not present" do
      let(:author) { nil }
      let(:query) { "{ author { name } }" }

      before do
        model.update(author: author)
      end

      it "does not include the author" do
        expect(response["author"]).to be_nil
      end
    end

    describe "with a regular user" do
      let(:author) { create(:user, organization: model.participatory_space.organization) }
      let(:query) { "{ author { name } }" }

      before do
        model.update(author: author, user_group: nil)
      end

      it "includes the user's ID" do
        expect(response["author"]["name"]).to eq(author.name)
      end
    end

    describe "with a user group" do
      let(:user_group) { create(:user_group, organization: model.participatory_space.organization) }
      let(:query) { "{ author { name } }" }

      before do
        model.update(user_group: user_group, author: nil)
      end

      it "includes the user's ID" do
        expect(response["author"]["name"]).to eq(user_group.name)
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
decidim-core-0.26.10 lib/decidim/core/test/shared_examples/authorable_interface_examples.rb
decidim-core-0.26.9 lib/decidim/core/test/shared_examples/authorable_interface_examples.rb
decidim-core-0.26.8 lib/decidim/core/test/shared_examples/authorable_interface_examples.rb
decidim-core-0.26.7 lib/decidim/core/test/shared_examples/authorable_interface_examples.rb
decidim-core-0.26.5 lib/decidim/core/test/shared_examples/authorable_interface_examples.rb
decidim-core-0.26.4 lib/decidim/core/test/shared_examples/authorable_interface_examples.rb
decidim-core-0.26.3 lib/decidim/core/test/shared_examples/authorable_interface_examples.rb
decidim-core-0.26.2 lib/decidim/core/test/shared_examples/authorable_interface_examples.rb
decidim-core-0.26.1 lib/decidim/core/test/shared_examples/authorable_interface_examples.rb
decidim-core-0.26.0 lib/decidim/core/test/shared_examples/authorable_interface_examples.rb
decidim-core-0.26.0.rc2 lib/decidim/core/test/shared_examples/authorable_interface_examples.rb
decidim-core-0.26.0.rc1 lib/decidim/core/test/shared_examples/authorable_interface_examples.rb
decidim-core-0.25.2 lib/decidim/core/test/shared_examples/authorable_interface_examples.rb
decidim-core-0.25.1 lib/decidim/core/test/shared_examples/authorable_interface_examples.rb
decidim-core-0.25.0 lib/decidim/core/test/shared_examples/authorable_interface_examples.rb
decidim-core-0.25.0.rc4 lib/decidim/core/test/shared_examples/authorable_interface_examples.rb
decidim-core-0.25.0.rc3 lib/decidim/core/test/shared_examples/authorable_interface_examples.rb
decidim-core-0.25.0.rc2 lib/decidim/core/test/shared_examples/authorable_interface_examples.rb
decidim-core-0.25.0.rc1 lib/decidim/core/test/shared_examples/authorable_interface_examples.rb
decidim-core-0.24.3 lib/decidim/core/test/shared_examples/authorable_interface_examples.rb