Sha256: 937302651d2384910a38c68ec4d1fa6ba0488471a9da8cad644da61b9de409e2

Contents?: true

Size: 1.21 KB

Versions: 5

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'

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

  describe "#badges" do
    before do
      stub_get("#{host}/admin/badges.json").to_return(body: fixture("badges.json"), headers: { content_type: "application/json" })
    end

    it "requests the correct resource" do
      subject.badges
      expect(a_get("#{host}/admin/badges.json")).to have_been_made
    end

    it "returns the requested badges" do
      badges = subject.badges
      expect(badges).to be_a Hash
      expect(badges['badges']).to be_an Array
    end
  end

  describe "#user-badges" do
    before do
      stub_get("#{host}/user-badges/test_user.json").to_return(body: fixture("user_badges.json"), headers: { content_type: "application/json" })
    end

    it "requests the correct resource" do
      subject.user_badges('test_user')
      expect(a_get("#{host}/user-badges/test_user.json")).to have_been_made
    end

    it "returns the requested user badges" do
      badges = subject.user_badges('test_user')
      expect(badges).to be_an Array
      expect(badges.first).to be_a Hash
      expect(badges.first).to have_key('badge_type_id')
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
discourse_api-0.39.3 spec/discourse_api/api/badges_spec.rb
discourse_api-0.39.2 spec/discourse_api/api/badges_spec.rb
discourse_api-0.39.1 spec/discourse_api/api/badges_spec.rb
discourse_api-0.39.0 spec/discourse_api/api/badges_spec.rb
discourse_api-0.38.0 spec/discourse_api/api/badges_spec.rb