Sha256: 87374ea9a259b45018ff9b2b370b60d080090b7d95d46218b89d95230bd92a96

Contents?: true

Size: 1.39 KB

Versions: 5

Compression:

Stored size: 1.39 KB

Contents

# frozen_string_literal: true
require "spec_helper"
require "decidim/api/test/type_context"

module Decidim
  module Comments
    describe CommentableType do
      include_context "graphql type"

      let(:model) { create(:dummy_resource) }
      let!(:comments) { create_list(:comment, 3, commentable: model) }

      describe "acceptsNewComments" do
        let(:query) { "{ acceptsNewComments }" }

        it "returns the 'accepts_new_comments?' method value" do
          expect(response).to include("acceptsNewComments" => model.accepts_new_comments?)
        end
      end

      describe "commentsHaveAlignment" do
        let(:query) { "{ commentsHaveAlignment }" }

        it "returns the 'comments_have_alignment?' method value" do
          expect(response).to include("commentsHaveAlignment" => model.comments_have_alignment?)
        end
      end

      describe "commentsHaveVotes" do
        let(:query) { "{ commentsHaveVotes }" }

        it "returns the 'comments_have_votes?' method value" do
          expect(response).to include("commentsHaveVotes" => model.comments_have_votes?)
        end
      end

      describe "comments" do
        let(:query) { "{ comments { id } }" }

        it "returns the commentable comments" do
          model.comments.each do |comment|
            expect(response["comments"]).to include("id" => comment.id.to_s)
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-0.1.0 decidim-comments/spec/types/commentable_type_spec.rb
decidim-0.0.8.1 decidim-comments/spec/types/commentable_type_spec.rb
decidim-0.0.7 decidim-comments/spec/types/commentable_type_spec.rb
decidim-0.0.6 decidim-comments/spec/types/commentable_type_spec.rb
decidim-0.0.5 decidim-comments/spec/types/commentable_type_spec.rb