Sha256: a1a262100c787180086b86d352d82030d9090284bbe92920278dd39b1d2e46e5

Contents?: true

Size: 1.15 KB

Versions: 20

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

require "spec_helper"
require "decidim/api/test/type_context"

module Decidim
  module Comments
    describe CommentMutationType do
      include_context "graphql type"
      let(:model) { create(:comment) }

      describe "upVote" do
        let(:query) { "{ upVote { upVoted } }" }

        before do
          allow(Decidim::Comments::VoteComment).to receive(:call).with(model, current_user, weight: 1).and_return(model)
        end

        it "should call UpVoteComment command" do
          expect(model).to receive(:up_voted_by?).with(current_user).and_return(true)
          expect(response["upVote"]).to include("upVoted" => true)
        end
      end

      describe "downVote" do
        let(:query) { "{ downVote { downVoted } }" }

        before do
          allow(Decidim::Comments::VoteComment).to receive(:call).with(model, current_user, weight: -1).and_return(model)
        end

        it "should call UpVoteComment command" do
          expect(model).to receive(:down_voted_by?).with(current_user).and_return(true)
          expect(response["downVote"]).to include("downVoted" => true)
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
decidim-0.6.8 decidim-comments/spec/types/comment_mutation_type_spec.rb
decidim-0.6.7 decidim-comments/spec/types/comment_mutation_type_spec.rb
decidim-0.6.6 decidim-comments/spec/types/comment_mutation_type_spec.rb
decidim-0.6.5 decidim-comments/spec/types/comment_mutation_type_spec.rb
decidim-0.6.4 decidim-comments/spec/types/comment_mutation_type_spec.rb
decidim-0.6.3 decidim-comments/spec/types/comment_mutation_type_spec.rb
decidim-0.6.2 decidim-comments/spec/types/comment_mutation_type_spec.rb
decidim-0.6.1 decidim-comments/spec/types/comment_mutation_type_spec.rb
decidim-0.6.0 decidim-comments/spec/types/comment_mutation_type_spec.rb
decidim-0.5.1 decidim-comments/spec/types/comment_mutation_type_spec.rb
decidim-0.5.0 decidim-comments/spec/types/comment_mutation_type_spec.rb
decidim-0.4.4 decidim-comments/spec/types/comment_mutation_type_spec.rb
decidim-0.4.3 decidim-comments/spec/types/comment_mutation_type_spec.rb
decidim-0.4.2 decidim-comments/spec/types/comment_mutation_type_spec.rb
decidim-0.4.1 decidim-comments/spec/types/comment_mutation_type_spec.rb
decidim-0.4.0 decidim-comments/spec/types/comment_mutation_type_spec.rb
decidim-0.3.2 decidim-comments/spec/types/comment_mutation_type_spec.rb
decidim-0.3.1 decidim-comments/spec/types/comment_mutation_type_spec.rb
decidim-0.3.0 decidim-comments/spec/types/comment_mutation_type_spec.rb
decidim-0.2.0 decidim-comments/spec/types/comment_mutation_type_spec.rb