spree_sendwithus 2.0.11.4 → 2.0.11.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8820ac7bacb0ca596e78cc5e67d174dd289b01e1
4
- data.tar.gz: a2ca9405378fc60809bb93ac2ab8c89d0fe1cefd
3
+ metadata.gz: 7a20a3cf803b52f569cff86381e54e87a8d306ec
4
+ data.tar.gz: 11ff87ffa63f595e01d11ecefb48739ddd95bf19
5
5
  SHA512:
6
- metadata.gz: 6c64fe137fd21126ed5785b04bfe5c8eb5a83fc807d4906273947e23c72e0e6b80dca99d20e1494bd7a0070478c44d6abbbe651bddfd9940859f09335a4de8e3
7
- data.tar.gz: a5633b85e51c33c4ed057a050fa971be6f011e10224c8156a6e8b215fa80a50b15a9c6bc82f6d31797168b5215dfa23798c2e454b8bf2470f87c9552c5566e96
6
+ metadata.gz: 7d90340f4578c14d4104c89375d4b881a47f120179014419c8e4043a4f464e0be8abb4065b6272a128de8497b27ef95d01ed61f206092569af9238a04373030a
7
+ data.tar.gz: 21ada587ffbee89263fd87356955451b28eb6c6afd1ae89b451470bb7ec7f76188caf611eb2374a1c76764d7341e16a7951d3e69989aaf7cd3fbe0e728f746ad
data/README.md CHANGED
@@ -7,19 +7,20 @@ Installation
7
7
  ------------
8
8
 
9
9
  Add spree_sendwithus to your Gemfile:
10
-
11
10
  ```ruby
11
+ # Rubygems
12
+ gem 'spree_sendwithus'
13
+
14
+ # Direct from Github
12
15
  gem 'spree_sendwithus', github: 'freerunningtech/spree_sendwithus'
13
16
  ```
14
17
 
15
18
  Bundle your dependencies and run the installation generator:
16
-
17
19
  ```shell
18
20
  bundle install
19
21
  ```
20
22
 
21
23
  Add `send_with_us.rb` in `config/initializers` with the following:
22
-
23
24
  ```ruby
24
25
  SendWithUs::Api.configure do |config|
25
26
  config.api_key = ENV["SEND_WITH_US_API_KEY"]
@@ -28,7 +29,6 @@ end
28
29
  ```
29
30
 
30
31
  Now you can configure any of your mailers to use SendWithUs by making them a subclass of `Spree::SendWithUsMailer::Base`. For example:
31
-
32
32
  ```ruby
33
33
  # app/mailers/spree/quality_control_mailer.rb
34
34
 
@@ -42,7 +42,10 @@ class Spree::QualityControlMailer < Spree::SendWithUsMailer::Base
42
42
  assign(:original, order_data(Spree::Order.find(original)))
43
43
  assign(:reprint, order_data(Spree::Order.find(reprint)))
44
44
 
45
- mail(email_id: "SEND_WITH_US_TEMPLATE_ID")
45
+ mail(
46
+ email_id: 'SEND_WITH_US_TEMPLATE_ID',
47
+ esp_account: 'SEND_WITH_US_ESP_API_ID' # Optional
48
+ )
46
49
  end
47
50
 
48
51
  private
@@ -56,7 +59,6 @@ end
56
59
  ```
57
60
 
58
61
  The mailer will work with delayed job or without:
59
-
60
62
  ```ruby
61
63
  # Delayed
62
64
  Spree::QualityControlMailer.delay.reprint(1, 2)
@@ -67,9 +69,15 @@ Spree::QualityControlMailer.reprint(1, 2).deliver
67
69
 
68
70
  Also, the default URL host will be pulled from `config.action_mailer.default_url_options` so there's no need for any extra configuration! You're welcome!
69
71
 
72
+ RSpec
73
+ -----
74
+ Have spree_sendwithus mailers? Want to do some testing with RSpec? Don't want to hit the API?! Then look no further! Just add the following to your `spec_helper.rb` and bask in the glory that is mocking!
75
+ ```ruby
76
+ require 'spree_sendwithus/rspec_support'
77
+ ```
78
+
70
79
  Testing
71
80
  -------
72
-
73
81
  Be sure to bundle your dependencies and then create a dummy test app for the specs to run against.
74
82
 
75
83
  ```shell
