Sha256: fb63a244087110d37c1b3962a931c4dec22da97d30d2e811682acc5ec811151b

Contents?: true

Size: 1.76 KB

Versions: 5

Compression:

Stored size: 1.76 KB

Contents

require 'spec_helper'

describe "users" do
  let(:client) { create_client }
  it_should_behave_like "a resource", 
    :users,
    lambda { {email: "zendesk2+#{Zendesk2.uuid}@example.org", name: Zendesk2.uuid, verified: true} },
  lambda { {name: Zendesk2.uuid} }

  it "should get current user" do
    current_user = client.users.current
    current_user.should be_a(Zendesk2::Client::User)
    current_user.email.should == client.username
  end

  describe do
    let(:user) { client.users.create(email: "zendesk2+#{Zendesk2.uuid}@example.org", name: Zendesk2.uuid) }
    after(:all) { user.destroy }

    it "should update organization" do
      organization = client.organizations.create(name: Zendesk2.uuid)
      user.organization= organization
      user.save.should be_true
      user.organization.should == organization
    end

    it "should get requested tickets" do
      ticket = client.tickets.create(requester: user, subject: Zendesk2.uuid, description: Zendesk2.uuid)

      user.requested_tickets.should include ticket
    end

    it "should get ccd tickets" do
      ticket = client.tickets.create(collaborators: [user], subject: Zendesk2.uuid, description: Zendesk2.uuid)

      user.ccd_tickets.should include ticket
    end

    it "cannot destroy a user with a ticket" do
      ticket = client.tickets.create(requester: user, subject: Zendesk2.uuid, description: Zendesk2.uuid)

      user.destroy.should be_false

      user.should_not be_destroyed
    end

    it "should hate non-unique emails" do
      email = "zendesk2+#{Zendesk2.uuid}@example.org"
      client.users.create(email: email, name: Zendesk2.uuid)
      lambda { client.users.create(email: email, name: Zendesk2.uuid) }.should raise_exception(Zendesk2::Error)
    end

    it "should form login url"
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
zendesk2-0.0.18 spec/users_spec.rb
zendesk2-0.0.17 spec/users_spec.rb
zendesk2-0.0.16 spec/users_spec.rb
zendesk2-0.0.15 spec/users_spec.rb
zendesk2-0.0.14 spec/users_spec.rb