Skip to content

Commit 97b6e04

Browse files
committed
Refactored the Newsletter and User Controller
-Merged index, opt_in and opt_out actions from newsletter controller. -Moved sendtest, sendmailer and testmail actions from user controller to newsletter controller. -Merged test_opt_in, test_opt_out and testmail(from user controller) actions and renamed it as test_mail. -Merged send_opt_in_test, send_opt_out_test and sendtest(from user controller) actions and renamed it as send_test_mail. -Merged send_opt_in, send_opt-out and sendmailer(from user controller) actions and renamed it as send_newsletter. -Romoved the global send mail and send test buttons and added buttons below individual newsletters. -Removed the unnecessary and added necessary routes. -Added before filters and flash messages in Newsletter and User controller -Added method in before filter of newsletter controller -Added load_user before filter in user controller -Added flash messages where required -Added alert message before deleting newsletter -Modified the UI for test mail template and changed flash messages -Added placeholder to email_ids field in test mail template -Changed flash messages for test mail -Modified the UI and added type parameter in newsletters path -Added type in newsletters_path -Handled a failure condition - absence of newsletter in params -Changed the UI for test mail template -Changed the query for fetching newsletter in opt-in worker, opt-out worker and user worker -Added type varible for redirect path -Fix test configuration -Fix the bootstrap navbar menu-items active-state issue -Corrected the spelling and removed the type from flash messages -Fix the gemfile for test environment -Added Test cases for updated code -Added test cases for send newsletter and send test mail in newsletter controller spec -Added test cases for opt in, opt out and get image in newsletter model spec -Removed test cases for send_mailer and sendtest from user controller spec -Fixed typo in Rakefile -Updated load_newsletter query -Handled failure cases for update and destroy action of newsletter controller -Modified testcases to check flash message content -Added more checks and Moved instance varible from before filter to respective test case -Replaced double quotes with single quotes -Minor syntax corrections -Fixed the query for load newsletter and minor syntax error in user index template -Removed duplicated methods
1 parent 4d3bea6 commit 97b6e04

31 files changed

+587
-385
lines changed

Gemfile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ gem 'sendgrid'
1818
# Use mongoid to utilise mongodb
1919
gem 'mongoid'
2020

21-
# The following gems for testing purpose in development and testing environment
22-
group :development, :test do
21+
# The following gems for testing purpose in testing environment
22+
group :test do
2323
# Rspec is used to write the test cases
24-
gem 'rspec-rails'
24+
gem 'rspec-rails', '~> 3.1'
25+
gem 'mongoid-rspec'
26+
gem 'byebug'
2527
# Use factory girl to pass random data for test cases
2628
gem 'factory_girl_rails'
2729
# Use faker to generate fake strings and data
@@ -30,9 +32,6 @@ group :development, :test do
3032
gem 'database_cleaner'
3133
# Use to track how much code has been tested
3234
gem 'simplecov', '~> 0.7.1'
33-
end
34-
35-
group :test do
3635
# Webmock to stub http requests
3736
gem 'webmock'
3837
# VCR to record the responses from web and replay them when needed

Gemfile.lock

Lines changed: 84 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ GIT
77
oauth (>= 0.3.6)
88
oauth2 (>= 0.5.0)
99

