commontator 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. data/lib/commontator/version.rb +1 -1
  2. data/lib/commontator/version.rb~ +1 -1
  3. data/spec/app/controllers/comments_controller_spec.rb~ +7 -0
  4. data/spec/app/controllers/commontator/application_controller_spec.rb~ +30 -0
  5. data/spec/app/controllers/commontator/comments_controller_spec.rb +473 -0
  6. data/spec/app/controllers/commontator/comments_controller_spec.rb~ +473 -0
  7. data/spec/app/controllers/commontator/subscriptions_controller_spec.rb +99 -0
  8. data/spec/app/controllers/commontator/subscriptions_controller_spec.rb~ +99 -0
  9. data/spec/app/controllers/commontator/threads_controller_spec.rb +121 -0
  10. data/spec/app/controllers/commontator/threads_controller_spec.rb~ +121 -0
  11. data/spec/app/controllers/threads_controller_spec.rb~ +12 -0
  12. data/spec/app/helpers/commontator/application_helper_spec.rb +7 -0
  13. data/spec/app/helpers/commontator/application_helper_spec.rb~ +7 -0
  14. data/spec/app/helpers/commontator/threads_helper_spec.rb +17 -0
  15. data/spec/app/helpers/commontator/threads_helper_spec.rb~ +17 -0
  16. data/spec/app/mailers/commontator/subscriptions_mailer_spec.rb +38 -0
  17. data/spec/app/mailers/commontator/subscriptions_mailer_spec.rb~ +37 -0
  18. data/spec/app/models/commontator/comment_spec.rb +60 -0
  19. data/spec/app/models/commontator/comment_spec.rb~ +60 -0
  20. data/spec/app/models/commontator/subscription_spec.rb +28 -0
  21. data/spec/app/models/commontator/subscription_spec.rb~ +28 -0
  22. data/spec/app/models/commontator/thread_spec.rb +130 -0
  23. data/spec/app/models/commontator/thread_spec.rb~ +130 -0
  24. data/spec/dummy/Gemfile~ +3 -0
  25. data/spec/dummy/README.md +3 -0
  26. data/spec/dummy/README.md~ +3 -0
  27. data/spec/dummy/Rakefile +7 -0
  28. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  29. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  30. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  31. data/spec/dummy/app/controllers/application_controller.rb~ +7 -0
  32. data/spec/dummy/app/controllers/dummies_controller.rb~ +17 -0
  33. data/spec/dummy/app/controllers/dummy_models_controller.rb +29 -0
  34. data/spec/dummy/app/controllers/dummy_models_controller.rb~ +29 -0
  35. data/spec/dummy/app/helpers/application_helper.rb +15 -0
  36. data/spec/dummy/app/helpers/application_helper.rb~ +15 -0
  37. data/spec/dummy/app/models/dummy.rb~ +3 -0
  38. data/spec/dummy/app/models/dummy_model.rb +3 -0
  39. data/spec/dummy/app/models/dummy_user.rb +9 -0
  40. data/spec/dummy/app/models/dummy_user.rb~ +9 -0
  41. data/spec/dummy/app/models/user.rb~ +5 -0
  42. data/spec/dummy/app/views/dummy_model/show.html.erb +1 -0
  43. data/spec/dummy/app/views/dummy_model/show.html.erb~ +1 -0
  44. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  45. data/spec/dummy/config.ru +4 -0
  46. data/spec/dummy/config/application.rb +59 -0
  47. data/spec/dummy/config/application.rb~ +59 -0
  48. data/spec/dummy/config/boot.rb +10 -0
  49. data/spec/dummy/config/database.yml +25 -0
  50. data/spec/dummy/config/environment.rb +5 -0
  51. data/spec/dummy/config/environments/development.rb +37 -0
  52. data/spec/dummy/config/environments/production.rb +67 -0
  53. data/spec/dummy/config/environments/test.rb +37 -0
  54. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  55. data/spec/dummy/config/initializers/commontator.rb +158 -0
  56. data/spec/dummy/config/initializers/commontator.rb~ +157 -0
  57. data/spec/dummy/config/initializers/inflections.rb +15 -0
  58. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  59. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  60. data/spec/dummy/config/initializers/session_store.rb +8 -0
  61. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  62. data/spec/dummy/config/locales/en.yml +5 -0
  63. data/spec/dummy/config/routes.rb +7 -0
  64. data/spec/dummy/config/routes.rb~ +7 -0
  65. data/spec/dummy/db/development.sqlite3 +0 -0
  66. data/spec/dummy/db/migrate/0_create_dummies.rb~ +48 -0
  67. data/spec/dummy/db/migrate/0_create_dummy_models.rb +7 -0
  68. data/spec/dummy/db/migrate/0_create_dummy_models.rb~ +7 -0
  69. data/spec/dummy/db/migrate/1_create_dummy_users.rb +7 -0
  70. data/spec/dummy/db/migrate/1_create_dummy_users.rb~ +7 -0
  71. data/spec/dummy/db/migrate/1_create_users.rb~ +7 -0
  72. data/spec/dummy/db/migrate/2_install_commontator.rb +49 -0
  73. data/spec/dummy/db/migrate/2_install_commontator.rb~ +49 -0
  74. data/spec/dummy/db/migrate/3_acts_as_votable_migration.rb +20 -0
  75. data/spec/dummy/db/schema.rb +84 -0
  76. data/spec/dummy/db/schema.rb~ +71 -0
  77. data/spec/dummy/db/test.sqlite3 +0 -0
  78. data/spec/dummy/log/development.log +14298 -0
  79. data/spec/dummy/log/test.log +149321 -0
  80. data/spec/dummy/public/404.html +26 -0
  81. data/spec/dummy/public/422.html +26 -0
  82. data/spec/dummy/public/500.html +25 -0
  83. data/spec/dummy/public/favicon.ico +0 -0
  84. data/spec/dummy/script/rails +6 -0
  85. data/spec/dummy/tmp/cache/assets/CCB/1D0/sprockets%2F02d4b791eb831cf2057bf4703a1218d1 +0 -0
  86. data/spec/dummy/tmp/cache/assets/CD1/510/sprockets%2Fc69ee3cc5796188d873574179290a6ef +0 -0
  87. data/spec/dummy/tmp/cache/assets/D01/8B0/sprockets%2F0f196a1a50363b0a076ec6e1ee5417f6 +0 -0
  88. data/spec/dummy/tmp/cache/assets/D06/2F0/sprockets%2Fe1f674c11941d62aac1764ef3a7134e4 +0 -0
  89. data/spec/dummy/tmp/cache/assets/D54/060/sprockets%2Fe85565206c3e5fdf9dfeb367c85557b1 +0 -0
  90. data/spec/dummy/tmp/cache/assets/D9B/550/sprockets%2Fa41c8be5379abec3c0d0d98e2f0d5609 +0 -0
  91. data/spec/dummy/tmp/cache/assets/E01/2E0/sprockets%2Fa3fb9025f90ff05a6fd4afc7ded2692c +0 -0
  92. data/spec/lib/commontator/acts_as_commontable_spec.rb +26 -0
  93. data/spec/lib/commontator/acts_as_commontable_spec.rb~ +26 -0
  94. data/spec/lib/commontator/acts_as_commontator_spec.rb +25 -0
  95. data/spec/lib/commontator/acts_as_commontator_spec.rb~ +25 -0
  96. data/spec/lib/commontator/commontable_config_spec.rb +26 -0
  97. data/spec/lib/commontator/commontable_config_spec.rb~ +26 -0
  98. data/spec/lib/commontator/commontator_config_spec.rb +26 -0
  99. data/spec/lib/commontator/commontator_config_spec.rb~ +26 -0
  100. data/spec/lib/commontator/controller_includes_spec.rb +15 -0
  101. data/spec/lib/commontator/controller_includes_spec.rb~ +15 -0
  102. data/spec/lib/commontator/shared_helper_spec.rb +12 -0
  103. data/spec/lib/commontator/shared_helper_spec.rb~ +12 -0
  104. data/spec/lib/commontator_spec.rb +23 -0
  105. data/spec/lib/commontator_spec.rb~ +23 -0
  106. data/spec/spec_helper.rb +34 -0
  107. data/spec/spec_helper.rb~ +30 -0
  108. metadata +212 -2
