Sha256: d429ba75c7a50ad5eac1deb2f03e001a5ee2b96d996fa9e57be098a3ed58e818

Contents?: true

Size: 1.3 KB

Versions: 4

Compression:

Stored size: 1.3 KB

Contents

require 'spec_helper'

describe GroupDocs::Api::Helpers::AccessRights do
  subject do
    GroupDocs::User.new
  end

  describe '#convert_access_rights_to_byte' do
    let(:rights) { %w(view annotate download export all) }

    it 'raises error if rights is not an array' do
      lambda { subject.send(:convert_access_rights_to_byte, :view) }.should raise_error(ArgumentError)
    end

    it 'raises error if right is unknown' do
      lambda { subject.send(:convert_access_rights_to_byte, %w(unknown)) }.should raise_error(ArgumentError)
    end

    it 'converts each right to Symbol' do
      rights.each do |right|
        symbol = right.to_sym
        right.should_receive(:to_sym).and_return(symbol)
      end
      subject.send(:convert_access_rights_to_byte, rights)
    end

    it 'returns correct byte flag' do
      subject.send(:convert_access_rights_to_byte, rights).should == 46
    end
  end

  describe '#convert_byte_to_access_rights' do
    let(:rights) { %w(view annotate download export) }

    it 'raises error if rights is not an integer' do
      lambda { subject.send(:convert_byte_to_access_rights, :export) }.should raise_error(ArgumentError)
    end

    it 'returns correct rights array flag' do
      subject.send(:convert_byte_to_access_rights, 15).should =~ rights.map(&:to_sym)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
groupdocs-1.9.0 spec/groupdocs/api/helpers/access_rights_helper_spec.rb
groupdocs-1.8.1 spec/groupdocs/api/helpers/access_rights_helper_spec.rb
groupdocs-1.8.0 spec/groupdocs/api/helpers/access_rights_helper_spec.rb
groupdocs-1.7.0 spec/groupdocs/api/helpers/access_rights_helper_spec.rb