Sha256: e9346b2acc01890c2c01a97adfbf8b2b8f9f9409a56fd426adda3ea6c733477d

Contents?: true

Size: 1.3 KB

Versions: 5

Compression:

Stored size: 1.3 KB

Contents

require 'spec_helper'
require 'kintone/command/app_acl'
require 'kintone/api'

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

  describe '#update' do
    before(:each) do
      stub_request(
        :put,
        'https://example.cybozu.com/k/v1/app/acl.json'
      )
        .with(body: { 'app' => 1, 'rights' => { 'p1' => 'abc', 'p2' => 'def' } }.to_json)
        .to_return(body: '{}', status: 200, headers: { 'Content-type' => 'application/json' })
    end

    subject { target.update(app, rights) }

    let(:app) { 1 }
    let(:rights) { { 'p1' => 'abc', 'p2' => 'def' } }

    it { expect(subject).to eq({}) }

    context 'fail to request' do
      before(:each) do
        stub_request(
          :put,
          'https://example.cybozu.com/k/v1/app/acl.json'
        )
          .with(body: { 'app' => 1, 'rights' => { 'p1' => 'abc', 'p2' => 'def' } }.to_json)
          .to_return(
            body: '{"message":"不正なJSON文字列です。","id":"1505999166-897850006","code":"CB_IJ01"}',
            status: 500,
            headers: { 'Content-Type' => 'application/json' }
          )
      end

      it { expect { subject }.to raise_error Kintone::KintoneError }
    end
  end
end

Version data entries

5 entries across 5 versions & 3 rubygems

Version Path
kintone_rb-1.0.1 spec/kintone/command/app_acl_spec.rb
kintone_rb-1.0.0 spec/kintone/command/app_acl_spec.rb
kintone-oauth-extension-0.2.2 spec/kintone/command/app_acl_spec.rb
kintone-oauth-extension-0.2.1 spec/kintone/command/app_acl_spec.rb
kintone-0.1.5 spec/kintone/command/app_acl_spec.rb