@@ -0,0 +1,7 @@
1
+ module Commontator
2
+ describe ApplicationHelper do
3
+ it 'must print javascript proc' do
4
+ javascript_proc.must_equal 'Dummy Javascript'
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Commontator
2
+ describe ApplicationHelper do
3
+ it 'must print javascript proc' do
4
+ javascript_proc.must_equal ''
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ module Commontator
4
+ describe ThreadsHelper do
5
+ before do
6
+ setup_helper_spec
7
+ end
8
+
9
+ it 'must print commontable name' do
10
+ commontable_name(@thread).must_equal 'dummy model'
11
+ end
12
+
13
+ it 'must print commontable id' do
14
+ commontable_id(@thread).must_equal @thread.commontable_id
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ module Commontator
4
+ describe ThreadsHelper do
5
+ before do
6
+ setup_helper_spec
7
+ end
8
+
9
+ it 'must print commontable name' do
10
+ commontable_name(@thread).must_equal 'dummy comment'
11
+ end
12
+
13
+ it 'must print commontable id' do
14
+ commontable_id(@thread).must_equal @thread.commontable_id
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ module Commontator
4
+ describe SubscriptionsMailer do
5
+ before do
6
+ setup_mailer_spec
7
+ @comment = Comment.new
8
+ @comment.thread = @thread
9
+ @comment.creator = @user
10
+ @comment.body = 'Something'
11
+ @comment.save!
12
+ @commontable_url = 'dummy_model_url'
13
+ @thread.subscribe(@user)
14
+ end
15
+
16
+ it 'wont send email if subscribers empty' do
17
+ mail = SubscriptionsMailer.comment_created_email(@comment, @commontable_url)
18
+ mail.to.must_be_nil
19
+ mail.cc.must_be_nil
20
+ mail.bcc.must_be_nil
21
+ mail.subject.must_be_nil
22
+ mail.body.must_be_empty
23
+ end
24
+
25
+ it 'must send email if subscribers not empty' do
26
+ user2 = DummyUser.create
27
+ @thread.subscribe(DummyUser.create)
28
+ mail = SubscriptionsMailer.comment_created_email(@comment, @commontable_url)
29
+ mail.to.must_be_nil
30
+ mail.cc.must_be_nil
31
+ mail.bcc.size.must_equal 1
32
+ mail.bcc.must_include user2.email
33
+ mail.subject.wont_be_empty
34
+ mail.body.wont_be_empty
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ module Commontator
4
+ describe SubscriptionsMailer do
5
+ before do
6
+ setup_mailer_spec
7
+ @comment = Comment.new
8
+ @comment.thread = @thread
9
+ @comment.creator = @user
10
+ @comment.body = 'Something'
11
+ @comment.save!
12
+ @commontable_url = 'dummy_model_url'
13
+ @thread.subscribe(@user)
14
+ end
15
+
16
+ it 'wont send email if subscribers empty' do
17
+ mail = SubscriptionsMailer.comment_created_email(@comment, @commontable_url)
18
+ mail.to.must_be_nil
19
+ mail.cc.must_be_nil
20
+ mail.bcc.must_be_nil
21
+ mail.subject.must_be_nil
22
+ mail.body.must_be_empty
23
+ end
24
+
25
+ it 'must send email if subscribers not empty' do
26
+ user2 = DummyUser.create
27
+ @thread.subscribe(DummyUser.create)
28
+ mail = SubscriptionsMailer.comment_created_email(@comment, @commontable_url)
29
+ mail.to.must_be_nil
30
+ mail.cc.must_be_nil
31
+ mail.bcc.must_include user2.email
32
+ mail.subject.wont_be_empty
33
+ mail.body.wont_be_empty
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+ require 'acts_as_votable'
3
+
4
+ module Commontator
5
+ describe Comment do
6
+ before do
7
+ setup_model_spec
8
+ @comment = Comment.new
9
+ @comment.thread = @thread
10
+ @comment.creator = @user
11
+ @comment.body = 'Something'
12
+ end
13
+
14
+ it 'must be votable if acts_as_votable is installed' do
15
+ Comment.must_respond_to(:acts_as_votable)
16
+ @comment.is_votable?.must_equal true
17
+ @comment.acts_as_votable_initialized.must_equal true
18
+ end
19
+
20
+ it 'must know if it has been modified' do
21
+ @comment.save!
22
+
23
+ @comment.is_modified?.must_equal false
24
+
25
+ sleep 1
26
+ @comment.body = 'Something else'
27
+ @comment.save!
28
+
29
+ @comment.is_modified?.must_equal true
30
+ end
31
+
32
+ it 'must know if it has been deleted' do
33
+ user = DummyUser.new
34
+
35
+ @comment.is_deleted?.must_equal false
36
+ @comment.deleter.must_be_nil
37
+
38
+ @comment.delete(user)
39
+
40
+ @comment.is_deleted?.must_equal true
41
+ @comment.deleter.must_equal user
42
+
43
+ @comment.undelete
44
+
45
+ @comment.is_deleted?.must_equal false
46
+ end
47
+
48
+ it 'must make proper timestamps' do
49
+ @comment.save!
50
+
51
+ @comment.timestamp.must_equal "#{@thread.config.comment_create_verb_past.capitalize} on #{@comment.created_at.strftime(@thread.config.timestamp_format)}"
52
+
53
+ sleep 1
54
+ @comment.body = 'Something else'
55
+ @comment.save!
56
+
57
+ @comment.timestamp.must_equal "Last modified on #{@comment.updated_at.strftime(@thread.config.timestamp_format)}"
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+ require 'acts_as_votable'
3
+
4
+ module Commontator
5
+ describe Comment do
6
+ before do
7
+ setup_model_spec
8
+ @comment = Comment.new
9
+ @comment.thread = @thread
10
+ @comment.creator = @user
11
+ @comment.body = 'Something'
12
+ end
13
+
14
+ it 'must be votable if acts_as_votable is installed' do
15
+ Commontator::Comment.must_respond_to(:acts_as_votable)
16
+ @comment.is_votable?.must_equal true
17
+ @comment.acts_as_votable_initialized.must_equal true
18
+ end
19
+
20
+ it 'must know if it has been modified' do
21
+ @comment.save!
22
+
23
+ @comment.is_modified?.must_equal false
24
+
25
+ sleep 1
26
+ @comment.body = 'Something else'
27
+ @comment.save!
28
+
29
+ @comment.is_modified?.must_equal true
30
+ end
31
+
32
+ it 'must know if it has been deleted' do
33
+ user = DummyUser.new
34
+
35
+ @comment.is_deleted?.must_equal false
36
+ @comment.deleter.must_be_nil
37
+
38
+ @comment.delete(user)
39
+
40
+ @comment.is_deleted?.must_equal true
41
+ @comment.deleter.must_equal user
42
+
43
+ @comment.undelete
44
+
45
+ @comment.is_deleted?.must_equal false
46
+ end
47
+
48
+ it 'must make proper timestamps' do
49
+ @comment.save!
50
+
51
+ @comment.timestamp.must_equal "#{@thread.config.comment_create_verb_past.capitalize} on #{@comment.created_at.strftime(@thread.config.timestamp_format)}"
52
+
53
+ sleep 1
54
+ @comment.body = 'Something else'
55
+ @comment.save!
56
+
57
+ @comment.timestamp.must_equal "Last modified on #{@comment.updated_at.strftime(@thread.config.timestamp_format)}"
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ module Commontator
4
+ describe Subscription do
5
+ before do
6
+ setup_model_spec
7
+ @subscription = Subscription.new
8
+ @subscription.thread = @thread
9
+ @subscription.subscriber = @user
10
+ end
11
+
12
+ it 'must count unread comments' do
13
+ @subscription.unread.must_equal 0
14
+
15
+ @subscription.add_unread
16
+
17
+ @subscription.unread.must_equal 1
18
+
19
+ @subscription.add_unread
20
+
21
+ @subscription.unread.must_equal 2
22
+
23
+ @subscription.mark_as_read
24
+
25
+ @subscription.unread.must_equal 0
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ module Commontator
4
+ describe Commontator::Subscription do
5
+ before do
6
+ setup_model_spec
7
+ @subscription = Commontator::Subscription.new
8
+ @subscription.thread = @thread
9
+ @subscription.subscriber = @user
10
+ end
11
+
12
+ it 'must count unread comments' do
13
+ @subscription.unread.must_equal 0
14
+
15
+ @subscription.add_unread
16
+
17
+ @subscription.unread.must_equal 1
18
+
19
+ @subscription.add_unread
20
+
21
+ @subscription.unread.must_equal 2
22
+
23
+ @subscription.mark_as_read
24
+
25
+ @subscription.unread.must_equal 0
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,130 @@
1
+ require 'spec_helper'
2
+
3
+ module Commontator
4
+ describe Thread do
5
+ before do
6
+ setup_model_spec
7
+ end
8
+
9
+ it 'must have a config' do
10
+ @thread.config.must_be_instance_of CommontableConfig
11
+ @thread.commontable = nil
12
+ @thread.config.must_be_nil
13
+ end
14
+
15
+ it 'must order all comments' do
16
+ comment = Comment.new
17
+ comment.thread = @thread
18
+ comment.creator = @user
19
+ comment.body = 'Something'
20
+ comment.save!
21
+ comment2 = Comment.new
22
+ comment2.thread = @thread
23
+ comment2.creator = @user
24
+ comment2.body = 'Something else'
25
+ comment2.save!
26
+
27
+ comments = @thread.comments
28
+ ordered_comments = @thread.ordered_comments
29
+
30
+ comments.each { |c| ordered_comments.must_include c }
31
+ ordered_comments.each { |oc| comments.must_include oc }
32
+ end
33
+
34
+ it 'must list all subscribers' do
35
+ @thread.subscribe(@user)
36
+ @thread.subscribe(DummyUser.create)
37
+
38
+ @thread.subscriptions.each { |sp| \
39
+ @thread.subscribers.must_include sp.subscriber }
40
+ end
41
+
42
+ it 'must find the subscription for each user' do
43
+ @thread.subscribe(@user)
44
+ user2 = DummyUser.create
45
+ @thread.subscribe(user2)
46
+
47
+ subscription = @thread.subscription_for(@user)
48
+ subscription.thread.must_equal @thread
49
+ subscription.subscriber.must_equal @user
50
+ subscription = @thread.subscription_for(user2)
51
+ subscription.thread.must_equal @thread
52
+ subscription.subscriber.must_equal user2
53
+ end
54
+
55
+ it 'must know if it is closed' do
56
+ @thread.is_closed?.must_equal false
57
+
58
+ @thread.close(@user)
59
+
60
+ @thread.is_closed?.must_equal true
61
+ @thread.closer.must_equal @user
62
+
63
+ @thread.reopen
64
+
65
+ @thread.is_closed?.must_equal false
66
+ end
67
+
68
+ it 'must know if an user is subscribed' do
69
+ @thread.subscribe(@user)
70
+ user2 = DummyUser.create
71
+
72
+ @thread.subscribe(user2)
73
+
74
+ @thread.is_subscribed?(@user).must_equal true
75
+ @thread.is_subscribed?(user2).must_equal true
76
+ @thread.is_subscribed?(DummyUser.create).must_equal false
77
+
78
+ @thread.unsubscribe(@user)
79
+
80
+ @thread.is_subscribed?(@user).must_equal false
81
+ @thread.is_subscribed?(user2).must_equal true
82
+ @thread.is_subscribed?(DummyUser.create).must_equal false
83
+ end
84
+
85
+ it 'must add unread comments and mark comments as read' do
86
+ @thread.subscribe(@user)
87
+ user2 = DummyUser.create
88
+ @thread.subscribe(user2)
89
+
90
+ @thread.subscription_for(@user).unread.must_equal 0
91
+ @thread.subscription_for(user2).unread.must_equal 0
92
+
93
+ @thread.add_unread_except_for(@user)
94
+ @thread.add_unread_except_for(user2)
95
+ @thread.add_unread_except_for(@user)
96
+
97
+ @thread.subscription_for(@user).unread.must_equal 1
98
+ @thread.subscription_for(user2).unread.must_equal 2
99
+
100
+ @thread.mark_as_read_for(user2)
101
+
102
+ @thread.subscription_for(@user).unread.must_equal 1
103
+ @thread.subscription_for(user2).unread.must_equal 0
104
+ end
105
+
106
+ it 'must be able to clear comments' do
107
+ comment = Comment.new
108
+ comment.thread = @thread
109
+ comment.creator = @user
110
+ comment.body = 'Something'
111
+ comment.save!
112
+
113
+ @thread.commontable.must_equal @commontable
114
+ @thread.comments.must_include comment
115
+ @thread.is_closed?.must_equal false
116
+ @commontable.thread.must_equal @thread
117
+
118
+ @thread.clear(@user)
119
+
120
+ @thread.commontable.must_be_nil
121
+ @thread.comments.must_include comment
122
+ @thread.is_closed?.must_equal true
123
+ @thread.closer.must_equal @user
124
+ @commontable.reload
125
+ @commontable.thread.wont_be_nil
126
+ @commontable.thread.wont_equal @thread
127
+ @commontable.thread.comments.wont_include comment
128
+ end
129
+ end
130
+ end