user_notifier 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,12 +34,12 @@ describe UserNotifier::Base do
34
34
  end
35
35
 
36
36
  it "should not create notification for same association and different template name" do
37
- UserNotification.notify_once('another_test', user)
37
+ UserNotification.notify_once('another_test', user)
38
38
  expect(UserNotification.count(:all)).to eq 2
39
39
  end
40
40
 
41
41
  it "should not create duplicate notification for same association and template name" do
42
- UserNotification.notify_once('test', user)
42
+ UserNotification.notify_once('test', user)
43
43
  expect(UserNotification.count(:all)).to eq 1
44
44
  end
45
45
  end
@@ -47,12 +47,27 @@ describe UserNotifier::Base do
47
47
  describe ".notify" do
48
48
  subject{ notification }
49
49
 
50
- it "should create notification in the database" do
51
- subject
52
- expect(UserNotification.last).to be_present
50
+ context "direct notification" do
51
+ it "should create notification in the database" do
52
+ subject
53
+ expect(UserNotification.last).to be_present
54
+ end
55
+
56
+ its(:template_name){ should eq 'test' }
57
+ its(:deliver_at){ should be_kind_of(Time) }
53
58
  end
54
59
 
55
- its(:template_name){ should eq 'test' }
60
+ context "with scheduled notification" do
61
+ let(:deliver_at) { 3.days.from_now }
62
+ let(:notification) { UserNotification.notify('deliver_at_test', user, nil, {deliver_at: deliver_at}) }
63
+ it "should create notification in the database" do
64
+ subject
65
+ expect(UserNotification.last).to be_present
66
+ end
67
+
68
+ its(:template_name){ should eq 'deliver_at_test' }
69
+ its(:deliver_at){ should eq deliver_at }
70
+ end
56
71
  end
57
72
 
58
73
  describe "#deliver" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: user_notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Diogo Biazus
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-14 00:00:00.000000000 Z
11
+ date: 2015-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -160,6 +160,7 @@ files:
160
160
  - spec/dummy/db/migrate/20140625183616_create_user_notifications.rb
161
161
  - spec/dummy/db/migrate/20140709164530_create_orders.rb
162
162
  - spec/dummy/db/migrate/20140709170259_create_order_notifications.rb
163
+ - spec/dummy/db/migrate/20150713180329_add_deliver_at_to_notifications.rb
163
164
  - spec/dummy/db/schema.rb
164
165
  - spec/dummy/db/test.sqlite3
165
166
  - spec/dummy/log/development.log
@@ -235,6 +236,7 @@ test_files:
235
236
  - spec/dummy/db/migrate/20140625183616_create_user_notifications.rb
236
237
  - spec/dummy/db/migrate/20140709164530_create_orders.rb
237
238
  - spec/dummy/db/migrate/20140709170259_create_order_notifications.rb
239
+ - spec/dummy/db/migrate/20150713180329_add_deliver_at_to_notifications.rb
238
240
  - spec/dummy/db/schema.rb
239
241
  - spec/dummy/db/test.sqlite3
240
242
  - spec/dummy/log/development.log