Sha256: 4056b299c144bc8648698fd05ef5efb59305428cd33c3b0e17aadec817618df2

Contents?: true

Size: 1.57 KB

Versions: 6

Compression:

Stored size: 1.57 KB

Contents

require 'spec_helper'

class Announcement < StorageRoom::Entry
  key :text
  
  one :location
  one :shop
end

class Shop < StorageRoom::Entry
  key :name
end

describe StorageRoom::WebhookCall do
  before(:each) do
    @webhook_call = StorageRoom::WebhookCall.new
  end
  
  describe "#new_from_json_string" do
    it "should create object" do
      file = fixture_file('webhook_call.json')
      webhook_call = StorageRoom::Resource.new_from_json_string(file)
      
      webhook_call.should be_an_instance_of(StorageRoom::WebhookCall)        
      webhook_call[:@url].should_not be_present
      webhook_call[:@event].should == 'update'
      webhook_call.entry.should be_an_instance_of(Announcement)
      webhook_call.entry.text.should == 'WEBHOOK TEST'
      
      webhook_call.entry.location.should be_an_instance_of(StorageRoom::Location)
      webhook_call.entry.location.lat.should == 1.2
      webhook_call.entry.location.lng.should == 2.3

      stub_request(:get, "http://APPLICATION_API_KEY:X@api.storageroomapp.com/accounts/4e1e9c234250712eba000052/collections/4e1e9c234250712eba000063/entries/4e1f3259425071435e000099").
        to_return(:status => 200, :body => fixture_file('webhook_call_association.json'))
      
      shop = webhook_call.entry.shop
      shop.loaded?.should be_false
      shop.should be_an_instance_of(Shop)
      shop.loaded?.should be_true      
      shop['@url'].should == 'http://api.storageroomapp.com/accounts/4e1e9c234250712eba000052/collections/4e1e9c234250712eba000063/entries/4e1f3259425071435e000099'
      shop.name.should == 'SHOP'
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
storage_room-0.3.24 spec/storage_room/webhook_call_spec.rb
storage_room-0.3.23 spec/storage_room/webhook_call_spec.rb
storage_room-0.3.22 spec/storage_room/webhook_call_spec.rb
storage_room-0.3.21 spec/storage_room/webhook_call_spec.rb
storage_room-0.3.20 spec/storage_room/webhook_call_spec.rb
storage_room-0.3.19 spec/storage_room/webhook_call_spec.rb