short_message 0.0.1

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.
Files changed (56) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.md +25 -0
  3. data/Rakefile +27 -0
  4. data/app/controllers/short_message/application_controller.rb +4 -0
  5. data/app/helpers/short_message/application_helper.rb +4 -0
  6. data/app/mailers/short_message/mailer.rb +16 -0
  7. data/app/models/short_message/message.rb +85 -0
  8. data/config/locales/de.yml +12 -0
  9. data/config/locales/en.yml +12 -0
  10. data/config/routes.rb +2 -0
  11. data/db/migrate/20130308133457_create_short_message_messages.rb +13 -0
  12. data/lib/generators/short_message/install_generator.rb +12 -0
  13. data/lib/generators/short_message/templates/config/initializers/short_message.rb +18 -0
  14. data/lib/short_message/config.rb +37 -0
  15. data/lib/short_message/engine.rb +16 -0
  16. data/lib/short_message/version.rb +3 -0
  17. data/lib/short_message.rb +5 -0
  18. data/lib/tasks/short_message_tasks.rake +4 -0
  19. data/spec/config_helper.rb +15 -0
  20. data/spec/dummy/README.rdoc +261 -0
  21. data/spec/dummy/Rakefile +7 -0
  22. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  23. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  24. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  25. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  26. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  27. data/spec/dummy/config/application.rb +65 -0
  28. data/spec/dummy/config/boot.rb +10 -0
  29. data/spec/dummy/config/database.example.yml +42 -0
  30. data/spec/dummy/config/database.yml +9 -0
  31. data/spec/dummy/config/environment.rb +5 -0
  32. data/spec/dummy/config/environments/development.rb +37 -0
  33. data/spec/dummy/config/environments/production.rb +67 -0
  34. data/spec/dummy/config/environments/test.rb +37 -0
  35. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  36. data/spec/dummy/config/initializers/inflections.rb +15 -0
  37. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  38. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  39. data/spec/dummy/config/initializers/session_store.rb +8 -0
  40. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  41. data/spec/dummy/config/locales/en.yml +5 -0
  42. data/spec/dummy/config/routes.rb +4 -0
  43. data/spec/dummy/config.ru +4 -0
  44. data/spec/dummy/db/schema.rb +26 -0
  45. data/spec/dummy/log/test.log +292 -0
  46. data/spec/dummy/public/404.html +26 -0
  47. data/spec/dummy/public/422.html +26 -0
  48. data/spec/dummy/public/500.html +25 -0
  49. data/spec/dummy/public/favicon.ico +0 -0
  50. data/spec/dummy/script/rails +6 -0
  51. data/spec/factories/short_message_messages.rb +17 -0
  52. data/spec/mailers/short_message/mailer_spec.rb +64 -0
  53. data/spec/models/short_message/config_spec.rb +17 -0
  54. data/spec/models/short_message/message_spec.rb +52 -0
  55. data/spec/spec_helper.rb +21 -0
  56. metadata +265 -0
