Sha256: 439c7fa9f661213a4f875179f9f048bb530203e9c52d3910e5fdf07ebd67d759

Contents?: true

Size: 1.82 KB

Versions: 5

Compression:

Stored size: 1.82 KB

Contents

require "spec_helper"

describe Brightbox::UserCollaboration do

  describe "#remove" do
    context "when collaboration is pending" do
      it "tells model to reject collaboration" do
        data = faux_collaboration_data("pending")
        collaboration = Brightbox::UserCollaboration.new(data)
        expect(collaboration).to receive(:reject)
        collaboration.remove
      end
    end

    context "when collaboration is accepted" do
      it "tells model to destroy collaboration" do
        data = faux_collaboration_data("accepted")
        collaboration = Brightbox::UserCollaboration.new(data)
        expect(collaboration).to receive(:destroy)
        collaboration.remove
      end
    end
  end

  # Returns a fog model of a UserCollaboration to initialise a CLI model
  #
  def faux_collaboration_data(status, _options = {})
    api_response_data = {
      "id" => "col-12345",
      "resource_type" => "collaboration",
      "url" => "https://api.gb1.brightbox.com/1.0/user/collaborations/col-12345",
      "status" => status,
      "email" => "invitee@example.com",
      "role" => "admin",
      "created_at" => "2013-08-13T11:59:24Z",
      "started_at" => nil,
      "finished_at" => "2013-08-13T13:21:58Z",
      "role_label" => "Collaborator",
      "user" => nil,
      "account" => {
        "id" => "acc-12345",
        "resource_type" => "account",
        "url" => "https://api.gb1.brightbox.com/1.0/accounts/acc-12345",
        "name" => "System account",
        "status" => "active"
      },
      "inviter" => {
        "id" => "usr-54321",
        "resource_type" => "user",
        "url" => "https://api.gb1.brightbox.com/1.0/users/usr-54321",
        "name" => "Marie Halvorson",
        "email_address" => "marie@example.com"
      }
    }
    Fog::Brightbox::Compute::UserCollaboration.new(api_response_data)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
brightbox-cli-3.3.0 spec/unit/brightbox/user_collaboration/remove_spec.rb
brightbox-cli-3.2.0 spec/unit/brightbox/user_collaboration/remove_spec.rb
brightbox-cli-3.1.0 spec/unit/brightbox/user_collaboration/remove_spec.rb
brightbox-cli-3.0.1 spec/unit/brightbox/user_collaboration/remove_spec.rb
brightbox-cli-3.0.0 spec/unit/brightbox/user_collaboration/remove_spec.rb