Sha256: 3ee598f40d83e72006a27d7de455ab5909112055b29494644137bec82c33635a

Contents?: true

Size: 1.48 KB

Versions: 44

Compression:

Stored size: 1.48 KB

Contents

require 'spec_helper'

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

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

    it "requests the correct resource" do
      subject.badges
      expect(a_get("http://localhost:3000/admin/badges.json?api_key=test_d7fd0429940&api_username=test_user")).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("http://localhost:3000/users/test_user/activity/badges.json?api_key=test_d7fd0429940&api_username=test_user").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("http://localhost:3000/users/test_user/activity/badges.json?api_key=test_d7fd0429940&api_username=test_user")).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

44 entries across 44 versions & 1 rubygems

Version Path
discourse_api-0.4.2 spec/discourse_api/api/badges_spec.rb
discourse_api-0.4.1 spec/discourse_api/api/badges_spec.rb
discourse_api-0.4.0 spec/discourse_api/api/badges_spec.rb
discourse_api-0.3.6 spec/discourse_api/api/badges_spec.rb