Sha256: 091c05c94294d266f4951c92a5d8141084d5fac6a5f292c899c1b438fabda165

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true
require "spec_helper"

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

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

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

    it "returns the requested settings" do
      settings = subject.email_settings
      expect(settings).to be_a Hash
      expect(settings).to have_key("delivery_method")
      expect(settings).to have_key("settings")
    end
  end

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

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

    it "returns all email" do
      all_email = subject.list_email("all")
      expect(all_email).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/email_spec.rb
discourse_api-2.0.0 spec/discourse_api/api/email_spec.rb