message_train 0.1.7 → 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/.simplecov +8 -0
- data/.travis.yml +7 -2
- data/Gemfile +3 -0
- data/README.rdoc +37 -1
- data/Rakefile +5 -6
- data/VERSION +1 -1
- data/app/assets/javascripts/message_train.js +33 -0
- data/app/assets/stylesheets/message_train.scss +26 -0
- data/app/controllers/concerns/message_train_support.rb +127 -0
- data/app/controllers/message_train/application_controller.rb +1 -60
- data/app/controllers/message_train/boxes_controller.rb +0 -4
- data/app/controllers/message_train/messages_controller.rb +12 -6
- data/app/controllers/message_train/participants_controller.rb +1 -1
- data/app/controllers/message_train/unsubscribes_controller.rb +59 -0
- data/app/helpers/message_train/application_helper.rb +26 -0
- data/app/helpers/message_train/attachments_helper.rb +19 -0
- data/app/helpers/message_train/boxes_helper.rb +16 -11
- data/app/helpers/message_train/collectives_helper.rb +48 -0
- data/app/helpers/message_train/conversations_helper.rb +24 -16
- data/app/helpers/message_train/messages_helper.rb +14 -12
- data/app/mailers/message_train/application_mailer.rb +8 -0
- data/app/mailers/message_train/previews/receipt_mailer_preview.rb +10 -0
- data/app/mailers/message_train/receipt_mailer.rb +17 -0
- data/app/models/message_train/attachment.rb +28 -10
- data/app/models/message_train/box.rb +114 -83
- data/app/models/message_train/conversation.rb +48 -39
- data/app/models/message_train/ignore.rb +2 -6
- data/app/models/message_train/message.rb +40 -24
- data/app/models/message_train/receipt.rb +20 -10
- data/app/models/message_train/unsubscribe.rb +7 -0
- data/app/views/layouts/mailer.html.haml +6 -0
- data/app/views/message_train/application/_attachment_fields.html.haml +7 -0
- data/app/views/message_train/application/_attachment_link.html.haml +4 -0
- data/app/views/message_train/application/_widget.html.haml +6 -0
- data/app/views/message_train/boxes/_dropdown_list.html.haml +1 -2
- data/app/views/message_train/boxes/_list_item.html.haml +2 -2
- data/app/views/message_train/boxes/_widget.html.haml +4 -1
- data/app/views/message_train/boxes/show.html.haml +12 -4
- data/app/views/message_train/collectives/_dropdown_list.html.haml +6 -0
- data/app/views/message_train/collectives/_list_item.html.haml +5 -0
- data/app/views/message_train/collectives/_widget.html.haml +7 -0
- data/app/views/message_train/conversations/_conversation.html.haml +22 -7
- data/app/views/message_train/conversations/_deleted_toggle.html.haml +1 -1
- data/app/views/message_train/conversations/_ignored_toggle.html.haml +3 -3
- data/app/views/message_train/conversations/_read_toggle.html.haml +3 -3
- data/app/views/message_train/conversations/_toggle.html.haml +4 -1
- data/app/views/message_train/conversations/_trashed_toggle.html.haml +3 -3
- data/app/views/message_train/conversations/show.html.haml +4 -3
- data/app/views/message_train/messages/_deleted_toggle.html.haml +1 -1
- data/app/views/message_train/messages/_form.html.haml +22 -7
- data/app/views/message_train/messages/_message.html.haml +14 -4
- data/app/views/message_train/messages/_read_toggle.html.haml +1 -1
- data/app/views/message_train/messages/_trashed_toggle.html.haml +1 -1
- data/app/views/message_train/messages/edit.html.haml +1 -1
- data/app/views/message_train/messages/new.html.haml +4 -1
- data/app/views/message_train/participants/_field.html.haml +1 -1
- data/app/views/message_train/participants/_prefilled_field.html.haml +4 -0
- data/app/views/message_train/receipt_mailer/notification_email.html.haml +13 -0
- data/app/views/message_train/unsubscribes/index.html.haml +10 -0
- data/config/environment.rb +1 -0
- data/config/locales/en.yml +49 -7
- data/config/routes.rb +10 -2
- data/db/migrate/20150901183458_add_received_through_to_message_train_receipts.rb +6 -0
- data/db/migrate/20151004184347_add_unique_index_to_receipts.rb +5 -0
- data/db/migrate/20151124000820_create_message_train_unsubscribes.rb +14 -0
- data/lib/generators/message_train/install/install_generator.rb +8 -2
- data/lib/generators/message_train/install/templates/initializer.rb +5 -1
- data/lib/message_train/configuration.rb +11 -1
- data/lib/message_train/engine.rb +1 -0
- data/lib/message_train/mixin.rb +206 -21
- data/message_train.gemspec +66 -13
- data/spec/controllers/message_train/boxes_controller_spec.rb +10 -3
- data/spec/controllers/message_train/concerns_spec.rb +40 -0
- data/spec/controllers/message_train/conversations_controller_spec.rb +3 -3
- data/spec/controllers/message_train/messages_controller_spec.rb +60 -27
- data/spec/controllers/message_train/participants_controller_spec.rb +41 -6
- data/spec/controllers/message_train/unsubscribes_controller_spec.rb +56 -0
- data/spec/dummy/app/assets/files/message_train/attachments/{1917-Boys_Race_Above-Wiki.jpg → image-sample.jpg} +0 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/models/group.rb +16 -1
- data/spec/dummy/app/models/role.rb +22 -0
- data/spec/dummy/app/models/user.rb +1 -1
- data/spec/dummy/app/views/layouts/_top_navigation.html.haml +4 -2
- data/spec/dummy/app/views/layouts/application.html.haml +2 -3
- data/spec/dummy/app/views/pages/index.html.haml +4 -0
- data/spec/dummy/config/application.rb +6 -0
- data/spec/dummy/config/environments/development.rb +1 -0
- data/spec/dummy/config/environments/test.rb +1 -0
- data/spec/dummy/config/initializers/high_voltage.rb +3 -0
- data/spec/dummy/config/initializers/message_train.rb +6 -1
- data/spec/dummy/config/initializers/paperclip.rb +2 -2
- data/spec/dummy/config/routes.rb +2 -2
- data/spec/dummy/config/settings.yml +9 -0
- data/spec/dummy/db/migrate/{20150724142846_create_message_train_conversations.night_train.rb → 20150901183629_create_message_train_conversations.message_train.rb} +0 -0
- data/spec/dummy/db/migrate/{20150724142847_create_message_train_messages.night_train.rb → 20150901183630_create_message_train_messages.message_train.rb} +0 -0
- data/spec/dummy/db/migrate/{20150724142848_create_message_train_attachments.night_train.rb → 20150901183631_create_message_train_attachments.message_train.rb} +0 -0
- data/spec/dummy/db/migrate/{20150724142849_create_message_train_receipts.night_train.rb → 20150901183632_create_message_train_receipts.message_train.rb} +0 -0
- data/spec/dummy/db/migrate/{20150724142850_create_message_train_ignores.night_train.rb → 20150901183633_create_message_train_ignores.message_train.rb} +0 -0
- data/spec/dummy/db/migrate/20150901183634_add_received_through_to_message_train_receipts.message_train.rb +7 -0
- data/spec/dummy/db/migrate/20151004184519_add_unique_index_to_receipts.message_train.rb +6 -0
- data/spec/dummy/db/migrate/20151124001417_create_message_train_unsubscribes.message_train.rb +15 -0
- data/spec/dummy/db/schema.rb +24 -7
- data/spec/dummy/db/seeds/conversations.seeds.rb +92 -3
- data/spec/dummy/db/seeds/groups.seeds.rb +27 -0
- data/spec/dummy/db/seeds/test/attachments.seeds.rb +4 -0
- data/spec/dummy/db/seeds/unsubscribes.seeds.rb +12 -0
- data/spec/dummy/db/seeds/users.seeds.rb +27 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/factories/group.rb +4 -4
- data/spec/factories/message.rb +10 -3
- data/spec/features/boxes_spec.rb +160 -33
- data/spec/features/conversations_spec.rb +11 -4
- data/spec/features/messages_spec.rb +20 -6
- data/spec/features/unsubscribes_spec.rb +38 -0
- data/spec/helpers/message_train/application_helper_spec.rb +60 -0
- data/spec/helpers/message_train/attachment_helper_spec.rb +35 -0
- data/spec/helpers/message_train/boxes_helper_spec.rb +11 -5
- data/spec/helpers/message_train/collectives_helper_spec.rb +76 -0
- data/spec/helpers/message_train/conversations_helper_spec.rb +295 -0
- data/spec/helpers/message_train/messages_helper_spec.rb +217 -0
- data/spec/models/group_spec.rb +112 -2
- data/spec/models/message_train/attachment_spec.rb +44 -1
- data/spec/models/message_train/box_spec.rb +306 -51
- data/spec/models/message_train/conversation_spec.rb +84 -6
- data/spec/models/message_train/ignore_spec.rb +0 -4
- data/spec/models/message_train/message_spec.rb +49 -12
- data/spec/models/message_train/receipt_spec.rb +44 -8
- data/spec/models/message_train/unsubscribe_spec.rb +16 -0
- data/spec/models/role_spec.rb +125 -0
- data/spec/models/user_spec.rb +155 -26
- data/spec/rails_helper.rb +8 -1
- data/spec/support/attachments.rb +4 -0
- data/spec/support/controller_behaviors.rb +28 -0
- data/spec/support/conversations.rb +13 -0
- data/spec/support/groups.rb +3 -0
- data/spec/support/loaded_site.rb +3 -0
- data/spec/support/messages.rb +23 -0
- data/spec/support/roles.rb +4 -0
- data/spec/support/users.rb +6 -0
- data/spec/support/wysihtml5_helper.rb +8 -0
- metadata +99 -12
- data/spec/dummy/app/assets/files/message_train/attachments/Haie_rci.svg +0 -1714
- data/spec/dummy/public/capybara.html +0 -193
data/spec/features/boxes_spec.rb
CHANGED
@@ -2,47 +2,174 @@ require 'rails_helper'
|
|
2
2
|
RSpec.feature 'Boxes' do
|
3
3
|
include_context 'loaded site'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
describe 'Showing' do
|
9
|
-
describe 'at /box/in' do
|
10
|
-
before do
|
11
|
-
visit '/box/in'
|
12
|
-
end
|
13
|
-
it_behaves_like 'a bootstrap page listing a collection of items', MessageTrain::Conversation, plural_title: 'Inbox', minimum: 2
|
5
|
+
describe 'When logged in as first-user' do
|
6
|
+
before do
|
7
|
+
login_as first_user
|
14
8
|
end
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
before do
|
20
|
-
visit '/box/in'
|
21
|
-
click_button 'Mark'
|
22
|
-
click_link 'mark-read'
|
23
|
-
end
|
24
|
-
it_behaves_like 'a bootstrap page with an alert', 'warning', 'Nothing to do'
|
25
|
-
end
|
26
|
-
describe 'after checking a box' do
|
27
|
-
describe 'Marking Read' do
|
9
|
+
describe 'Without a collective' do
|
10
|
+
|
11
|
+
describe 'Showing' do
|
12
|
+
describe 'at /box/in' do
|
28
13
|
before do
|
29
14
|
visit '/box/in'
|
30
15
|
click_link 'Last'
|
31
|
-
check "objects_conversations_#{unread_conversation.id.to_s}"
|
32
|
-
click_button 'Mark'
|
33
|
-
click_link 'mark-read'
|
34
16
|
end
|
35
|
-
it_behaves_like 'a bootstrap page
|
17
|
+
it_behaves_like 'a bootstrap page listing a collection of items', MessageTrain::Conversation, plural_title: 'Inbox', minimum: 2
|
18
|
+
|
19
|
+
describe 'does not list Roles dropdown' do
|
20
|
+
subject { page }
|
21
|
+
it { should_not have_css('li.dropdown a.dropdown-toggle', text: 'Roles') }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'shows the attachment icon on the correct conversation' do
|
25
|
+
before do
|
26
|
+
if page.has_no_css?("#message_train_conversation_#{attachment_conversation.id.to_s}")
|
27
|
+
click_link 'Prev'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
subject { page }
|
31
|
+
it { should have_css("#message_train_conversation_#{attachment_conversation.id.to_s} .glyphicon-paperclip")}
|
32
|
+
end
|
33
|
+
|
34
|
+
describe 'shows a link to compose' do
|
35
|
+
before do
|
36
|
+
within ".content" do
|
37
|
+
find('.compose').click
|
38
|
+
end
|
39
|
+
end
|
40
|
+
it_behaves_like 'a bootstrap page', title: 'New Message'
|
41
|
+
end
|
36
42
|
end
|
37
|
-
|
43
|
+
end
|
44
|
+
|
45
|
+
describe 'Marking', js: true do
|
46
|
+
describe 'at /box/in' do
|
47
|
+
describe 'using the buttons on each conversation' do
|
48
|
+
before do
|
49
|
+
visit '/box/in'
|
50
|
+
click_link 'Last'
|
51
|
+
find("#message_train_conversation_#{unread_conversation.id.to_s}").hover
|
52
|
+
within "#message_train_conversation_#{unread_conversation.id.to_s}" do
|
53
|
+
accept_confirm do
|
54
|
+
find('.trash-toggle').click
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
it_behaves_like 'a bootstrap page with an alert', 'info', 'Update successful'
|
59
|
+
end
|
60
|
+
describe 'without checking anything' do
|
61
|
+
before do
|
62
|
+
visit '/box/in'
|
63
|
+
click_button 'Mark'
|
64
|
+
click_link 'mark-read'
|
65
|
+
end
|
66
|
+
it_behaves_like 'a bootstrap page with an alert', 'warning', 'Nothing to do'
|
67
|
+
end
|
68
|
+
describe 'after checking a box' do
|
69
|
+
describe 'Marking Read' do
|
70
|
+
before do
|
71
|
+
visit '/box/in'
|
72
|
+
click_link 'Last'
|
73
|
+
check "objects_conversations_#{unread_conversation.id.to_s}"
|
74
|
+
click_button 'Mark'
|
75
|
+
click_link 'mark-read'
|
76
|
+
end
|
77
|
+
it_behaves_like 'a bootstrap page with an alert', 'info', 'Update successful'
|
78
|
+
end
|
79
|
+
describe 'Marking Ignored' do
|
80
|
+
before do
|
81
|
+
visit '/box/in'
|
82
|
+
click_link 'Last'
|
83
|
+
check "objects_conversations_#{unread_conversation.id.to_s}"
|
84
|
+
click_button 'Mark'
|
85
|
+
click_link 'mark-ignored'
|
86
|
+
end
|
87
|
+
it_behaves_like 'a bootstrap page with an alert', 'info', 'Update successful'
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe 'Within a collective' do
|
96
|
+
|
97
|
+
describe 'Showing' do
|
98
|
+
describe 'at /collectives/groups:membered-group/box/in' do
|
38
99
|
before do
|
39
|
-
visit '/box/in'
|
40
|
-
click_link 'Last'
|
41
|
-
check "objects_conversations_#{unread_conversation.id.to_s}"
|
42
|
-
click_button 'Mark'
|
43
|
-
click_link 'mark-ignored'
|
100
|
+
visit '/collectives/groups:membered-group/box/in'
|
44
101
|
end
|
45
|
-
it_behaves_like 'a bootstrap page
|
102
|
+
it_behaves_like 'a bootstrap page listing a collection of items', MessageTrain::Conversation, plural_title: 'Inbox', minimum: 1
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe 'Marking', js: true do
|
107
|
+
describe 'at /collectives/groups:membered-group/box/in' do
|
108
|
+
describe 'without checking anything' do
|
109
|
+
before do
|
110
|
+
visit '/collectives/groups:membered-group/box/in'
|
111
|
+
click_button 'Mark'
|
112
|
+
click_link 'mark-read'
|
113
|
+
end
|
114
|
+
it_behaves_like 'a bootstrap page with an alert', 'warning', 'Nothing to do'
|
115
|
+
end
|
116
|
+
describe 'after checking a box' do
|
117
|
+
describe 'Marking Read' do
|
118
|
+
before do
|
119
|
+
visit '/collectives/groups:membered-group/box/in'
|
120
|
+
check "objects_conversations_#{membered_group_conversation.id.to_s}"
|
121
|
+
click_button 'Mark'
|
122
|
+
click_link 'mark-read'
|
123
|
+
end
|
124
|
+
it_behaves_like 'a bootstrap page with an alert', 'info', 'Update successful'
|
125
|
+
end
|
126
|
+
describe 'Marking Ignored' do
|
127
|
+
before do
|
128
|
+
visit '/collectives/groups:membered-group/box/in'
|
129
|
+
check "objects_conversations_#{membered_group_conversation.id.to_s}"
|
130
|
+
click_button 'Mark'
|
131
|
+
click_link 'mark-ignored'
|
132
|
+
end
|
133
|
+
it_behaves_like 'a bootstrap page with an alert', 'info', 'Update successful'
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
describe 'When logged in as admin-user' do
|
142
|
+
before do
|
143
|
+
login_as admin_user
|
144
|
+
end
|
145
|
+
|
146
|
+
describe 'Showing' do
|
147
|
+
describe 'at /box/in' do
|
148
|
+
before do
|
149
|
+
visit '/box/in'
|
150
|
+
end
|
151
|
+
|
152
|
+
describe 'lists Roles dropdown' do
|
153
|
+
subject { page }
|
154
|
+
it { should have_css('li.dropdown a.dropdown-toggle', text: 'Roles') }
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
describe 'When logged in as superadmin-user' do
|
160
|
+
before do
|
161
|
+
login_as superadmin_user
|
162
|
+
end
|
163
|
+
|
164
|
+
describe 'Showing' do
|
165
|
+
describe 'at /box/in' do
|
166
|
+
before do
|
167
|
+
visit '/box/in'
|
168
|
+
end
|
169
|
+
|
170
|
+
describe 'lists Roles dropdown' do
|
171
|
+
subject { page }
|
172
|
+
it { should have_css('li.dropdown a.dropdown-toggle', text: 'Roles') }
|
46
173
|
end
|
47
174
|
end
|
48
175
|
end
|
@@ -8,23 +8,30 @@ RSpec.feature 'Conversations' do
|
|
8
8
|
describe 'Showing' do
|
9
9
|
describe 'at /box/in/conversations/:id' do
|
10
10
|
before do
|
11
|
-
visit '/box/in/conversations/'+unread_conversation.id.to_s
|
11
|
+
visit '/box/in/conversations/' + unread_conversation.id.to_s
|
12
12
|
end
|
13
13
|
it_behaves_like 'a bootstrap page showing an item', MessageTrain::Conversation, 'Unread Conversation'
|
14
|
+
|
15
|
+
describe 'shows a reply link' do
|
16
|
+
before do
|
17
|
+
click_link 'Reply'
|
18
|
+
end
|
19
|
+
it_behaves_like 'a bootstrap page', title: 'Reply'
|
20
|
+
end
|
14
21
|
end
|
15
22
|
end
|
16
23
|
describe 'Marking', js: true do
|
17
24
|
describe 'at /box/in/conversations/:id' do
|
18
25
|
describe 'Marking Read' do
|
19
26
|
before do
|
20
|
-
visit '/box/in/conversations/'+unread_conversation.id.to_s
|
21
|
-
click_link "mark_read_#{
|
27
|
+
visit '/box/in/conversations/' + unread_conversation.id.to_s
|
28
|
+
click_link "mark_read_#{unread_message.id.to_s}"
|
22
29
|
end
|
23
30
|
it_behaves_like 'a bootstrap page with an alert', 'info', 'Update successful'
|
24
31
|
end
|
25
32
|
describe 'Marking Ignored' do
|
26
33
|
before do
|
27
|
-
visit '/box/in/conversations/'+unread_conversation.id.to_s
|
34
|
+
visit '/box/in/conversations/' + unread_conversation.id.to_s
|
28
35
|
accept_confirm do
|
29
36
|
click_link 'Mark as Ignored'
|
30
37
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
RSpec.feature 'Messages' do
|
3
3
|
include_context 'loaded site'
|
4
|
+
include Wysihtml5Helper
|
4
5
|
|
5
6
|
before do
|
6
7
|
login_as first_user
|
@@ -12,7 +13,7 @@ RSpec.feature 'Messages' do
|
|
12
13
|
recipient_input = find(:css, "#message_recipients_to_save_users .tags-input")
|
13
14
|
recipient_input.set("")
|
14
15
|
fill_in 'Subject', with: 'This is a draft.'
|
15
|
-
|
16
|
+
fill_in_html 'Body', with: 'This is the body.'
|
16
17
|
click_button 'Send'
|
17
18
|
end
|
18
19
|
it_behaves_like 'a bootstrap page with an alert', 'warning', 'Message saved as draft.'
|
@@ -23,11 +24,25 @@ RSpec.feature 'Messages' do
|
|
23
24
|
before do
|
24
25
|
visit '/box/in/messages/new/'
|
25
26
|
recipient_input = find(:css, "#message_recipients_to_save_users .tags-input")
|
26
|
-
recipient_input.set("sec")
|
27
|
+
recipient_input.set("sec") # Should auto-complete to second-user with the following two key-presses
|
27
28
|
recipient_input.native.send_keys :arrow_down
|
28
29
|
recipient_input.native.send_keys :return
|
29
30
|
fill_in 'Subject', with: 'This is the subject.'
|
30
|
-
|
31
|
+
fill_in_html 'Body', with: 'This is the body.'
|
32
|
+
click_link 'add-attachment'
|
33
|
+
click_link 'add-attachment'
|
34
|
+
click_link 'add-attachment'
|
35
|
+
within '#attachments .nested-fields:nth-child(1)' do
|
36
|
+
attach_file 'Attachment', File.absolute_path('./spec/dummy/app/assets/files/message_train/attachments/example.pdf')
|
37
|
+
end
|
38
|
+
within '#attachments .nested-fields:nth-child(2)' do
|
39
|
+
attach_file 'Attachment', File.absolute_path('./spec/dummy/app/assets/files/message_train/attachments/Bambisj.jpg')
|
40
|
+
end
|
41
|
+
within '#attachments .nested-fields:nth-child(3)' do
|
42
|
+
accept_confirm do
|
43
|
+
find('.remove_fields').click
|
44
|
+
end
|
45
|
+
end
|
31
46
|
click_button 'Send'
|
32
47
|
end
|
33
48
|
it_behaves_like 'a bootstrap page with an alert', 'info', 'Message sent.'
|
@@ -38,12 +53,11 @@ RSpec.feature 'Messages' do
|
|
38
53
|
before do
|
39
54
|
visit "/box/in/conversations/#{draft_conversation.id}"
|
40
55
|
recipient_input = find(:css, "#message_recipients_to_save_users .tags-input")
|
41
|
-
recipient_input.set("sec")
|
56
|
+
recipient_input.set("sec") # Should auto-complete to second-user with the following two key-presses
|
42
57
|
recipient_input.native.send_keys :arrow_down
|
43
58
|
recipient_input.native.send_keys :return
|
44
59
|
fill_in 'Subject', with: 'This is the subject.'
|
45
|
-
|
46
|
-
find(:css, "#message_draft").set(false)
|
60
|
+
fill_in_html 'Body', with: 'This is the body.'
|
47
61
|
click_button 'Send'
|
48
62
|
end
|
49
63
|
it_behaves_like 'a bootstrap page with an alert', 'info', 'Message sent.'
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
RSpec.feature 'Unsubscribes' do
|
3
|
+
include_context 'loaded site'
|
4
|
+
|
5
|
+
before do
|
6
|
+
login_as first_user
|
7
|
+
end
|
8
|
+
describe 'Index' do
|
9
|
+
describe 'at /unsubscribes' do
|
10
|
+
before do
|
11
|
+
visit '/unsubscribes'
|
12
|
+
end
|
13
|
+
it_behaves_like 'a bootstrap page', title: 'Manage Your Email Notifications'
|
14
|
+
context "displays a list of #subscriptions in .subscription" do
|
15
|
+
subject { page }
|
16
|
+
it { should have_css("#subscriptions .subscription", minimum: 3) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
describe 'Unsubscribing' do
|
21
|
+
describe 'at /unsubscribes' do
|
22
|
+
before do
|
23
|
+
visit '/unsubscribes'
|
24
|
+
find("#unsubscribe-group-#{membered_group.id.to_s}").click
|
25
|
+
end
|
26
|
+
it_behaves_like 'a bootstrap page with an alert', 'info', 'You are now unsubscribed from Membered Group, which means that you will not be notified by email of any messages received by that Group.'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
describe 'Removing an Unsubscribe' do
|
30
|
+
describe 'at /unsubscribes' do
|
31
|
+
before do
|
32
|
+
visit '/unsubscribes'
|
33
|
+
find("#remove-unsubscribe-#{unsubscribed_group.id.to_s}").click
|
34
|
+
end
|
35
|
+
it_behaves_like 'a bootstrap page with an alert', 'info', 'You are no longer unsubscribed from Unsubscribed Group, which means that you will now be notified by email of any messages received in that Group.'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe MessageTrain::ApplicationHelper do
|
4
|
+
include_context 'loaded site'
|
5
|
+
include ControllerMacros
|
6
|
+
helper MessageTrain::BoxesHelper
|
7
|
+
helper MessageTrain::CollectivesHelper
|
8
|
+
|
9
|
+
before do
|
10
|
+
login_user first_user
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#message_train_widget' do
|
14
|
+
context 'when @collective is nil' do
|
15
|
+
before do
|
16
|
+
assign(:collective, nil)
|
17
|
+
assign(:box_user, first_user)
|
18
|
+
helper.message_train_widget
|
19
|
+
end
|
20
|
+
subject { helper.render_widgets }
|
21
|
+
it { should have_tag 'h3', text: /Messages/ }
|
22
|
+
it { should have_tag 'ul', with: { class: 'list-group' } }
|
23
|
+
it { should have_tag 'li', with: { class: 'list-group-item' }, count: 6 }
|
24
|
+
end
|
25
|
+
context 'when @collective is set' do
|
26
|
+
before do
|
27
|
+
assign(:collective, membered_group)
|
28
|
+
assign(:box_user, first_user)
|
29
|
+
helper.message_train_widget
|
30
|
+
end
|
31
|
+
subject { helper.render_widgets }
|
32
|
+
it { should have_tag 'h3', text: /Membered Group Messages/ }
|
33
|
+
it { should have_tag 'ul', with: { class: 'list-group' } }
|
34
|
+
it { should have_tag 'li', with: { class: 'list-group-item' }, count: 4 }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#fuzzy_date' do
|
39
|
+
context 'when less than a minute ago' do
|
40
|
+
subject { helper.fuzzy_date(30.seconds.ago) }
|
41
|
+
it { should eq 'Just Now' }
|
42
|
+
end
|
43
|
+
context 'when less than an day ago' do
|
44
|
+
subject { helper.fuzzy_date(2.hours.ago) }
|
45
|
+
it { should eq 2.hours.ago.strftime('%l:%M %p') }
|
46
|
+
end
|
47
|
+
context 'when less than a week ago' do
|
48
|
+
subject { helper.fuzzy_date(2.days.ago) }
|
49
|
+
it { should eq 2.days.ago.strftime('%a %l:%M %p') }
|
50
|
+
end
|
51
|
+
context 'when less than a year ago' do
|
52
|
+
subject { helper.fuzzy_date(2.months.ago) }
|
53
|
+
it { should eq 2.months.ago.strftime('%b %-d') }
|
54
|
+
end
|
55
|
+
context 'when more than a year ago' do
|
56
|
+
subject { helper.fuzzy_date(2.years.ago) }
|
57
|
+
it { should eq 2.years.ago.strftime('%b %-d, %Y') }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe MessageTrain::AttachmentsHelper do
|
4
|
+
include_context 'loaded site'
|
5
|
+
|
6
|
+
describe '#attachment_icon' do
|
7
|
+
context 'when attachment is an image' do
|
8
|
+
subject { helper.attachment_icon(image_attachment) }
|
9
|
+
it { should have_tag :img, with: { src: image_attachment.attachment.url(:thumb) } }
|
10
|
+
end
|
11
|
+
context 'when attachment is a file' do
|
12
|
+
subject { helper.attachment_icon(pdf_attachment) }
|
13
|
+
it { should have_tag :span, with: { class: 'glyphicon-save-file' } }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#attachment_link' do
|
18
|
+
context 'when attachment is an image' do
|
19
|
+
subject { helper.attachment_link(image_attachment) }
|
20
|
+
it { should have_tag :a, with: {
|
21
|
+
href: '#',
|
22
|
+
class: 'thumbnail',
|
23
|
+
'data-toggle' => 'modal',
|
24
|
+
'data-target' => '#attachment_preview',
|
25
|
+
'data-src' => image_attachment.attachment.url(:large),
|
26
|
+
'data-original' => image_attachment.attachment.url(:original),
|
27
|
+
'data-text' => 'Click for Original'
|
28
|
+
} }
|
29
|
+
end
|
30
|
+
context 'when attachment is a file' do
|
31
|
+
subject { helper.attachment_link(pdf_attachment) }
|
32
|
+
it { should have_tag :a, with: { href: pdf_attachment.attachment.url, class: 'thumbnail' } }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -7,6 +7,7 @@ describe MessageTrain::BoxesHelper do
|
|
7
7
|
before do
|
8
8
|
login_user first_user
|
9
9
|
end
|
10
|
+
|
10
11
|
context '#box_nav_item' do
|
11
12
|
subject { helper.box_nav_item(first_user.box(:in)) }
|
12
13
|
it { should have_tag 'li', text: /Inbox/ }
|
@@ -20,16 +21,21 @@ describe MessageTrain::BoxesHelper do
|
|
20
21
|
end
|
21
22
|
|
22
23
|
context '#boxes_widget' do
|
23
|
-
subject { helper.boxes_widget }
|
24
|
+
subject { helper.boxes_widget(first_user) }
|
24
25
|
it { should have_tag 'h3', text: /Messages/ }
|
25
26
|
it { should have_tag 'ul', with: { class: 'list-group' } }
|
26
27
|
it { should have_tag 'li', with: { class: 'list-group-item' }, count: 6 }
|
27
28
|
end
|
28
29
|
|
29
|
-
|
30
|
-
subject { helper.boxes_dropdown_list }
|
31
|
-
it { should have_tag 'ul', with: { class: 'dropdown-menu' } }
|
32
|
-
it { should have_tag 'li',
|
30
|
+
describe '#boxes_dropdown_list' do
|
31
|
+
subject { helper.boxes_dropdown_list(first_user) }
|
32
|
+
it { should have_tag 'ul', with: { class: 'dropdown-menu' }, count: 1 }
|
33
|
+
it { should have_tag 'li', text: /^Inbox/ }
|
34
|
+
it { should have_tag 'li', text: /^Sent/ }
|
35
|
+
it { should have_tag 'li', text: /^All/ }
|
36
|
+
it { should have_tag 'li', text: /^Drafts/ }
|
37
|
+
it { should have_tag 'li', text: /^Trash/ }
|
38
|
+
it { should have_tag 'li', text: /^Ignored/ }
|
33
39
|
end
|
34
40
|
|
35
41
|
context '#box_participant_slug' do
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe MessageTrain::CollectivesHelper do
|
4
|
+
include_context 'loaded site'
|
5
|
+
include ControllerMacros
|
6
|
+
|
7
|
+
before do
|
8
|
+
login_user first_user
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#collective_boxes_widget' do
|
12
|
+
subject { helper.collective_boxes_widget(membered_group, first_user) }
|
13
|
+
it { should have_tag 'h3', text: /Membered Group Messages/ }
|
14
|
+
it { should have_tag 'ul', with: { class: 'list-group' } }
|
15
|
+
it { should have_tag 'li', with: { class: 'list-group-item' }, count: 4 }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#collective_nav_item' do
|
19
|
+
context 'when user is not allowed' do
|
20
|
+
subject { helper.collective_nav_item(first_group.box(:in, third_user), third_user) }
|
21
|
+
it { should be nil }
|
22
|
+
end
|
23
|
+
context 'when no messages are unread' do
|
24
|
+
subject { helper.collective_nav_item(first_group.box(:in, first_user), first_user) }
|
25
|
+
it { should have_tag 'li', text: /^First Group/ }
|
26
|
+
it { should_not have_tag 'span', with: { class: 'badge' } }
|
27
|
+
end
|
28
|
+
context 'when there are unread messages' do
|
29
|
+
subject { helper.collective_nav_item(membered_group.box(:in, first_user), first_user) }
|
30
|
+
it { should have_tag 'li', text: /^Membered Group/ }
|
31
|
+
it { should have_tag 'span', text: /[0-9]+/, with: { class: 'badge' } }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#collective_list_item' do
|
36
|
+
context 'when user is a valid sender and box is sent' do
|
37
|
+
subject { helper.collective_list_item(first_group.box(:sent, first_user)) }
|
38
|
+
it { should have_tag 'li', text: /^Sent/ }
|
39
|
+
it { should have_tag 'span', text: /[0-9]+/, with: { class: 'badge' } }
|
40
|
+
end
|
41
|
+
context 'when user is a valid recipient and box is in' do
|
42
|
+
subject { helper.collective_list_item(membered_group.box(:in, first_user)) }
|
43
|
+
it { should have_tag 'li', text: /^Inbox/ }
|
44
|
+
it { should have_tag 'span', text: /[0-9]+/, with: { class: 'badge' } }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#collective_boxes_dropdown_list' do
|
49
|
+
describe 'passed a regular user' do
|
50
|
+
subject { helper.collective_boxes_dropdown_list(first_user) }
|
51
|
+
it { should have_tag 'ul', with: { class: 'dropdown-menu' }, count: 1 } # Groups and Roles
|
52
|
+
it { should have_tag 'li', text: /^First Group/ }
|
53
|
+
it { should have_tag 'li', text: /^Membered Group/ }
|
54
|
+
end
|
55
|
+
describe 'passed an admin user' do
|
56
|
+
subject { helper.collective_boxes_dropdown_list(admin_user) }
|
57
|
+
it { should have_tag 'ul', with: { class: 'dropdown-menu' }, count: 1 } # Groups and Roles
|
58
|
+
it { should have_tag 'li', text: /^Admin/ }
|
59
|
+
end
|
60
|
+
describe 'passed a superadmin user' do
|
61
|
+
subject { helper.collective_boxes_dropdown_list(superadmin_user) }
|
62
|
+
it { should have_tag 'ul', with: { class: 'dropdown-menu' }, count: 1 } # Groups and Roles
|
63
|
+
it { should have_tag 'li', text: /^Admin/ }
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context '#collective_slug' do
|
68
|
+
subject { helper.collective_slug(first_group) }
|
69
|
+
it { should eq 'first-group' }
|
70
|
+
end
|
71
|
+
|
72
|
+
context '#collective_name' do
|
73
|
+
subject { helper.collective_name(first_group) }
|
74
|
+
it { should eq 'First Group' }
|
75
|
+
end
|
76
|
+
end
|