Sha256: 616cc9816d0652a85f48b52dece3fb5c1912c4638d65685642a29d9b3ea933d2

Contents?: true

Size: 1.77 KB

Versions: 24

Compression:

Stored size: 1.77 KB

Contents

require 'spec_helper'

describe DiscourseApi::API::Posts do
  let (:client) { DiscourseApi::Client.new("http://localhost:3000", "test_d7fd0429940", "test_user") }

  describe "#get_post" do
    before do
      stub_get("http://localhost:3000/posts/11.json?api_key=test_d7fd0429940&api_username=test_user").to_return(body: fixture("post.json"), headers: { content_type: "application/json" })
    end

    it "fetches a post" do
      the_post = client.get_post(11)
      expect(the_post).to be_a Hash
      expect(the_post['id']).to eq(11)
    end
  end

  describe "#wikify_post" do
    before do
      stub_put("http://localhost:3000/posts/9999/wiki?api_key=test_d7fd0429940&api_username=test_user")
    end

    it "fails on unknown post" do
      client.wikify_post(9999)
      expect(a_put("http://localhost:3000/posts/9999/wiki?api_key=test_d7fd0429940&api_username=test_user")).to have_been_made
    end
  end

  describe "#delete_post" do
    before do
      stub_delete("http://localhost:3000/posts/9999.json?api_key=test_d7fd0429940&api_username=test_user")
    end

    it "deletes a post" do
      client.delete_post(9999)
      expect(a_delete("http://localhost:3000/posts/9999.json?api_key=test_d7fd0429940&api_username=test_user")).to have_been_made
    end
  end

  describe "#post_action_users" do
    before do
      stub_get("http://localhost:3000/post_action_users.json?api_key=test_d7fd0429940&api_username=test_user&id=11&post_action_type_id=2").to_return(body: fixture("post_action_users.json"), headers: { content_type: "application/json" })
    end

    it "fetches post_action_users" do
      post_action_users = client.post_action_users(11, 2)
      expect(post_action_users).to be_a Hash
      expect(post_action_users["post_action_users"][0]["id"]).to eq(1286)
    end
  end

end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
discourse_api-0.33.0 spec/discourse_api/api/posts_spec.rb
discourse_api-0.32.0 spec/discourse_api/api/posts_spec.rb
discourse_api-0.31.0 spec/discourse_api/api/posts_spec.rb
discourse_api-0.30.0 spec/discourse_api/api/posts_spec.rb
discourse_api-0.29.0 spec/discourse_api/api/posts_spec.rb
discourse_api-0.28.1 spec/discourse_api/api/posts_spec.rb
discourse_api-0.28.0 spec/discourse_api/api/posts_spec.rb
discourse_api-0.27.0 spec/discourse_api/api/posts_spec.rb
discourse_api-0.26.0 spec/discourse_api/api/posts_spec.rb
discourse_api-0.25.0 spec/discourse_api/api/posts_spec.rb
discourse_api-0.24.0 spec/discourse_api/api/posts_spec.rb
discourse_api-0.23.1 spec/discourse_api/api/posts_spec.rb
discourse_api-0.23.0 spec/discourse_api/api/posts_spec.rb
discourse_api-0.22.0 spec/discourse_api/api/posts_spec.rb
discourse_api-0.20.1 spec/discourse_api/api/posts_spec.rb
discourse_api-0.20.0 spec/discourse_api/api/posts_spec.rb
discourse_api-0.19.0 spec/discourse_api/api/posts_spec.rb
discourse_api-0.18.0 spec/discourse_api/api/posts_spec.rb
discourse_api-0.17.0 spec/discourse_api/api/posts_spec.rb
discourse_api-0.16.1 spec/discourse_api/api/posts_spec.rb