@@ -0,0 +1,292 @@
1
+ Connecting to database specified by database.yml
2
+ Connecting to database specified by database.yml
3
+ Connecting to database specified by database.yml
4
+ Connecting to database specified by database.yml
5
+ Connecting to database specified by database.yml
6
+  (139.7ms) CREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB
7
+  (329.1ms) CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`)
8
+  (2.2ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
9
+ Migrating to CreateShortMessageMessages (20130308133457)
10
+  (104.4ms) CREATE TABLE `short_message_messages` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `message_key` varchar(255), `sender` varchar(255), `recipient` varchar(255), `status_code` int(11), `text` text, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
11
+  (0.5ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20130308133457')
12
+  (0.2ms) SELECT `schema_migrations`.`version` FROM `schema_migrations`
13
+ Connecting to database specified by database.yml
14
+  (0.1ms) BEGIN
15
+  (0.3ms) ROLLBACK
16
+  (0.1ms) BEGIN
17
+  (0.2ms) ROLLBACK
18
+  (0.1ms) BEGIN
19
+  (0.3ms) ROLLBACK
20
+  (0.1ms) BEGIN
21
+  (0.2ms) ROLLBACK
22
+  (0.1ms) BEGIN
23
+  (0.2ms) ROLLBACK
24
+  (0.1ms) BEGIN
25
+  (0.2ms) ROLLBACK
26
+  (0.1ms) BEGIN
27
+  (0.2ms) ROLLBACK
28
+  (0.1ms) BEGIN
29
+  (0.3ms) ROLLBACK
30
+  (0.1ms) BEGIN
31
+  (0.3ms) ROLLBACK
32
+ Connecting to database specified by database.yml
33
+  (0.1ms) BEGIN
34
+  (0.2ms) ROLLBACK
35
+  (0.1ms) BEGIN
36
+  (0.3ms) ROLLBACK
37
+  (0.1ms) BEGIN
38
+  (0.3ms) ROLLBACK
39
+  (0.1ms) BEGIN
40
+  (0.2ms) ROLLBACK
41
+  (0.1ms) BEGIN
42
+  (0.2ms) ROLLBACK
43
+  (0.1ms) BEGIN
44
+  (0.3ms) ROLLBACK
45
+  (0.1ms) BEGIN
46
+  (0.2ms) ROLLBACK
47
+  (0.1ms) BEGIN
48
+  (0.2ms) ROLLBACK
49
+  (0.0ms) BEGIN
50
+  (0.3ms) ROLLBACK
51
+ Connecting to database specified by database.yml
52
+  (0.1ms) BEGIN
53
+  (0.2ms) ROLLBACK
54
+  (0.1ms) BEGIN
55
+  (0.2ms) ROLLBACK
56
+  (0.1ms) BEGIN
57
+  (0.1ms) ROLLBACK
58
+  (0.1ms) BEGIN
59
+  (0.2ms) ROLLBACK
60
+  (0.1ms) BEGIN
61
+  (0.2ms) ROLLBACK
62
+ Connecting to database specified by database.yml
63
+  (0.1ms) BEGIN
64
+  (0.2ms) ROLLBACK
65
+  (0.0ms) BEGIN
66
+  (0.1ms) ROLLBACK
67
+  (0.1ms) BEGIN
68
+  (0.2ms) ROLLBACK
69
+  (0.1ms) BEGIN
70
+  (0.1ms) ROLLBACK
71
+  (0.1ms) BEGIN
72
+  (0.2ms) ROLLBACK
73
+ Connecting to database specified by database.yml
74
+ Connecting to database specified by database.yml
75
+ Connecting to database specified by database.yml
76
+ Connecting to database specified by database.yml
77
+ Connecting to database specified by database.yml
78
+  (0.2ms) BEGIN
79
+  (0.2ms) ROLLBACK
80
+  (0.2ms) BEGIN
81
+  (0.1ms) ROLLBACK
82
+  (0.1ms) BEGIN
83
+  (0.2ms) ROLLBACK
84
+  (0.1ms) BEGIN
85
+  (0.1ms) ROLLBACK
86
+  (0.0ms) BEGIN
87
+  (0.1ms) ROLLBACK
88
+  (0.1ms) BEGIN
89
+  (0.2ms) ROLLBACK
90
+  (0.1ms) BEGIN
91
+  (0.1ms) ROLLBACK
92
+  (0.1ms) BEGIN
93
+  (0.1ms) ROLLBACK
94
+ Connecting to database specified by database.yml
95
+  (0.1ms) BEGIN
96
+  (0.1ms) ROLLBACK
97
+  (0.1ms) BEGIN
98
+  (0.4ms) ROLLBACK
99
+  (0.1ms) BEGIN
100
+  (0.3ms) ROLLBACK
101
+  (0.1ms) BEGIN
102
+  (0.2ms) ROLLBACK
103
+  (0.0ms) BEGIN
104
+  (0.3ms) ROLLBACK
105
+  (0.1ms) BEGIN
106
+  (0.2ms) ROLLBACK
107
+  (0.1ms) BEGIN
108
+  (0.2ms) ROLLBACK
109
+  (0.1ms) BEGIN
110
+  (0.1ms) ROLLBACK
111
+  (0.1ms) BEGIN
112
+  (0.3ms) ROLLBACK
113
+  (0.1ms) BEGIN
114
+  (0.2ms) ROLLBACK
115
+  (0.1ms) BEGIN
116
+  (0.2ms) ROLLBACK
117
+  (0.1ms) BEGIN
118
+  (0.2ms) ROLLBACK
119
+  (0.1ms) BEGIN
120
+  (0.2ms) ROLLBACK
121
+  (0.1ms) BEGIN
122
+  (0.2ms) ROLLBACK
123
+  (0.1ms) BEGIN
124
+  (0.2ms) ROLLBACK
125
+  (0.1ms) BEGIN
126
+  (0.2ms) ROLLBACK
127
+  (0.1ms) BEGIN
128
+  (0.2ms) ROLLBACK
129
+ Connecting to database specified by database.yml
130
+  (0.1ms) BEGIN
131
+  (0.2ms) ROLLBACK
132
+  (0.1ms) BEGIN
133
+  (0.2ms) ROLLBACK
134
+  (0.1ms) BEGIN
135
+  (0.1ms) ROLLBACK
136
+  (0.0ms) BEGIN
137
+  (0.0ms) ROLLBACK
138
+  (0.0ms) BEGIN
139
+  (0.1ms) ROLLBACK
140
+  (0.0ms) BEGIN
141
+  (0.1ms) ROLLBACK
142
+  (0.1ms) BEGIN
143
+  (0.1ms) ROLLBACK
144
+  (0.0ms) BEGIN
145
+  (0.1ms) ROLLBACK
146
+ Connecting to database specified by database.yml
147
+  (0.1ms) BEGIN
148
+  (0.2ms) ROLLBACK
149
+  (0.1ms) BEGIN
150
+  (0.3ms) ROLLBACK
151
+  (0.0ms) BEGIN
152
+  (0.0ms) ROLLBACK
153
+  (0.0ms) BEGIN
154
+  (0.2ms) ROLLBACK
155
+  (0.0ms) BEGIN
156
+  (0.0ms) ROLLBACK
157
+  (0.1ms) BEGIN
158
+  (0.1ms) ROLLBACK
159
+  (0.0ms) BEGIN
160
+  (0.1ms) ROLLBACK
161
+  (0.1ms) BEGIN
162
+  (0.1ms) ROLLBACK
163
+ Connecting to database specified by database.yml
164
+  (0.1ms) BEGIN
165
+  (0.1ms) ROLLBACK
166
+  (0.1ms) BEGIN
167
+  (0.1ms) ROLLBACK
168
+  (0.0ms) BEGIN
169
+  (0.2ms) ROLLBACK
170
+  (0.1ms) BEGIN
171
+  (0.2ms) ROLLBACK
172
+  (0.1ms) BEGIN
173
+  (0.1ms) ROLLBACK
174
+  (0.0ms) BEGIN
175
+  (0.1ms) ROLLBACK
176
+  (0.1ms) BEGIN
177
+  (0.2ms) ROLLBACK
178
+  (0.1ms) BEGIN
179
+  (0.1ms) ROLLBACK
180
+ Connecting to database specified by database.yml
181
+  (0.0ms) BEGIN
182
+  (0.2ms) ROLLBACK
183
+  (0.1ms) BEGIN
184
+  (0.2ms) ROLLBACK
185
+  (0.1ms) BEGIN
186
+  (0.2ms) ROLLBACK
187
+  (0.1ms) BEGIN
188
+  (0.2ms) ROLLBACK
189
+  (0.2ms) BEGIN
190
+  (0.2ms) ROLLBACK
191
+  (0.1ms) BEGIN
192
+  (0.1ms) ROLLBACK
193
+  (0.1ms) BEGIN
194
+  (0.1ms) ROLLBACK
195
+  (0.1ms) BEGIN
196
+  (0.1ms) ROLLBACK
197
+ Connecting to database specified by database.yml
198
+  (0.1ms) BEGIN
199
+  (0.3ms) ROLLBACK
200
+  (0.0ms) BEGIN
201
+  (0.2ms) ROLLBACK
202
+  (0.1ms) BEGIN
203
+  (0.1ms) ROLLBACK
204
+  (0.0ms) BEGIN
205
+  (0.2ms) ROLLBACK
206
+  (0.1ms) BEGIN
207
+  (0.2ms) ROLLBACK
208
+  (0.1ms) BEGIN
209
+  (0.1ms) ROLLBACK
210
+  (0.0ms) BEGIN
211
+  (0.3ms) ROLLBACK
212
+  (0.1ms) BEGIN
213
+  (0.3ms) ROLLBACK
214
+  (0.1ms) BEGIN
215
+  (0.2ms) ROLLBACK
216
+  (0.1ms) BEGIN
217
+  (0.2ms) ROLLBACK
218
+  (0.1ms) BEGIN
219
+  (0.2ms) ROLLBACK
220
+  (0.1ms) BEGIN
221
+  (0.2ms) ROLLBACK
222
+  (0.1ms) BEGIN
223
+  (0.2ms) ROLLBACK
224
+  (0.1ms) BEGIN
225
+  (0.2ms) ROLLBACK
226
+  (0.1ms) BEGIN
227
+  (0.2ms) ROLLBACK
228
+  (0.1ms) BEGIN
229
+  (0.1ms) ROLLBACK
230
+  (0.1ms) BEGIN
231
+  (0.1ms) ROLLBACK
232
+ Connecting to database specified by database.yml
233
+  (0.1ms) BEGIN
234
+  (0.2ms) ROLLBACK
235
+  (0.1ms) BEGIN
236
+  (0.2ms) ROLLBACK
237
+  (0.1ms) BEGIN
238
+  (0.2ms) ROLLBACK
239
+  (0.1ms) BEGIN
240
+  (0.1ms) ROLLBACK
241
+  (0.1ms) BEGIN
242
+  (0.1ms) ROLLBACK
243
+  (0.1ms) BEGIN
244
+  (0.1ms) ROLLBACK
245
+ Connecting to database specified by database.yml
246
+  (0.1ms) BEGIN
247
+  (0.2ms) ROLLBACK
248
+  (0.1ms) BEGIN
249
+  (0.2ms) ROLLBACK
250
+  (0.1ms) BEGIN
251
+  (0.1ms) ROLLBACK
252
+  (0.1ms) BEGIN
253
+  (0.3ms) ROLLBACK
254
+  (0.1ms) BEGIN
255
+  (0.3ms) ROLLBACK
256
+  (0.1ms) BEGIN
257
+  (0.2ms) ROLLBACK
258
+  (0.1ms) BEGIN
259
+  (0.2ms) ROLLBACK
260
+  (0.1ms) BEGIN
261
+  (0.2ms) ROLLBACK
262
+  (0.1ms) BEGIN
263
+  (0.2ms) ROLLBACK
264
+  (0.0ms) BEGIN
265
+  (0.2ms) ROLLBACK
266
+  (0.0ms) BEGIN
267
+  (0.2ms) ROLLBACK
268
+  (0.1ms) BEGIN
269
+  (0.1ms) ROLLBACK
270
+  (0.1ms) BEGIN
271
+  (0.2ms) ROLLBACK
272
+  (0.1ms) BEGIN
273
+  (0.1ms) ROLLBACK
274
+  (0.1ms) BEGIN
275
+  (0.2ms) ROLLBACK
276
+  (0.1ms) BEGIN
277
+  (0.1ms) ROLLBACK
278
+  (0.1ms) BEGIN
279
+  (0.1ms) ROLLBACK
280
+ Connecting to database specified by database.yml
281
+  (0.0ms) BEGIN
282
+  (0.2ms) ROLLBACK
283
+  (0.1ms) BEGIN
284
+  (0.2ms) ROLLBACK
285
+  (0.1ms) BEGIN
286
+  (0.1ms) ROLLBACK
287
+  (0.1ms) BEGIN
288
+  (0.1ms) ROLLBACK
289
+  (0.1ms) BEGIN
290
+  (0.1ms) ROLLBACK
291
+  (0.0ms) BEGIN
292
+  (0.2ms) ROLLBACK
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,17 @@
1
+ # Read about factories at https://github.com/thoughtbot/factory_girl
2
+
3
+ FactoryGirl.define do
4
+ factory :short_message_message, :class => 'Message' do
5
+ message_key "MyString"
6
+ sender "MyString"
7
+ recipient "MyString"
8
+ status_code 1
9
+ text "MyText"
10
+ end
11
+ end
12
+
13
+ FactoryGirl.define do
14
+ factory :message, class: ShortMessage::Message do
15
+
16
+ end
17
+ end
@@ -0,0 +1,64 @@
1
+ require "spec_helper"
2
+
3
+ module ShortMessage
4
+ describe Mailer do
5
+ describe "reload notification" do
6
+ ShortMessage.configure do |config|
7
+ config.reload_notification_email = "webmaster@your-domain.com"
8
+ config.default_mail_sender = "webmaster@your-domain.com"
9
+ end
10
+
11
+ amount = 20
12
+
13
+ let(:mail) { ShortMessage::Mailer.recharge_notification amount }
14
+
15
+ it "renders the subject" do
16
+ mail.subject.should == "SMS credit recharged"
17
+ end
18
+
19
+ it "renders the sender email" do
20
+ mail.from.should == ["webmaster@your-domain.com"]
21
+ end
22
+
23
+ it "renders the recipient email" do
24
+ mail.to.should == ["webmaster@your-domain.com"]
25
+ end
26
+
27
+ it "contains the amount in the body" do
28
+ mail.body.encoded.should match(amount.to_s)
29
+ end
30
+ end
31
+
32
+ describe "voucher notification" do
33
+ ShortMessage.configure do |config|
34
+ config.user_id = "123456789abcdefghijklmnopq"
35
+ config.voucher_notification_email = "give-me-money@your-domain.com"
36
+ config.default_mail_sender = "webmaster@your-domain.com"
37
+ end
38
+
39
+ amount = 20
40
+
41
+ let(:mail) { ShortMessage::Mailer.voucher_notification amount }
42
+
43
+ it "renders the subject" do
44
+ mail.subject.should == "SMS credit recharged, please create a voucher"
45
+ end
46
+
47
+ it "renders the sender email" do
48
+ mail.from.should == ["webmaster@your-domain.com"]
49
+ end
50
+
51
+ it "renders the recipient email" do
52
+ mail.to.should == ["give-me-money@your-domain.com"]
53
+ end
54
+
55
+ it "contains the amount in the body" do
56
+ mail.body.encoded.should match(amount.to_s)
57
+ end
58
+
59
+ it "contains the customer in the body" do
60
+ mail.body.encoded.should match(amount.to_s)
61
+ end
62
+ end
63
+ end
64
+ end