10+
GIT
11+
remote: git://github.com/aq1018/mongoid-history.git
12+
revision: 2935da05ccf24027c83b3bd1a92b39edc78ee6b8
13+
specs:
14+
mongoid-history (0.8.4)
15+
activesupport
16+
easy_diff
17+
mongoid (>= 3.0)
18+
mongoid-compatibility (>= 0.5.1)
19+
1020
PATH
1121
remote: .
1222
specs:
@@ -25,12 +35,13 @@ PATH
2535
jquery-rails
2636
mini_magick
2737
mongoid
38+
mongoid-history
2839
omniauth-google-oauth2
2940
rails (~> 4.2.5.2)
3041
redactor-rails (= 0.4.5)
3142
redis-namespace
3243
redis-rails
33-
rest_client
44+
rest-client
3445
sass-rails (~> 4.0.3)
3546
select2-rails
3647
sendgrid
@@ -85,16 +96,17 @@ GEM
8596
addressable (>= 2.3.1)
8697
extlib (>= 0.9.15)
8798
multi_json (>= 1.0.0)
88-
autoprefixer-rails (7.2.2)
99+
autoprefixer-rails (9.8.6)
89100
execjs
90101
bcrypt (3.1.7)
91102
bootstrap-datepicker-rails (1.3.0.2)
92103
railties (>= 3.0)
93-
bootstrap-sass (3.3.5)
94-
autoprefixer-rails (>= 5.0.0.1)
95-
sass (>= 3.2.19)
104+
bootstrap-sass (3.4.1)
105+
autoprefixer-rails (>= 5.2.1)
106+
sassc (>= 2.0.0)
96107
bson (2.3.0)
97108
builder (3.2.3)
109+
byebug (10.0.2)
98110
carrierwave (0.10.0)
99111
activemodel (>= 3.2.0)
100112
activesupport (>= 3.2.0)
@@ -104,7 +116,7 @@ GEM
104116
carrierwave (>= 0.8.0, < 0.11.0)
105117
mongoid (>= 3.0, < 5.0)
106118
mongoid-grid_fs (>= 1.3, < 3.0)
107-
celluloid (0.17.3)
119+
celluloid (0.17.4)
108120
celluloid-essentials
109121
celluloid-extras
110122
celluloid-fsm
@@ -148,7 +160,10 @@ GEM
148160
devise_invitable (1.6.1)
149161
actionmailer (>= 3.2.6)
150162
devise (>= 3.2.0)
151-
diff-lcs (1.2.5)
163+
diff-lcs (1.4.4)
164+
domain_name (0.5.20190701)
165+
unf (>= 0.0.5, < 1.0.0)
166+
easy_diff (1.0.0)
152167
erubis (2.7.0)
153168
execjs (2.7.0)
154169
extlib (0.9.16)
@@ -161,7 +176,8 @@ GEM
161176
i18n (~> 0.5)
162177
faraday (0.9.0)
163178
multipart-post (>= 1.2, < 3)
164-
globalid (0.4.1)
179+
ffi (1.12.2)
180+
globalid (0.4.2)
165181
activesupport (>= 4.2.0)
166182
google-api-client (0.7.1)
167183
addressable (>= 2.3.2)
@@ -174,7 +190,7 @@ GEM
174190
retriable (>= 1.4)
175191
signet (>= 0.5.0)
176192
uuidtools (>= 2.1.0)
177-
haml (5.0.4)
193+
haml (5.2.0)
178194
temple (>= 0.8.0)
179195
tilt
180196
haml-rails (1.0.0)
@@ -186,22 +202,23 @@ GEM
186202
hashdiff (0.2.3)
187203
hashie (2.1.2)
188204
hike (1.2.3)
189-
hitimes (1.2.6)
190205
html2haml (2.2.0)
191206
erubis (~> 2.7.0)
192207
haml (>= 4.0, < 6)
193208
nokogiri (>= 1.6.0)
194209
ruby_parser (~> 3.5)
210+
http-accept (1.7.0)
211+
http-cookie (1.0.3)
212+
domain_name (~> 0.5)
195213
httparty (0.13.1)
196214
json (~> 1.8)
197215
multi_xml (>= 0.5.2)
198216
i18n (0.9.1)
199217
concurrent-ruby (~> 1.0)
200218
imgkit (1.6.0)
201-
jbuilder (2.7.0)
219+
jbuilder (2.9.1)
202220
activesupport (>= 4.2.0)
203-
multi_json (>= 1.2)
204-
jquery-rails (4.3.1)
221+
jquery-rails (4.4.0)
205222
rails-dom-testing (>= 1, < 3)
206223
railties (>= 4.2.0)
207224
thor (>= 0.14, < 2.0)
@@ -213,7 +230,7 @@ GEM
213230
loofah (2.1.1)
214231
crass (~> 1.0.2)
215232
nokogiri (>= 1.5.9)
216-
mail (2.7.0)
233+
mail (2.7.1)
217234
mini_mime (>= 0.1.1)
218235
method_source (0.8.2)
219236
mime-types (2.99.3)
@@ -223,19 +240,29 @@ GEM
223240
mina_extensions (0.0.2)
224241
mini_magick (3.8.0)
225242
subexec (~> 0.2.1)
226-
mini_mime (1.0.0)
243+
mini_mime (1.0.2)
227244
mini_portile2 (2.3.0)
228245
minitest (5.10.3)
229246
mongoid (4.0.0)
230247
activemodel (~> 4.0)
231248
moped (~> 2.0.0)
232249
origin (~> 2.1)
233250
tzinfo (>= 0.3.37)
251+
mongoid-compatibility (0.5.1)
252+
activesupport
253+
mongoid (>= 2.0)
234254
mongoid-grid_fs (2.1.0)
235255
mime-types (>= 1.0, < 3.0)
236256
mongoid (>= 3.0, < 5.0)
237257
mongoid-paperclip (0.0.9)
238258
paperclip (>= 2.3.6)
259+
mongoid-rspec (4.1.0)
260+
activesupport (>= 3.0.0)
261+
mongoid (>= 3.1)
262+
mongoid-compatibility (>= 0.5.1)
263+
rspec-core (~> 3.3)
264+
rspec-expectations (~> 3.3)
265+
rspec-mocks (~> 3.3)
239266
mongoid_slug (3.2.1)
240267
mongoid (> 3.0)
241268
stringex (~> 2.0)
@@ -246,7 +273,7 @@ GEM
246273
multi_json (1.12.2)
247274
multi_xml (0.5.5)
248275
multipart-post (2.0.0)
249-
netrc (0.7.7)
276+
netrc (0.11.0)
250277
nokogiri (1.8.1)
251278
mini_portile2 (~> 2.3.0)
252279
oauth (0.4.7)
@@ -336,26 +363,30 @@ GEM
336363
ref (1.0.5)
337364
responders (2.1.1)
338365
railties (>= 4.2.0, < 5.1)
339-
rest_client (1.7.3)
340-
netrc (~> 0.7.7)
366+
rest-client (2.1.0)
367+
http-accept (>= 1.7.0, < 2.0)
368+
http-cookie (>= 1.0.2, < 2.0)
369+
mime-types (>= 1.16, < 4.0)
370+
netrc (~> 0.8)
341371
retriable (1.4.1)
342-
rspec-core (3.0.3)
343-
rspec-support (~> 3.0.0)
344-
rspec-expectations (3.0.3)
372+
rspec-core (3.9.3)
373+
rspec-support (~> 3.9.3)
374+
rspec-expectations (3.9.4)
375+
diff-lcs (>= 1.2.0, < 2.0)
376+
rspec-support (~> 3.9.0)
377+
rspec-mocks (3.9.1)
345378
diff-lcs (>= 1.2.0, < 2.0)
346-
rspec-support (~> 3.0.0)
347-
rspec-mocks (3.0.3)
348-
rspec-support (~> 3.0.0)
349-
rspec-rails (3.0.2)
379+
rspec-support (~> 3.9.0)
380+
rspec-rails (3.9.1)
350381
actionpack (>= 3.0)
351382
activesupport (>= 3.0)
352383
railties (>= 3.0)
353-
rspec-core (~> 3.0.0)
354-
rspec-expectations (~> 3.0.0)
355-
rspec-mocks (~> 3.0.0)
356-
rspec-support (~> 3.0.0)
357-
rspec-support (3.0.3)
358-
ruby_parser (3.10.1)
384+
rspec-core (~> 3.9.0)
385+
rspec-expectations (~> 3.9.0)
386+
rspec-mocks (~> 3.9.0)
387+
rspec-support (~> 3.9.0)
388+
rspec-support (3.9.4)
389+
ruby_parser (3.15.0)
359390
sexp_processor (~> 4.9)
360391
safe_yaml (1.0.3)
361392
sass (3.2.19)
@@ -364,13 +395,15 @@ GEM
364395
sass (~> 3.2.2)
365396
sprockets (~> 2.8, < 3.0)
366397
sprockets-rails (~> 2.0)
398+
sassc (2.4.0)
399+
ffi (~> 1.9)
367400
select2-rails (3.5.9)
368401
thor (~> 0.14)
369402
sendgrid (1.2.0)
370403
json
371404
sendgrid_toolkit (1.4.0)
372405
httparty (>= 0.7.6)
373-
sexp_processor (4.10.0)
406+
sexp_processor (4.15.1)
374407
sidekiq (3.3.0)
375408
celluloid (>= 0.16.0)
376409
connection_pool (>= 2.0.0)
@@ -396,7 +429,7 @@ GEM
396429
slop (3.6.0)
397430
spring (2.0.2)
398431
activesupport (>= 4.2)
399-
sprockets (2.12.4)
432+
sprockets (2.12.5)
400433
hike (~> 1.2)
401434
multi_json (~> 1.0)
402435
rack (~> 1.0)
@@ -407,22 +440,24 @@ GEM
407440
sprockets (>= 2.8, < 4.0)
408441
stringex (2.5.2)
409442
subexec (0.2.3)
410-
temple (0.8.0)
443+
temple (0.8.2)
411444
therubyracer (0.12.1)
412445
libv8 (~> 3.16.14.0)
413446
ref
414447
thor (0.20.0)
415448
thread_safe (0.3.6)
416449
tilt (1.4.1)
417-
timers (4.1.2)
418-
hitimes
419-
turbolinks (5.0.1)
420-
turbolinks-source (~> 5)
421-
turbolinks-source (5.0.3)
450+
timers (4.3.2)
451+
turbolinks (5.2.1)
452+
turbolinks-source (~> 5.2)
453+
turbolinks-source (5.2.0)
422454
tzinfo (1.2.4)
423455
thread_safe (~> 0.1)
424-
uglifier (4.0.1)
456+
uglifier (4.2.0)
425457
execjs (>= 0.3.0, < 3)
458+
unf (0.1.4)
459+
unf_ext
460+
unf_ext (0.0.7.7)
426461
uuidtools (2.1.4)
427462
vcr (2.9.2)
428463
warden (1.2.3)
@@ -436,6 +471,7 @@ PLATFORMS
436471
ruby
437472

