Sha256: 7f92acac8d6cb37605a24598fd06e8bce32b2dec841a8d7117e25529213f12da

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true
require "spec_helper"

describe DiscourseApi::API::UserActions do
  subject { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }

  describe "#user_replies" do
    before do
      stub_get("#{host}/user_actions.json?username=testuser&filter=5").to_return(
        body: fixture("replies.json"),
        headers: {
          content_type: "application/json",
        },
      )
    end

    it "requests the correct resource" do
      subject.user_replies("testuser")
      expect(a_get("#{host}/user_actions.json?username=testuser&filter=5")).to have_been_made
    end

    it "returns the requested user" do
      replies = subject.user_replies("testuser")
      expect(replies).to be_an Array
    end
  end

  describe "#user_topics_and_replies" do
    before do
      stub_get("#{host}/user_actions.json?username=testuser&filter=4,5").to_return(
        body: fixture("replies_and_topics.json"),
        headers: {
          content_type: "application/json",
        },
      )
    end

    it "requests the correct resource" do
      subject.user_topics_and_replies("testuser")
      expect(a_get("#{host}/user_actions.json?username=testuser&filter=4,5")).to have_been_made
    end

    it "returns the requested user" do
      replies = subject.user_topics_and_replies("testuser")
      expect(replies).to be_an Array
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
discourse_api-2.0.1 spec/discourse_api/api/user_actions_spec.rb
discourse_api-2.0.0 spec/discourse_api/api/user_actions_spec.rb