Sha256: 003c56f45117fcc7f6108d28531b0d4a9d9bf143d5603aa01d798cc21aa2866a

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'

RSpec.describe Salesforce::Rails::API::CalendarEvent do
  class TestClass < Salesforce::Rails::API::CalendarEvent
  end

  before do
    config = YAML.load(ERB.new(File.new(File.join(::Rails.root, 'config', 'salesforce.yml')).read).result)
    config = config.has_key?(::Rails.env) ? config[::Rails.env] : config
    token = config["token"]
    instance_url = config["instance_url"]
    @client = Databasedotcom::Client.new(config)
    @client.authenticate(:token => token, :instance_url => instance_url)
    TestClass.client = @client
  end

  context ".all" do
    it "returns all records of events as instances" do
      expect(@client).to receive(:query).with("SELECT Id, Subject, IsAllDayEvent, StartDateTime, EndDateTime, Description, Owner.Name, ShowAs FROM Event").and_return("foo")
      expect(TestClass.all).to eq("foo")
    end
  end

  context ".query" do
    it "constructs and submits a SOQL query" do
      expect(@client).to receive(:query).with("SELECT Id, Subject, IsAllDayEvent, StartDateTime, EndDateTime, Description, Owner.Name, ShowAs FROM Event WHERE Subject = 'foo'").and_return("bar")
      expect(TestClass.query("Subject = 'foo'")).to eq("bar")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
salesforce-rails-1.0.1 spec/lib/salesforce/rails/api/calendar_event_spec.rb