438473
DEPENDENCIES
474+
byebug
439475
carrierwave
440476
carrierwave-mongoid
441477
database_cleaner
@@ -449,16 +485,18 @@ DEPENDENCIES
449485
mina_extensions
450486
mini_magick
451487
mongoid
488+
mongoid-history!
452489
mongoid-paperclip
490+
mongoid-rspec
453491
mongoid_slug
454492
omniauth-google-oauth2
455493
pry
456494
redactor-rails
457495
redis-namespace
458496
redis-rails
459497
responders (~> 2.0)
460-
rest_client
461-
rspec-rails
498+
rest-client
499+
rspec-rails (~> 3.1)
462500
select2-rails
463501
sendgrid
464502
sendgrid_toolkit
@@ -469,5 +507,8 @@ DEPENDENCIES
469507
vcr
470508
webmock
471509

510+
RUBY VERSION
511+
ruby 2.2.4p230
512+
472513
BUNDLED WITH
473-
1.11.2
514+
1.17.3

Rakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ rescue LoadError
44
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
55
end
66

7-
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile",_FILE_)
7+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile",__FILE__)
88
load 'rails/tasks/engine.rake'
99
Bundler::GemHelper.install_tasks
10-
Dir[File.join(File.dirname(_FILE_), 'tasks/**/*.rake')].each {|f| load f }
10+
Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
1111

1212
#require 'rdoc/task'
1313
require 'rspec/core'

0 commit comments

Comments
 (0)