message_train 0.1.7 → 0.2.0
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.
- 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/models/user_spec.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
require 'rails_helper'
|
|
2
2
|
|
|
3
3
|
RSpec.describe User do
|
|
4
|
+
include_context 'loaded site'
|
|
4
5
|
|
|
5
6
|
describe 'Model' do
|
|
6
7
|
# Rolify Gem by extension
|
|
@@ -12,9 +13,67 @@ RSpec.describe User do
|
|
|
12
13
|
end
|
|
13
14
|
|
|
14
15
|
describe 'Scopes and Methods' do
|
|
15
|
-
|
|
16
|
+
|
|
17
|
+
describe '#box' do
|
|
18
|
+
describe 'with valid number of arguments' do
|
|
19
|
+
subject { first_user.box }
|
|
20
|
+
it { should be_a MessageTrain::Box }
|
|
21
|
+
its(:division) { should be :in }
|
|
22
|
+
its(:parent) { should be first_user }
|
|
23
|
+
its(:participant) { should be first_user }
|
|
24
|
+
end
|
|
25
|
+
describe 'with invalid number of arguments' do
|
|
26
|
+
it "should raise" do
|
|
27
|
+
expect{ first_user.box(:in, first_user, 'extra argument') }.to raise_error(RuntimeError, "Wrong number of arguments for User (expected 0..2, got 3)")
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
describe '#collective_boxes' do
|
|
33
|
+
describe 'with 0 arguments' do
|
|
34
|
+
subject { first_user.collective_boxes[:groups].collect { |x| x.parent } }
|
|
35
|
+
it { should include membered_group }
|
|
36
|
+
it { should include first_group }
|
|
37
|
+
end
|
|
38
|
+
describe 'with 1 argument' do
|
|
39
|
+
subject { first_user.collective_boxes(:in)[:groups].collect { |x| x.parent } }
|
|
40
|
+
it { should include membered_group }
|
|
41
|
+
it { should include first_group }
|
|
42
|
+
end
|
|
43
|
+
describe 'with 3 arguments' do
|
|
44
|
+
it "should raise" do
|
|
45
|
+
expect{ first_user.collective_boxes(:in, first_user, 'extra argument') }.to raise_error(RuntimeError, "Wrong number of arguments for User (expected 0..2, got 3)")
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
describe '#all_boxes' do
|
|
51
|
+
describe 'with 0 arguments' do
|
|
52
|
+
context 'returns all boxes for the given user' do
|
|
53
|
+
subject { first_user.all_boxes }
|
|
54
|
+
its(:first) { should be_a MessageTrain::Box }
|
|
55
|
+
its(:count) { should be 6 }
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
describe 'with 1 argument' do
|
|
59
|
+
context 'returns all boxes for the given user' do
|
|
60
|
+
subject { first_user.all_boxes(first_user) }
|
|
61
|
+
its(:first) { should be_a MessageTrain::Box }
|
|
62
|
+
its(:count) { should be 6 }
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
describe 'with 2 arguments' do
|
|
66
|
+
it "should raise" do
|
|
67
|
+
expect{ first_user.all_boxes(first_user, 'extra argument') }.to raise_error(RuntimeError, "Wrong number of arguments for User (expected 0..1, got 2)")
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
16
71
|
|
|
17
72
|
describe '#conversations' do
|
|
73
|
+
context 'with division not set' do
|
|
74
|
+
subject { first_user.conversations.first.includes_receipts_to?(first_user) }
|
|
75
|
+
it { should be true }
|
|
76
|
+
end
|
|
18
77
|
context 'with division as :in' do
|
|
19
78
|
subject { first_user.conversations(:in).first.includes_receipts_to?(first_user) }
|
|
20
79
|
it { should be true }
|
|
@@ -27,42 +86,112 @@ RSpec.describe User do
|
|
|
27
86
|
subject { first_user.conversations(:trash).first.includes_trashed_for?(first_user) }
|
|
28
87
|
it { should be true}
|
|
29
88
|
end
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
89
|
+
describe 'with 23 arguments' do
|
|
90
|
+
it "should raise" do
|
|
91
|
+
expect{ first_user.conversations(:in, first_user, 'extra argument') }.to raise_error(RuntimeError, "Wrong number of arguments for User (expected 0..2, got 3)")
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
context 'with impossible division' do
|
|
95
|
+
subject { first_user.conversations(:impossible).nil? }
|
|
96
|
+
it { should be true}
|
|
37
97
|
end
|
|
38
98
|
end
|
|
39
99
|
|
|
40
100
|
describe '#all_conversations' do
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
101
|
+
describe 'with no arguments' do
|
|
102
|
+
context 'returns all conversations with any receipt' do
|
|
103
|
+
subject { first_user.all_conversations }
|
|
104
|
+
it { should include sent_conversation }
|
|
105
|
+
it { should include unread_conversation }
|
|
106
|
+
it { should include read_conversation }
|
|
107
|
+
it { should include ignored_conversation }
|
|
108
|
+
it { should include trashed_conversation }
|
|
109
|
+
it { should include deleted_conversation }
|
|
110
|
+
it { should_not include someone_elses_conversation }
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
describe 'with 1 argument' do
|
|
114
|
+
context 'returns all conversations with any receipt' do
|
|
115
|
+
subject { first_user.all_conversations(first_user) }
|
|
116
|
+
it { should include sent_conversation }
|
|
117
|
+
it { should include unread_conversation }
|
|
118
|
+
it { should include read_conversation }
|
|
119
|
+
it { should include ignored_conversation }
|
|
120
|
+
it { should include trashed_conversation }
|
|
121
|
+
it { should include deleted_conversation }
|
|
122
|
+
it { should_not include someone_elses_conversation }
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
describe 'with 2 arguments' do
|
|
126
|
+
it "should raise" do
|
|
127
|
+
expect{ first_user.all_conversations(first_user, 'extra argument') }.to raise_error(RuntimeError, "Wrong number of arguments for User (expected 0..1, got 2)")
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
context 'when empty' do
|
|
131
|
+
subject { silent_user.all_conversations }
|
|
132
|
+
it { should eq [] }
|
|
50
133
|
end
|
|
51
134
|
end
|
|
52
135
|
|
|
53
136
|
describe '#all_messages' do
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
137
|
+
describe 'with no arguments' do
|
|
138
|
+
context 'returns all messages with any receipt' do
|
|
139
|
+
subject { first_user.all_messages }
|
|
140
|
+
it { should include sent_message }
|
|
141
|
+
it { should include unread_message }
|
|
142
|
+
it { should include read_message }
|
|
143
|
+
it { should include ignored_message }
|
|
144
|
+
it { should include trashed_message }
|
|
145
|
+
it { should include deleted_message }
|
|
146
|
+
it { should_not include someone_elses_message }
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
describe 'with 1 argument' do
|
|
150
|
+
context 'returns all messages with any receipt' do
|
|
151
|
+
subject { first_user.all_messages(first_user) }
|
|
152
|
+
it { should include sent_message }
|
|
153
|
+
it { should include unread_message }
|
|
154
|
+
it { should include read_message }
|
|
155
|
+
it { should include ignored_message }
|
|
156
|
+
it { should include trashed_message }
|
|
157
|
+
it { should include deleted_message }
|
|
158
|
+
it { should_not include someone_elses_message }
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
describe 'with 2 arguments' do
|
|
162
|
+
it "should raise" do
|
|
163
|
+
expect{ first_user.all_messages(first_user, 'extra argument') }.to raise_error(RuntimeError, "Wrong number of arguments for User (expected 0..1, got 2)")
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
context 'when empty' do
|
|
167
|
+
subject { silent_user.all_messages }
|
|
168
|
+
it { should eq [] }
|
|
63
169
|
end
|
|
64
170
|
end
|
|
65
171
|
|
|
172
|
+
describe '#unsubscribed_from?' do
|
|
173
|
+
describe 'when an unsubscribe exists' do
|
|
174
|
+
subject { unsubscribed_user.unsubscribed_from?(membered_group) }
|
|
175
|
+
it { should be true }
|
|
176
|
+
end
|
|
177
|
+
describe 'when no unsubscribe exists' do
|
|
178
|
+
subject { first_user.unsubscribed_from?(membered_group) }
|
|
179
|
+
it { should be false }
|
|
180
|
+
end
|
|
181
|
+
describe 'when unsubscribe_from is used' do
|
|
182
|
+
before do
|
|
183
|
+
first_user.unsubscribe_from(membered_group)
|
|
184
|
+
end
|
|
185
|
+
subject { first_user.unsubscribed_from?(membered_group) }
|
|
186
|
+
it { should be true }
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
describe '#subscriptions' do
|
|
191
|
+
subject { first_user.subscriptions }
|
|
192
|
+
it { should be_an Array }
|
|
193
|
+
it { should have_at_least(3).items }
|
|
194
|
+
end
|
|
66
195
|
end
|
|
67
196
|
|
|
68
197
|
end
|
data/spec/rails_helper.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require 'coveralls'
|
|
2
2
|
Coveralls.wear!
|
|
3
|
+
|
|
3
4
|
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
|
4
5
|
ENV['RAILS_ENV'] ||= 'test'
|
|
5
6
|
require File.expand_path('../dummy/config/environment', __FILE__)
|
|
@@ -10,6 +11,7 @@ require 'rspec/rails'
|
|
|
10
11
|
# Add additional requires below this line. Rails is not loaded until this point!
|
|
11
12
|
require 'shoulda/matchers'
|
|
12
13
|
require 'factory_girl_rails'
|
|
14
|
+
require 'paperclip/matchers'
|
|
13
15
|
require 'capybara/rspec'
|
|
14
16
|
require 'database_cleaner'
|
|
15
17
|
require 'rake'
|
|
@@ -27,7 +29,7 @@ require 'rake'
|
|
|
27
29
|
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
|
28
30
|
# require only the support files necessary.
|
|
29
31
|
#
|
|
30
|
-
Dir[
|
|
32
|
+
Dir[MessageTrain::Engine.root.join('spec/support/**/*.rb')].each { |f| require f }
|
|
31
33
|
|
|
32
34
|
# Checks for pending migrations before tests are run.
|
|
33
35
|
# If you are not using ActiveRecord, you can remove this line.
|
|
@@ -80,4 +82,9 @@ RSpec.configure do |config|
|
|
|
80
82
|
config.include Devise::TestHelpers, type: :helper
|
|
81
83
|
config.include Devise::TestHelpers, type: :routing
|
|
82
84
|
config.include RSpecHtmlMatchers
|
|
85
|
+
|
|
86
|
+
config.include Paperclip::Shoulda::Matchers
|
|
87
|
+
config.after(:suite) do
|
|
88
|
+
FileUtils.rm_rf(Dir["#{Rails.root}/public/system/test/*/*"])
|
|
89
|
+
end
|
|
83
90
|
end
|
|
@@ -34,6 +34,15 @@ end
|
|
|
34
34
|
shared_examples_for 'a redirect to sign in' do
|
|
35
35
|
it_behaves_like 'a redirect to', '/users/sign_in'
|
|
36
36
|
end
|
|
37
|
+
shared_examples_for 'a redirect with a message' do |path, options|
|
|
38
|
+
it_behaves_like 'a redirect matching', path
|
|
39
|
+
options.each do |key, value|
|
|
40
|
+
context "sets #{key.to_s} message" do
|
|
41
|
+
subject { flash[key] }
|
|
42
|
+
it { should eq value }
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
37
46
|
shared_examples_for 'an error response with message' do |message|
|
|
38
47
|
it_behaves_like 'an error response', :forbidden
|
|
39
48
|
context 'sets failure message' do
|
|
@@ -54,6 +63,15 @@ shared_examples_for 'a page with a message' do |options|
|
|
|
54
63
|
end
|
|
55
64
|
end
|
|
56
65
|
end
|
|
66
|
+
shared_examples_for 'a page with a message matching' do |options|
|
|
67
|
+
it_behaves_like 'a successful page'
|
|
68
|
+
options.each do |key, value|
|
|
69
|
+
context "sets #{key.to_s} message" do
|
|
70
|
+
subject { flash[key] }
|
|
71
|
+
it { should match value }
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
57
75
|
shared_examples_for 'a page with an error message' do |message|
|
|
58
76
|
it_behaves_like 'a page with a message', error: message
|
|
59
77
|
end
|
|
@@ -63,9 +81,19 @@ end
|
|
|
63
81
|
shared_examples_for 'a page with a notice message' do |message|
|
|
64
82
|
it_behaves_like 'a page with a message', notice: message
|
|
65
83
|
end
|
|
84
|
+
shared_examples_for 'a page with an error message matching' do |message|
|
|
85
|
+
it_behaves_like 'a page with a message matching', error: message
|
|
86
|
+
end
|
|
66
87
|
shared_examples_for 'a 403 Forbidden error' do
|
|
67
88
|
it_should_behave_like 'an error response with message', 'You are not authorized to access this page.'
|
|
68
89
|
end
|
|
90
|
+
shared_examples_for 'a redirect with error' do |path, message|
|
|
91
|
+
it_behaves_like 'a redirect to', path
|
|
92
|
+
context 'sets error' do
|
|
93
|
+
subject { flash[:error] }
|
|
94
|
+
it { should eq message }
|
|
95
|
+
end
|
|
96
|
+
end
|
|
69
97
|
shared_examples_for 'a redirect with notice' do |path, message|
|
|
70
98
|
it_behaves_like 'a redirect to', path
|
|
71
99
|
context 'sets notice' do
|
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
shared_context 'conversations' do
|
|
2
2
|
let(:sent_conversation) { MessageTrain::Conversation.find_by_subject('Sent Conversation') }
|
|
3
3
|
let(:unread_conversation) { MessageTrain::Conversation.find_by_subject('Unread Conversation') }
|
|
4
|
+
let(:to_many_conversation) { MessageTrain::Conversation.find_by_subject('To Many Conversation') }
|
|
4
5
|
let(:ignored_conversation) { MessageTrain::Conversation.find_by_subject('Ignored Conversation') }
|
|
5
6
|
let(:trashed_conversation) { MessageTrain::Conversation.find_by_subject('Trashed Conversation') }
|
|
6
7
|
let(:read_conversation) { MessageTrain::Conversation.find_by_subject('Read Conversation') }
|
|
8
|
+
let(:attachment_conversation) { MessageTrain::Conversation.find_by_subject('Attachment Conversation') }
|
|
7
9
|
let(:deleted_conversation) { MessageTrain::Conversation.find_by_subject('Deleted Conversation') }
|
|
10
|
+
let(:group_conversation) { MessageTrain::Conversation.find_by_subject('Group Announcement') }
|
|
11
|
+
let(:membered_group_conversation) { MessageTrain::Conversation.find_by_subject('Membered Group Announcement') }
|
|
12
|
+
let(:membered_group_trashed_conversation) { MessageTrain::Conversation.find_by_subject('Membered Group Trashed Conversation') }
|
|
13
|
+
let(:membered_group_read_conversation) { MessageTrain::Conversation.find_by_subject('Membered Group Read Conversation') }
|
|
14
|
+
let(:membered_group_ignored_conversation) { MessageTrain::Conversation.find_by_subject('Membered Group Ignored Conversation') }
|
|
15
|
+
let(:membered_group_deleted_conversation) { MessageTrain::Conversation.find_by_subject('Membered Group Deleted Conversation') }
|
|
16
|
+
let(:membered_group_draft) { MessageTrain::Conversation.find_by_subject('Membered Group Draft') }
|
|
17
|
+
let(:owned_group_draft) { MessageTrain::Conversation.find_by_subject('Owned Group Draft') }
|
|
8
18
|
let(:someone_elses_conversation) { MessageTrain::Conversation.find_by_subject("Someone Else's Conversation") }
|
|
9
19
|
let(:draft_conversation) { MessageTrain::Conversation.find_by_subject('This should turn into a draft')}
|
|
20
|
+
let(:long_conversation) { MessageTrain::Conversation.find_by_subject('Long Conversation')}
|
|
21
|
+
let(:role_conversation) { MessageTrain::Conversation.find_by_subject('Role Conversation')}
|
|
22
|
+
let(:role_draft) { MessageTrain::Conversation.find_by_subject('Role Draft')}
|
|
10
23
|
end
|
data/spec/support/groups.rb
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
shared_context 'groups' do
|
|
2
2
|
let(:first_group) { Group.find_by_title('First Group') }
|
|
3
|
+
let(:membered_group) { Group.find_by_title('Membered Group') }
|
|
4
|
+
let(:empty_group) { Group.find_by_title('Empty Group') }
|
|
5
|
+
let(:unsubscribed_group) { Group.find_by_title('Unsubscribed Group') }
|
|
3
6
|
end
|
data/spec/support/loaded_site.rb
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
shared_context 'messages' do
|
|
2
|
+
let(:sent_message) { sent_conversation.messages.first }
|
|
3
|
+
let(:unread_message) { unread_conversation.messages.first }
|
|
4
|
+
let(:to_many_message) { to_many_conversation.messages.first }
|
|
5
|
+
let(:ignored_message) { ignored_conversation.messages.first }
|
|
6
|
+
let(:trashed_message) { trashed_conversation.messages.first }
|
|
7
|
+
let(:read_message) { read_conversation.messages.first }
|
|
8
|
+
let(:attachment_message) { attachment_conversation.messages.first }
|
|
9
|
+
let(:deleted_message) { deleted_conversation.messages.first }
|
|
10
|
+
let(:group_message) { group_conversation.messages.first }
|
|
11
|
+
let(:membered_group_message) { membered_group_conversation.messages.first }
|
|
12
|
+
let(:membered_group_trashed_message) { membered_group_trashed_conversation.messages.first }
|
|
13
|
+
let(:membered_group_read_message) { membered_group_read_conversation.messages.first }
|
|
14
|
+
let(:membered_group_ignored_message) { membered_group_ignored_conversation.messages.first }
|
|
15
|
+
let(:membered_group_deleted_message) { membered_group_deleted_conversation.messages.first }
|
|
16
|
+
let(:membered_group_draft_message) { membered_group_draft.messages.first }
|
|
17
|
+
let(:owned_group_draft_message) { owned_group_draft.messages.first }
|
|
18
|
+
let(:someone_elses_message) { someone_elses_conversation.messages.first }
|
|
19
|
+
let(:draft_message) { draft_conversation.messages.first }
|
|
20
|
+
let(:long_message) { long_conversation.messages.first }
|
|
21
|
+
let(:role_message) { role_conversation.messages.first }
|
|
22
|
+
let(:role_draft_message) { role_draft.messages.first }
|
|
23
|
+
end
|
data/spec/support/users.rb
CHANGED
|
@@ -2,5 +2,11 @@ shared_context 'users' do
|
|
|
2
2
|
let(:first_user) { User.friendly.find('first-user') }
|
|
3
3
|
let(:second_user) { User.friendly.find('second-user') }
|
|
4
4
|
let(:third_user) { User.friendly.find('third-user') }
|
|
5
|
+
let(:fourth_user) { User.friendly.find('fourth-user') }
|
|
6
|
+
let(:fourth_user) { User.friendly.find('fourth-user') }
|
|
7
|
+
let(:superadmin_user) { User.friendly.find('superadmin-user') }
|
|
8
|
+
let(:admin_user) { User.friendly.find('admin-user') }
|
|
9
|
+
let(:silent_user) { User.friendly.find('silent-user') }
|
|
10
|
+
let(:unsubscribed_user) { User.friendly.find('unsubscribed-user') }
|
|
5
11
|
let(:last_user) { User.order('id').last }
|
|
6
12
|
end
|