user_notifier 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/user_notifier/notification/templates/migration.rb +1 -0
- data/lib/user_notifier/models/base.rb +1 -1
- data/lib/user_notifier/version.rb +1 -1
- data/spec/dummy/config/database.yml +36 -16
- data/spec/dummy/db/migrate/20150713180329_add_deliver_at_to_notifications.rb +14 -0
- data/spec/dummy/db/schema.rb +12 -7
- data/spec/dummy/log/development.log +149 -0
- data/spec/dummy/log/test.log +860 -0
- data/spec/models/user_notifier/base_spec.rb +21 -6
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cb454c6c1c482a948d1f588878a24833712fd1a
|
4
|
+
data.tar.gz: 0cad09d1c573dd3d186c2d98250c9dcbf6fc8088
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b60d65e3695cb8a5372a3321c7558d853e180c303e65a1225edfe0b03c17b55b3e9193e6ca70362a94d04bdac11669bdb7cd0399f7fb1cb5fc8f1213774935a
|
7
|
+
data.tar.gz: 5af36e65df4dac3b6b12b0e5e560ecd9dcd7e105f8bcb87d01cadec812df38e37e673902fab480e8a0c125564eaf14eaac8920d8694164129f0b966767dd5dec
|
@@ -23,7 +23,7 @@ class UserNotifier::Base < ActiveRecord::Base
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def deliver!
|
26
|
-
UserNotifier::EmailWorker.
|
26
|
+
UserNotifier::EmailWorker.perform_at((self.try(:deliver_at) || Time.now), self.class.name.to_s, self.id)
|
27
27
|
end
|
28
28
|
|
29
29
|
def deliver_without_worker
|
@@ -1,25 +1,45 @@
|
|
1
|
-
#
|
2
|
-
# gem install sqlite3
|
1
|
+
# PostgreSQL. Versions 9.1 or later are supported.
|
3
2
|
#
|
4
|
-
#
|
5
|
-
# gem
|
3
|
+
# Install the pg driver:
|
4
|
+
# gem install pg
|
5
|
+
# On Mac OS X with macports:
|
6
|
+
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
|
7
|
+
# On Windows:
|
8
|
+
# gem install pg
|
9
|
+
# Choose the win32 build.
|
10
|
+
# Install PostgreSQL and put its /bin directory on your path.
|
6
11
|
development:
|
7
|
-
adapter:
|
8
|
-
|
12
|
+
adapter: postgresql
|
13
|
+
encoding: unicode
|
14
|
+
host: localhost
|
15
|
+
database: user_notifier_development
|
9
16
|
pool: 5
|
10
|
-
|
17
|
+
username: postgres
|
18
|
+
|
19
|
+
|
20
|
+
# Connect on a TCP socket. Omitted by default since the client uses a
|
21
|
+
# domain socket that doesn't need configuration. Windows does not have
|
22
|
+
# domain sockets, so uncomment these lines.
|
23
|
+
#host: localhost
|
24
|
+
#port: 5432
|
25
|
+
|
26
|
+
# Schema search path. The server defaults to $user,public
|
27
|
+
#schema_search_path: myapp,sharedapp,public
|
28
|
+
|
29
|
+
# Minimum log levels, in increasing order:
|
30
|
+
# debug5, debug4, debug3, debug2, debug1,
|
31
|
+
# log, notice, warning, error, fatal, and panic
|
32
|
+
# The server defaults to notice.
|
33
|
+
#min_messages: warning
|
11
34
|
|
12
35
|
# Warning: The database defined as "test" will be erased and
|
13
36
|
# re-generated from your development database when you run "rake".
|
14
37
|
# Do not set this db to the same as development or production.
|
15
|
-
test:
|
16
|
-
adapter: sqlite3
|
17
|
-
database: db/test.sqlite3
|
18
|
-
pool: 5
|
19
|
-
timeout: 5000
|
20
38
|
|
21
|
-
|
22
|
-
adapter:
|
23
|
-
|
39
|
+
test:
|
40
|
+
adapter: postgresql
|
41
|
+
encoding: unicode
|
42
|
+
host: localhost
|
43
|
+
database: user_notifier_test
|
24
44
|
pool: 5
|
25
|
-
|
45
|
+
username: postgres
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class AddDeliverAtToNotifications < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
add_column :order_notifications, :deliver_at, :timestamp
|
4
|
+
add_column :user_notifications, :deliver_at, :timestamp
|
5
|
+
|
6
|
+
execute "ALTER TABLE order_notifications ALTER deliver_at SET DEFAULT current_timestamp"
|
7
|
+
execute "ALTER TABLE user_notifications ALTER deliver_at SET DEFAULT current_timestamp"
|
8
|
+
end
|
9
|
+
|
10
|
+
def down
|
11
|
+
remove_column :order_notifications, :deliver_at, :timestamp
|
12
|
+
remove_column :user_notifications, :deliver_at, :timestamp
|
13
|
+
end
|
14
|
+
end
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -11,16 +11,20 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended that you check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
14
|
+
ActiveRecord::Schema.define(version: 20150713180329) do
|
15
|
+
|
16
|
+
# These are extensions that must be enabled in order to support this database
|
17
|
+
enable_extension "plpgsql"
|
15
18
|
|
16
19
|
create_table "order_notifications", force: :cascade do |t|
|
17
|
-
t.integer "user_id",
|
18
|
-
t.integer "order_id",
|
19
|
-
t.text "from_email",
|
20
|
-
t.text "from_name",
|
21
|
-
t.text "template_name",
|
22
|
-
t.text "locale",
|
20
|
+
t.integer "user_id", null: false
|
21
|
+
t.integer "order_id", null: false
|
22
|
+
t.text "from_email", null: false
|
23
|
+
t.text "from_name", null: false
|
24
|
+
t.text "template_name", null: false
|
25
|
+
t.text "locale", null: false
|
23
26
|
t.datetime "sent_at"
|
27
|
+
t.datetime "deliver_at", default: "now()"
|
24
28
|
end
|
25
29
|
|
26
30
|
create_table "orders", force: :cascade do |t|
|
@@ -37,6 +41,7 @@ ActiveRecord::Schema.define(version: 20140709170259) do
|
|
37
41
|
t.text "template_name"
|
38
42
|
t.text "locale"
|
39
43
|
t.datetime "sent_at"
|
44
|
+
t.datetime "deliver_at", default: "now()"
|
40
45
|
end
|
41
46
|
|
42
47
|
create_table "users", force: :cascade do |t|
|
@@ -37,3 +37,152 @@ Migrating to CreateOrderNotifications (20140709170259)
|
|
37
37
|
[1m[35m (0.6ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20140625163719')
|
38
38
|
[1m[36m (0.7ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20140625183616')[0m
|
39
39
|
[1m[35m (0.7ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20140709164530')
|
40
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
41
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
42
|
+
[1m[36m (4.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" character varying NOT NULL) [0m
|
43
|
+
[1m[35m (1.4ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
44
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.6ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
45
|
+
Migrating to CreateUsers (20140625163719)
|
46
|
+
[1m[35m (0.2ms)[0m BEGIN
|
47
|
+
DEPRECATION WARNING: `#timestamps` was called without specifying an option for `null`. In Rails 5, this behavior will change to `null: false`. You should manually specify `null: true` to prevent the behavior of your existing migrations from changing. (called from block in change at /Users/diogo/Projects/user_notifier/spec/dummy/db/migrate/20140625163719_create_users.rb:7)
|
48
|
+
[1m[36m (4.8ms)[0m [1mCREATE TABLE "users" ("id" serial primary key, "name" text, "email" text, "created_at" timestamp, "updated_at" timestamp) [0m
|
49
|
+
[1m[35mSQL (0.4ms)[0m INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20140625163719"]]
|
50
|
+
[1m[36m (0.5ms)[0m [1mCOMMIT[0m
|
51
|
+
Migrating to CreateUserNotifications (20140625183616)
|
52
|
+
[1m[35m (0.3ms)[0m BEGIN
|
53
|
+
[1m[36m (4.2ms)[0m [1mCREATE TABLE "user_notifications" ("id" serial primary key, "user_id" integer, "from_email" text, "from_name" text, "template_name" text, "locale" text, "sent_at" timestamp) [0m
|
54
|
+
[1m[35mSQL (0.3ms)[0m INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20140625183616"]]
|
55
|
+
[1m[36m (0.6ms)[0m [1mCOMMIT[0m
|
56
|
+
Migrating to CreateOrders (20140709164530)
|
57
|
+
[1m[35m (0.4ms)[0m BEGIN
|
58
|
+
DEPRECATION WARNING: `#timestamps` was called without specifying an option for `null`. In Rails 5, this behavior will change to `null: false`. You should manually specify `null: true` to prevent the behavior of your existing migrations from changing. (called from block in change at /Users/diogo/Projects/user_notifier/spec/dummy/db/migrate/20140709164530_create_orders.rb:7)
|
59
|
+
[1m[36m (5.8ms)[0m [1mCREATE TABLE "orders" ("id" serial primary key, "user_id" integer, "title" text, "created_at" timestamp, "updated_at" timestamp) [0m
|
60
|
+
[1m[35mSQL (0.4ms)[0m INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20140709164530"]]
|
61
|
+
[1m[36m (0.5ms)[0m [1mCOMMIT[0m
|
62
|
+
Migrating to CreateOrderNotifications (20140709170259)
|
63
|
+
[1m[35m (0.4ms)[0m BEGIN
|
64
|
+
[1m[36m (6.0ms)[0m [1mCREATE TABLE "order_notifications" ("id" serial primary key, "user_id" integer NOT NULL, "order_id" integer NOT NULL, "from_email" text NOT NULL, "from_name" text NOT NULL, "template_name" text NOT NULL, "locale" text NOT NULL, "sent_at" timestamp) [0m
|
65
|
+
[1m[35mSQL (0.3ms)[0m INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20140709170259"]]
|
66
|
+
[1m[36m (0.5ms)[0m [1mCOMMIT[0m
|
67
|
+
Migrating to AddDeliverAtToNotifications (20150713180329)
|
68
|
+
[1m[35m (0.4ms)[0m BEGIN
|
69
|
+
[1m[36m (1.1ms)[0m [1mALTER TABLE "order_notifications" ADD "deliver_at" timestamp[0m
|
70
|
+
[1m[35m (1.5ms)[0m ALTER TABLE "user_notifications" ADD "deliver_at" timestamp
|
71
|
+
[1m[36m (1.5ms)[0m [1mALTER TABLE order_notifications ALTER deliver_at SET DEFAULT current_timestamp[0m
|
72
|
+
[1m[35m (1.0ms)[0m ALTER TABLE user_notifications ALTER deliver_at SET DEFAULT current_timestamp
|
73
|
+
[1m[36mSQL (0.5ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ($1)[0m [["version", "20150713180329"]]
|
74
|
+
[1m[35m (0.6ms)[0m COMMIT
|
75
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.4ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
76
|
+
[1m[35m (5.5ms)[0m SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
|
77
|
+
FROM pg_constraint c
|
78
|
+
JOIN pg_class t1 ON c.conrelid = t1.oid
|
79
|
+
JOIN pg_class t2 ON c.confrelid = t2.oid
|
80
|
+
JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
|
81
|
+
JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
|
82
|
+
JOIN pg_namespace t3 ON c.connamespace = t3.oid
|
83
|
+
WHERE c.contype = 'f'
|
84
|
+
AND t1.relname = 'order_notifications'
|
85
|
+
AND t3.nspname = ANY (current_schemas(false))
|
86
|
+
ORDER BY c.conname
|
87
|
+
|
88
|
+
[1m[36m (4.6ms)[0m [1mSELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
|
89
|
+
FROM pg_constraint c
|
90
|
+
JOIN pg_class t1 ON c.conrelid = t1.oid
|
91
|
+
JOIN pg_class t2 ON c.confrelid = t2.oid
|
92
|
+
JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
|
93
|
+
JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
|
94
|
+
JOIN pg_namespace t3 ON c.connamespace = t3.oid
|
95
|
+
WHERE c.contype = 'f'
|
96
|
+
AND t1.relname = 'orders'
|
97
|
+
AND t3.nspname = ANY (current_schemas(false))
|
98
|
+
ORDER BY c.conname
|
99
|
+
[0m
|
100
|
+
[1m[35m (5.0ms)[0m SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
|
101
|
+
FROM pg_constraint c
|
102
|
+
JOIN pg_class t1 ON c.conrelid = t1.oid
|
103
|
+
JOIN pg_class t2 ON c.confrelid = t2.oid
|
104
|
+
JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
|
105
|
+
JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
|
106
|
+
JOIN pg_namespace t3 ON c.connamespace = t3.oid
|
107
|
+
WHERE c.contype = 'f'
|
108
|
+
AND t1.relname = 'user_notifications'
|
109
|
+
AND t3.nspname = ANY (current_schemas(false))
|
110
|
+
ORDER BY c.conname
|
111
|
+
|
112
|
+
[1m[36m (4.7ms)[0m [1mSELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
|
113
|
+
FROM pg_constraint c
|
114
|
+
JOIN pg_class t1 ON c.conrelid = t1.oid
|
115
|
+
JOIN pg_class t2 ON c.confrelid = t2.oid
|
116
|
+
JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
|
117
|
+
JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
|
118
|
+
JOIN pg_namespace t3 ON c.connamespace = t3.oid
|
119
|
+
WHERE c.contype = 'f'
|
120
|
+
AND t1.relname = 'users'
|
121
|
+
AND t3.nspname = ANY (current_schemas(false))
|
122
|
+
ORDER BY c.conname
|
123
|
+
[0m
|
124
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.6ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
125
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.3ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
126
|
+
[1m[36m (4.0ms)[0m [1mSELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
|
127
|
+
FROM pg_constraint c
|
128
|
+
JOIN pg_class t1 ON c.conrelid = t1.oid
|
129
|
+
JOIN pg_class t2 ON c.confrelid = t2.oid
|
130
|
+
JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
|
131
|
+
JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
|
132
|
+
JOIN pg_namespace t3 ON c.connamespace = t3.oid
|
133
|
+
WHERE c.contype = 'f'
|
134
|
+
AND t1.relname = 'order_notifications'
|
135
|
+
AND t3.nspname = ANY (current_schemas(false))
|
136
|
+
ORDER BY c.conname
|
137
|
+
[0m
|
138
|
+
[1m[35m (3.5ms)[0m SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
|
139
|
+
FROM pg_constraint c
|
140
|
+
JOIN pg_class t1 ON c.conrelid = t1.oid
|
141
|
+
JOIN pg_class t2 ON c.confrelid = t2.oid
|
142
|
+
JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
|
143
|
+
JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
|
144
|
+
JOIN pg_namespace t3 ON c.connamespace = t3.oid
|
145
|
+
WHERE c.contype = 'f'
|
146
|
+
AND t1.relname = 'orders'
|
147
|
+
AND t3.nspname = ANY (current_schemas(false))
|
148
|
+
ORDER BY c.conname
|
149
|
+
|
150
|
+
[1m[36m (3.3ms)[0m [1mSELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
|
151
|
+
FROM pg_constraint c
|
152
|
+
JOIN pg_class t1 ON c.conrelid = t1.oid
|
153
|
+
JOIN pg_class t2 ON c.confrelid = t2.oid
|
154
|
+
JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
|
155
|
+
JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
|
156
|
+
JOIN pg_namespace t3 ON c.connamespace = t3.oid
|
157
|
+
WHERE c.contype = 'f'
|
158
|
+
AND t1.relname = 'user_notifications'
|
159
|
+
AND t3.nspname = ANY (current_schemas(false))
|
160
|
+
ORDER BY c.conname
|
161
|
+
[0m
|
162
|
+
[1m[35m (3.4ms)[0m SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
|
163
|
+
FROM pg_constraint c
|
164
|
+
JOIN pg_class t1 ON c.conrelid = t1.oid
|
165
|
+
JOIN pg_class t2 ON c.confrelid = t2.oid
|
166
|
+
JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
|
167
|
+
JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
|
168
|
+
JOIN pg_namespace t3 ON c.connamespace = t3.oid
|
169
|
+
WHERE c.contype = 'f'
|
170
|
+
AND t1.relname = 'users'
|
171
|
+
AND t3.nspname = ANY (current_schemas(false))
|
172
|
+
ORDER BY c.conname
|
173
|
+
|
174
|
+
[1m[36m (120.6ms)[0m [1mDROP DATABASE IF EXISTS "user_notifier_test"[0m
|
175
|
+
[1m[35m (243.4ms)[0m CREATE DATABASE "user_notifier_test" ENCODING = 'unicode'
|
176
|
+
[1m[36mSQL (0.4ms)[0m [1mCREATE EXTENSION IF NOT EXISTS "plpgsql"[0m
|
177
|
+
[1m[35m (7.1ms)[0m CREATE TABLE "order_notifications" ("id" serial primary key, "user_id" integer NOT NULL, "order_id" integer NOT NULL, "from_email" text NOT NULL, "from_name" text NOT NULL, "template_name" text NOT NULL, "locale" text NOT NULL, "sent_at" timestamp, "deliver_at" timestamp DEFAULT 'now()')
|
178
|
+
[1m[36m (4.8ms)[0m [1mCREATE TABLE "orders" ("id" serial primary key, "user_id" integer, "title" text, "created_at" timestamp, "updated_at" timestamp) [0m
|
179
|
+
[1m[35m (4.4ms)[0m CREATE TABLE "user_notifications" ("id" serial primary key, "user_id" integer, "from_email" text, "from_name" text, "template_name" text, "locale" text, "sent_at" timestamp, "deliver_at" timestamp DEFAULT 'now()')
|
180
|
+
[1m[36m (5.4ms)[0m [1mCREATE TABLE "users" ("id" serial primary key, "name" text, "email" text, "created_at" timestamp, "updated_at" timestamp) [0m
|
181
|
+
[1m[35m (2.3ms)[0m CREATE TABLE "schema_migrations" ("version" character varying NOT NULL)
|
182
|
+
[1m[36m (1.3ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
183
|
+
[1m[35m (0.4ms)[0m SELECT version FROM "schema_migrations"
|
184
|
+
[1m[36m (0.6ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20150713180329')[0m
|
185
|
+
[1m[35m (0.5ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20140625163719')
|
186
|
+
[1m[36m (0.4ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20140625183616')[0m
|
187
|
+
[1m[35m (0.4ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20140709164530')
|
188
|
+
[1m[36m (0.4ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20140709170259')[0m
|