Sha256: 5c0cf1584a5792f5ac5e572d63face9f9daee91234a37570191b78c7b4de3e67

Contents?: true

Size: 1.79 KB

Versions: 12

Compression:

Stored size: 1.79 KB

Contents

require 'spec_helper'

require 'gds_zendesk/client'
require 'gds_zendesk/users'
require 'gds_zendesk/test_helpers'

module GDSZendesk
  describe Users do
    include GDSZendesk::TestHelpers

    let(:users) { Client.new(valid_zendesk_credentials).users }

    context "existing users" do
      before do
        zendesk_has_user(email: "test@test.com", id: 123)
      end

      context "creating/updating a user" do
        it "should update the phone and job title if those are set" do
          stub_post = stub_zendesk_user_update(123, phone: "12345", details: "Job title: Developer")
          users.create_or_update_user(double("requested user", email: "test@test.com", phone: "12345", job: "Developer"))

          expect(stub_post).to have_been_requested
        end
      end

      it "should know whether the user is suspended or not" do
        zendesk_has_user(email: "test@test.com", id: 123, suspended: "true")
        expect(users.suspended?("test@test.com")).to be_truthy
      end
    end

    context "non-existent users" do
      before do
        zendesk_has_no_user_with_email("test@test.com")
      end

      it "should not be suspended" do
        expect(users).to_not be_suspended("test@test.com")
      end

      context "creating/updating" do
        it "should create that user" do
          stub_post = stub_zendesk_user_creation(
            verified: true,
            name: "Abc",
            email: "test@test.com",
            phone: "12345",
            details: "Job title: Developer"
          )
          user_being_requested = double("requested user",
            name: "Abc", email: "test@test.com", phone: "12345", job: "Developer")

          users.create_or_update_user(user_being_requested)
          expect(stub_post).to have_been_requested
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
gds_zendesk-3.2.0 spec/gds_zendesk/users_spec.rb
gds_zendesk-3.1.0 spec/gds_zendesk/users_spec.rb
gds_zendesk-3.0.0 spec/gds_zendesk/users_spec.rb
gds_zendesk-2.4.0 spec/gds_zendesk/users_spec.rb
gds_zendesk-2.3.1 spec/gds_zendesk/users_spec.rb
gds_zendesk-2.3.0 spec/gds_zendesk/users_spec.rb
gds_zendesk-2.2.0 spec/gds_zendesk/users_spec.rb
gds_zendesk-2.1.0 spec/gds_zendesk/users_spec.rb
gds_zendesk-2.0.0 spec/gds_zendesk/users_spec.rb
gds_zendesk-1.0.5 spec/gds_zendesk/users_spec.rb
gds_zendesk-1.0.4 spec/gds_zendesk/users_spec.rb
gds_zendesk-1.0.3 spec/gds_zendesk/users_spec.rb