Sha256: 6eedf9ed585330ae686b4a9c59ca9581fe6144fc2f8e55f7bd075a9c72d675cd

Contents?: true

Size: 1.34 KB

Versions: 5

Compression:

Stored size: 1.34 KB

Contents

require 'spec_helper'
require 'kintone/command/field_acl'
require 'kintone/api'

describe Kintone::Command::FieldAcl do
  let(:target) { Kintone::Command::FieldAcl.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/field/acl.json'
      )
        .with(body: { 'id' => 1, 'rights' => { 'p1' => 'abc', 'p2' => 'def' } }.to_json)
        .to_return(
          body: '{}',
          status: 200,
          headers: { 'Content-type' => 'application/json' }
        )
    end

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

    subject { target.update(id, rights) }

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

    context 'fail to request' do
      before(:each) do
        stub_request(
          :put,
          'https://example.cybozu.com/k/v1/field/acl.json'
        )
          .with(body: { 'id' => 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/field_acl_spec.rb
kintone_rb-1.0.0 spec/kintone/command/field_acl_spec.rb
kintone-oauth-extension-0.2.2 spec/kintone/command/field_acl_spec.rb
kintone-oauth-extension-0.2.1 spec/kintone/command/field_acl_spec.rb
kintone-0.1.5 spec/kintone/command/field_acl_spec.rb