Sha256: 06569431735874bcf478a18d00011c0369a1168e6bd4b7e479ad229cf13c15e2

Contents?: true

Size: 1.48 KB

Versions: 18

Compression:

Stored size: 1.48 KB

Contents

# encoding: utf-8
require 'spec_helper'


describe "API Access" do

  it "Create" do
    data = {
      :id => 1,
      :name => 'Name',
      :permissions => {:permission => [:read]},
    }
    api_access = Osm::ApiAccess.new(data)

    api_access.id.should == 1
    api_access.name.should == 'Name'
    api_access.permissions.should == {:permission => [:read]}
    api_access.valid?.should be_true
  end


  describe "Using the API" do

    before :each do
      body = {
        'apis' => [
          {
            'apiid' => '1',
            'name' => 'API Name',
            'permissions' => { 'read' => '10', 'readwrite' => '20' }
          }, {
            'apiid' => '2',
            'name' => 'API 2 Name',
            'permissions' => { 'read' => '10', 'readwrite' => '20' }
          }
        ]
      }
      FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/users.php?action=getAPIAccess&sectionid=1", :body => body.to_json)
    end

    it "Get All" do
      api_accesses = Osm::ApiAccess.get_all(@api, 1)

      api_accesses.size.should == 2
      api_access = api_accesses[0]
      api_access.id.should == 1
      api_access.name.should == 'API Name'
      api_access.permissions.should == {:read => [:read], :readwrite => [:read, :write]}
    end

    it "Get One" do
      api_access = Osm::ApiAccess.get(@api, 1, 2)
      api_access.id.should == 2
    end

    it "Get Ours" do
      api_access = Osm::ApiAccess.get_ours(@api, 1)
      api_access.id.should == 1
    end

  end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
osm-0.1.17 spec/osm/api_access_spec.rb
osm-0.1.16 spec/osm/api_access_spec.rb
osm-0.1.15 spec/osm/api_access_spec.rb
osm-0.1.14 spec/osm/api_access_spec.rb
osm-0.1.13 spec/osm/api_access_spec.rb
osm-0.1.12 spec/osm/api_access_spec.rb
osm-0.1.11 spec/osm/api_access_spec.rb
osm-0.1.10 spec/osm/api_access_spec.rb
osm-0.1.9 spec/osm/api_access_spec.rb
osm-0.1.8 spec/osm/api_access_spec.rb
osm-0.1.7 spec/osm/api_access_spec.rb
osm-0.1.6 spec/osm/api_access_spec.rb
osm-0.1.5 spec/osm/api_access_spec.rb
osm-0.1.4 spec/osm/api_access_spec.rb
osm-0.1.3 spec/osm/api_access_spec.rb
osm-0.1.2 spec/osm/api_access_spec.rb
osm-0.1.1 spec/osm/api_access_spec.rb
osm-0.1.0 spec/osm/api_access_spec.rb