spec/concerns/crud_activities_spec.rb in mrkt-1.2.0 vs spec/concerns/crud_activities_spec.rb in mrkt-1.2.1
- old
+ new
@@ -1,9 +1,11 @@
describe Mrkt::CrudActivities do
- include_context 'initialized client'
+ include_context 'with an initialized client'
describe '#get_activity_types' do
+ subject { client.get_activity_types }
+
let(:response_stub) do
{
requestId: 'c245#14cd6830ae2',
result: [
{
@@ -27,30 +29,30 @@
}
],
success: true
}
end
- subject { client.get_activity_types }
before do
stub_request(:get, "https://#{host}/rest/v1/activities/types.json")
.to_return(json_stub(response_stub))
end
it { is_expected.to eq(response_stub) }
end
describe '#get_paging_token' do
+ subject { client.get_paging_token(since_datetime) }
+
let(:since_datetime) { Time.utc(2017, 1, 1, 4, 30) }
let(:response_stub) do
{
requestId: '12eb3#1599b371c62',
success: true,
nextPageToken: '4GAX7YNCIJKO2VAED5LH5PQIYPUM7WCVKTQWEDMP2L24AXZT54LA===='
}
end
- subject { client.get_paging_token(since_datetime) }
before do
stub_request(:get, "https://#{host}/rest/v1/activities/pagingtoken.json")
.with(query: { sinceDatetime: '2017-01-01T04:30:00Z' })
.to_return(json_stub(response_stub))
@@ -58,10 +60,12 @@
it { is_expected.to eq(response_stub) }
end
describe '#get_activities' do
+ subject { client.get_activities(token) }
+
let(:activity_type_ids) { [1, 2] }
let(:lead_ids) { [100, 102] }
let(:token) { '4GAX7YNCIJKO2VAED5LH5PQIYPUM7WCVKTQWEDMP2L24AXZT54LA====' }
let(:response_stub) do
{
@@ -104,21 +108,22 @@
success: true,
nextPageToken: 'WQV2VQVPPCKHC6AQYVK7JDSA3I5PBAJNUNY3CR563KMVM7F43OIQ====',
moreResult: false
}
end
- subject { client.get_activities(token) }
before do
stub_request(:get, "https://#{host}/rest/v1/activities.json")
.with(query: { nextPageToken: token })
.to_return(json_stub(response_stub))
end
it { is_expected.to eq(response_stub) }
- context 'specifying activity type ids' do
+ context 'when specifying activity type ids' do
+ subject { client.get_activities(token, activity_type_ids: activity_type_ids) }
+
let(:response_stub) do
{
data: {
requestId: '417b#1599b3bca62',
result: [
@@ -145,11 +150,10 @@
success: true,
nextPageToken: 'WQV2VQVPPCKHC6AQYVK7JDSA3I5PBAJNUNY3CR563KMVM7F43OIQ====',
moreResult: false
}
end
- subject { client.get_activities(token, activity_type_ids: activity_type_ids) }
before do
stub_request(:get, "https://#{host}/rest/v1/activities.json")
.with(query: {
nextPageToken: token,
@@ -159,11 +163,13 @@
end
it { is_expected.to eq(response_stub) }
end
- context 'specifying lead ids' do
+ context 'when specifying lead ids' do
+ subject { client.get_activities(token, lead_ids: lead_ids) }
+
let(:response_stub) do
{
data: {
requestId: '417b#1599b3bca62',
result: [
@@ -190,38 +196,38 @@
success: true,
nextPageToken: 'WQV2VQVPPCKHC6AQYVK7JDSA3I5PBAJNUNY3CR563KMVM7F43OIQ====',
moreResult: false
}
end
- subject { client.get_activities(token, lead_ids: lead_ids) }
before do
stub_request(:get, "https://#{host}/rest/v1/activities.json")
.with(query: { nextPageToken: token, leadIds: lead_ids.join(',') })
.to_return(json_stub(response_stub))
end
it { is_expected.to eq(response_stub) }
end
- context 'specifying arrays values as empty strings' do
- let(:activity_type_ids) { '' }
- let(:lead_ids) { '' }
+ context 'when specifying arrays values as empty strings' do
subject do
client.get_activities(token, activity_type_ids: activity_type_ids, lead_ids: lead_ids)
end
+ let(:activity_type_ids) { '' }
+ let(:lead_ids) { '' }
+
before do
stub_request(:get, "https://#{host}/rest/v1/activities.json")
.with(query: { nextPageToken: token })
.to_return(json_stub(response_stub))
end
it { is_expected.to eq(response_stub) }
end
- context 'specifying all options' do
+ context 'when specifying all options' do
subject do
client.get_activities(token, activity_type_ids: activity_type_ids, lead_ids: lead_ids)
end
before do
@@ -237,10 +243,12 @@
it { is_expected.to eq(response_stub) }
end
end
describe '#get_deleted_leads' do
+ subject { client.get_deleted_leads(token) }
+
let(:token) { '4GAX7YNCIJKO2VAED5LH5PQIYPUM7WCVKTQWEDMP2L24AXZT54LA====' }
let(:response_stub) do
{
requestId: '8105#1650074c30c',
result: [
@@ -264,10 +272,9 @@
success: true,
nextPageToken: 'XQH6SLHODNIM7CY6MKJ6GAOR3JYOQXIN3THAHKYZXSOYN4HOPR2Q====',
moreResult: false
}
end
- subject { client.get_deleted_leads(token) }
before do
stub_request(:get, "https://#{host}/rest/v1/activities/deletedleads.json")
.with(query: { nextPageToken: token })
.to_return(json_stub(response_stub))