@@ -3,7 +3,8 @@ require 'send_with_us'
3
3
  module Spree
4
4
  module SendWithUs
5
5
  class Message
6
- attr_reader :to, :from, :email_id, :email_data, :cc, :bcc, :files
6
+ attr_reader :to, :from, :email_id, :email_data, :cc, :bcc, :files,
7
+ :esp_account
7
8
 
8
9
  def initialize
9
10
  @email_data = {}
@@ -12,6 +13,7 @@ module Spree
12
13
  @cc = []
13
14
  @bcc = []
14
15
  @files = []
16
+ @esp_account = ""
15
17
  end
16
18
 
17
19
  def assign(key, value)
@@ -39,12 +41,23 @@ module Spree
39
41
  @bcc.concat(value)
40
42
  when :files
41
43
  @files.concat(value)
44
+ when :esp_account
45
+ @esp_account = value
42
46
  end
43
47
  end
44
48
  end
45
49
 
46
50
  def deliver
47
- ::SendWithUs::Api.new.send_with(@email_id, @to, @email_data, @from, @cc, @bcc, @files)
51
+ ::SendWithUs::Api.new.send_with(
52
+ @email_id,
53
+ @to,
54
+ @email_data,
55
+ @from,
56
+ @cc,
57
+ @bcc,
58
+ @files,
59
+ @esp_acount
60
+ )
48
61
  end
49
62
  end
50
63
  end
@@ -0,0 +1,5 @@
1
+ RSpec.configure do |config|
2
+ config.before(:each) do
3
+ allow(SendWithUs::Api).to receive(:new).and_return(double(send_with: true))
4
+ end
5
+ end
@@ -46,7 +46,8 @@ describe Spree::SendWithUs::Message do
46
46
  reply_to: "gregor@example.com",
47
47
  cc: ["sean@example.com"],
48
48
  bcc: ["clarke@example.com", "kyria@example.com"],
49
- files: ["path/to/file.txt", "../another_file.txt"]
49
+ files: ["path/to/file.txt", "../another_file.txt"],
50
+ esp_account: "esp_1234"
50
51
  ] }
51
52
 
52
53
  before do
@@ -86,6 +87,9 @@ describe Spree::SendWithUs::Message do
86
87
  "../another_file.txt"
87
88
  ]
88
89
  end
90
+ it "contains the expected esp account" do
91
+ expect(subject.esp_account).to eq "esp_1234"
92
+ end
89
93
  end
90
94
 
91
95
  describe "#deliver" do
@@ -2,7 +2,7 @@
2
2
  Gem::Specification.new do |s|
3
3
  s.platform = Gem::Platform::RUBY
4
4
  s.name = 'spree_sendwithus'
5
- s.version = '2.0.11.4'
5
+ s.version = '2.0.11.5'
6
6
  s.summary = 'SendWithUs integration'
7
7
  s.license = 'BSD-3'
8
8
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_sendwithus
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.11.4
4
+ version: 2.0.11.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - FreeRunning Technologies
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-16 00:00:00.000000000 Z
11
+ date: 2014-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: spree_core
@@ -96,6 +96,7 @@ files:
96
96
  - lib/spree_sendwithus/engine.rb
97
97
  - lib/spree_sendwithus/mailer.rb
98
98
  - lib/spree_sendwithus/message.rb
99
+ - lib/spree_sendwithus/rspec_support.rb
99
100
  - script/rails
100
101
  - spec/lib/spree_sendwithus/mailer_spec.rb
101
102
  - spec/lib/spree_sendwithus/message_spec.rb