Sha256: 1f1bff9495f215cb27911a64a32c7ba8ff9301350ad651af8d22c33d1d7e8ff4

Contents?: true

Size: 1.78 KB

Versions: 2

Compression:

Stored size: 1.78 KB

Contents

require 'spec_helper'
require 'kintone/command/space_members'
require 'kintone/api'

describe Kintone::Command::SpaceMembers do
  let(:target) { Kintone::Command::SpaceMembers.new(api) }
  let(:api) { Kintone::Api.new('example.cybozu.com', 'Administrator', 'cybozu') }

  describe '#get' do
    before(:each) do
      stub_request(
        :get,
        'https://example.cybozu.com/k/v1/space/members.json'
      )
        .with(query: { id: id })
        .to_return(body: response_data.to_json, status: 200,
                   headers: { 'Content-type' => 'application/json' })
    end

    subject { target.get(id) }

    let(:id) { 1 }

    def response_data
      {
        'members' => members
      }
    end

    def members
      [
        {
          'entity' => { 'type' => 'USER', 'code' => 'user1' },
          'isAdmin' => false,
          'isImplicit' => true
        }
      ]
    end

    it { expect(subject).to match members }
  end

  describe '#update' do
    before(:each) do
      stub_request(
        :put,
        'https://example.cybozu.com/k/v1/space/members.json'
      )
        .with(body: request_data.to_json)
        .to_return(body: '{}', status: 200,
                   headers: { 'Content-type' => 'application/json' })
    end

    subject { target.update(id, members) }

    let(:id) { 1 }
    let(:members) do
      [
        {
          'entity' => { 'type' => 'USER', 'code' => 'user1' },
          'isAdmin' => false,
          'isImplicit' => true
        }
      ]
    end

    def request_data
      {
        'id' => 1,
        'members' => [
          {
            'entity' => { 'type' => 'USER', 'code' => 'user1' },
            'isAdmin' => false,
            'isImplicit' => true
          }
        ]
      }
    end

    it { expect(subject).to be_truthy }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kintone-0.1.4 spec/kintone/command/space_members_spec.rb
kintone-0.1.3 spec/kintone/command/space_members_spec.rb