From 3a6229c8511a1a4e351608a4f228aa92b0b956ba Mon Sep 17 00:00:00 2001 From: Steven Stinson Date: Fri, 5 May 2017 14:49:29 +0100 Subject: [PATCH 1/3] Update README --- readme.md | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/readme.md b/readme.md index df803bf..9355516 100644 --- a/readme.md +++ b/readme.md @@ -8,6 +8,8 @@ This is in early stages of development but supports the primary requirements aro ### Setting up +Requires Rails 5 + From the command line gem install esendex @@ -51,16 +53,6 @@ Multiple messages are sent by passing an array of `Messages` to the `send_messag result = account.send_messages([Message.new("07777111222", "Hello"), Message.new("07777111333", "Hi")]) ``` -Sent messages can be retrieved by calling the `sent_messages` method. The return value is a *SentMessagesResult* - -```ruby -result = account.sent_messages -puts result -result.messages.each do |message| - puts message -end -``` - ### Testing Configuration The Esendex Gem ships with a couple of rake tasks that allow you to simply validate that all is well. @@ -96,9 +88,9 @@ Classes are provided in the gem for deserialising the notifications: `MessageDel message = InboundMessage.from_xml request.body ``` -### Rails 3 / Rails 4 +### Rails -In order to simplify receipt of push notifications for Rails 3 users, the gem ships with mountable Rails controllers to handle the receipt of these notifications. +In order to simplify receipt of push notifications for Rails users, the gem ships with mountable Rails controllers to handle the receipt of these notifications. To mount the end points, add this to `routes.rb` From c44392038ca9c072384f6cb8d6b6b5c7d0bb8fe9 Mon Sep 17 00:00:00 2001 From: James Turner and Steven Stinson Date: Fri, 5 May 2017 14:58:38 +0100 Subject: [PATCH 2/3] Remove property on account that should not exist anymore --- lib/esendex/account.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/esendex/account.rb b/lib/esendex/account.rb index 17a612d..7c5460e 100644 --- a/lib/esendex/account.rb +++ b/lib/esendex/account.rb @@ -34,11 +34,5 @@ def send_messages(messages) response = api_connection.post("/v1.0/messagedispatcher", batch_submission.to_s) DispatcherResult.from_xml response.body end - - def sent_messages(args={}) - SentMessageClient - .new(api_connection) - .get_messages(args.merge(account_reference: reference)) - end end end From a15555f92fc30e1e5e179787899408825d2eea7d Mon Sep 17 00:00:00 2001 From: James Turner and Steven Stinson Date: Fri, 5 May 2017 15:17:58 +0100 Subject: [PATCH 3/3] Remove redundant tests --- spec/account_spec.rb | 79 -------------------------------------------- 1 file changed, 79 deletions(-) diff --git a/spec/account_spec.rb b/spec/account_spec.rb index 5db985b..103efdb 100644 --- a/spec/account_spec.rb +++ b/spec/account_spec.rb @@ -129,83 +129,4 @@ subject.messages.should include(id: "#{message_two_id}", uri: "#{uri_prefix}#{message_two_id}") end end - - describe "#sent_messages" do - let(:sent_message_client) { stub("sent_message_client") } - let(:sent_messages_result) { Class.new } - - before(:each) do - stub_const("Esendex::SentMessageClient", sent_message_client) - sent_message_client - .should_receive(:new) - .with(api_connection) - .and_return(sent_message_client) - end - - context "with no args" do - before(:each) do - sent_message_client - .should_receive(:get_messages) - .with({account_reference: account_reference}) - .and_return(sent_messages_result) - end - - subject { account.sent_messages() } - - it "should return expected result" do - subject.should eq(sent_messages_result) - end - end - - context "with start and finish dates" do - it "should pass dates without adjustment" do - start_date = DateTime.now - 30 - finish_date = DateTime.now - 15 - sent_message_client - .should_receive(:get_messages) - .with({account_reference: account_reference, start: start_date, finish: finish_date}) - .and_return(sent_messages_result) - - account.sent_messages({start: start_date, finish: finish_date}).should_not be_nil - end - end - - context "with start date" do - it "should specify start date and default finish date" do - start_date = DateTime.now - 1 - sent_message_client - .should_receive(:get_messages) - .with({account_reference: account_reference, start: start_date}) - .and_return(sent_messages_result) - - account.sent_messages({start: start_date}).should_not be_nil - end - end - - context "with finish date" do - it "should specify default start date and finish date" do - finish_date = DateTime.now - 1 - start_date = finish_date - 90 - sent_message_client - .should_receive(:get_messages) - .with({account_reference: account_reference, finish: finish_date}) - .and_return(sent_messages_result) - - account.sent_messages({finish: finish_date}).should_not be_nil - end - end - - context "with start index and count" do - it "should pass expected arguments" do - start_index = 3 - count = 35 - sent_message_client - .should_receive(:get_messages) - .with({account_reference: account_reference, start_index: start_index, count: count}) - .and_return(sent_messages_result) - - account.sent_messages({start_index: start_index, count: count}).should_not be_nil - end - end - end end