message_train 0.5.2 → 0.5.3
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/.rubocop.yml +20 -0
- data/.ruby-gemset +1 -1
- data/.scss-lint.yml +7 -0
- data/.simplecov +1 -1
- data/.travis.yml +1 -1
- data/Gemfile +6 -2
- data/LICENSE.txt +2 -2
- data/README.rdoc +5 -5
- data/Rakefile +22 -21
- data/VERSION +1 -1
- data/app/assets/javascripts/message_train.js +1 -1
- data/app/assets/stylesheets/message_train.scss +29 -19
- data/app/controllers/concerns/message_train_support.rb +41 -37
- data/app/controllers/message_train/application_controller.rb +1 -0
- data/app/controllers/message_train/boxes_controller.rb +5 -4
- data/app/controllers/message_train/conversations_controller.rb +8 -7
- data/app/controllers/message_train/messages_controller.rb +25 -22
- data/app/controllers/message_train/participants_controller.rb +27 -23
- data/app/controllers/message_train/unsubscribes_controller.rb +37 -23
- data/app/helpers/message_train/application_helper.rb +6 -8
- data/app/helpers/message_train/attachments_helper.rb +12 -4
- data/app/helpers/message_train/boxes_helper.rb +38 -11
- data/app/helpers/message_train/collectives_helper.rb +38 -12
- data/app/helpers/message_train/conversations_helper.rb +43 -35
- data/app/helpers/message_train/messages_helper.rb +32 -25
- data/app/mailers/message_train/application_mailer.rb +7 -4
- data/app/mailers/message_train/previews/receipt_mailer_preview.rb +2 -3
- data/app/mailers/message_train/receipt_mailer.rb +14 -4
- data/app/models/message_train/attachment.rb +41 -25
- data/app/models/message_train/box.rb +159 -122
- data/app/models/message_train/conversation.rb +84 -41
- data/app/models/message_train/ignore.rb +8 -2
- data/app/models/message_train/message.rb +72 -42
- data/app/models/message_train/receipt.rb +30 -17
- data/app/models/message_train/unsubscribe.rb +1 -0
- data/app/views/application/404.html.haml +1 -1
- data/app/views/layouts/mailer.html.haml +2 -2
- data/app/views/layouts/mailer.text.haml +1 -1
- data/app/views/message_train/application/_attachment_fields.html.haml +1 -1
- data/app/views/message_train/application/_widget.html.haml +1 -1
- data/app/views/message_train/application/results.json.jbuilder +1 -1
- data/app/views/message_train/boxes/_dropdown_list.html.haml +1 -1
- data/app/views/message_train/boxes/_list_item.html.haml +1 -1
- data/app/views/message_train/boxes/show.html.haml +1 -1
- data/app/views/message_train/collectives/_dropdown_list.html.haml +1 -1
- data/app/views/message_train/collectives/_list_item.html.haml +1 -1
- data/app/views/message_train/conversations/_deleted_toggle.html.haml +1 -1
- data/app/views/message_train/conversations/_ignored_toggle.html.haml +2 -2
- data/app/views/message_train/conversations/_read_toggle.html.haml +1 -1
- data/app/views/message_train/conversations/_toggle.html.haml +1 -1
- data/app/views/message_train/conversations/_trashed_toggle.html.haml +1 -1
- data/app/views/message_train/conversations/show.html.haml +2 -2
- data/app/views/message_train/conversations/show.json.jbuilder +5 -1
- data/app/views/message_train/messages/_form.html.haml +1 -1
- data/app/views/message_train/messages/_message.html.haml +6 -6
- data/app/views/message_train/messages/_toggle.html.haml +1 -1
- data/app/views/message_train/messages/show.json.jbuilder +5 -1
- data/app/views/message_train/participants/_participant.json.jbuilder +1 -1
- data/app/views/message_train/participants/index.json.jbuilder +1 -1
- data/app/views/message_train/participants/show.json.jbuilder +1 -1
- data/app/views/message_train/receipt_mailer/notification_email.html.haml +1 -1
- data/app/views/message_train/receipt_mailer/notification_email.text.haml +1 -1
- data/app/views/message_train/unsubscribes/index.html.haml +1 -1
- data/config/environment.rb +1 -1
- data/config/initializers/date_time.rb +2 -2
- data/config/locales/en.yml +1 -1
- data/config/routes.rb +37 -15
- data/lib/generators/message_train/install/install_generator.rb +26 -11
- data/lib/generators/message_train/install/templates/initializer.rb +0 -2
- data/lib/generators/message_train/utils.rb +11 -4
- data/lib/message_train/configuration.rb +4 -5
- data/lib/message_train/engine.rb +1 -7
- data/lib/message_train/localization.rb +14 -18
- data/lib/message_train/mixin.rb +211 -150
- data/lib/message_train/version.rb +1 -0
- data/lib/message_train.rb +7 -6
- data/message_train.gemspec +24 -11
- data/spec/controllers/message_train/boxes_controller_spec.rb +63 -15
- data/spec/controllers/message_train/concerns_spec.rb +17 -13
- data/spec/controllers/message_train/conversations_controller_spec.rb +44 -12
- data/spec/controllers/message_train/messages_controller_spec.rb +87 -40
- data/spec/controllers/message_train/participants_controller_spec.rb +10 -4
- data/spec/controllers/message_train/unsubscribes_controller_spec.rb +43 -13
- data/spec/dummy/Rakefile +2 -1
- data/spec/dummy/app/assets/stylesheets/application.css.scss +7 -23
- data/spec/dummy/app/controllers/application_controller.rb +7 -7
- data/spec/dummy/app/models/group.rb +1 -1
- data/spec/dummy/app/models/role.rb +11 -7
- data/spec/dummy/app/models/user.rb +6 -5
- data/spec/dummy/app/views/layouts/_top_navigation.html.haml +1 -1
- data/spec/dummy/app/views/layouts/application.html.haml +1 -1
- data/spec/dummy/app/views/pages/index.html.haml +1 -1
- data/spec/dummy/config/application.rb +23 -17
- data/spec/dummy/config/environments/development.rb +5 -4
- data/spec/dummy/config/environments/production.rb +10 -6
- data/spec/dummy/config/environments/test.rb +4 -3
- data/spec/dummy/config/initializers/assets.rb +2 -1
- data/spec/dummy/config/initializers/backtrace_silencers.rb +4 -2
- data/spec/dummy/config/initializers/bootstrap_leather.rb +1 -1
- data/spec/dummy/config/initializers/devise.rb +63 -44
- data/spec/dummy/config/initializers/high_voltage.rb +1 -1
- data/spec/dummy/config/initializers/message_train.rb +5 -2
- data/spec/dummy/config/initializers/mime_types.rb +1 -1
- data/spec/dummy/config/initializers/paperclip.rb +5 -2
- data/spec/dummy/config/initializers/rolify.rb +3 -2
- data/spec/dummy/config/initializers/wrap_parameters.rb +2 -1
- data/spec/dummy/config/routes.rb +1 -3
- data/spec/dummy/config/settings.yml +1 -1
- data/spec/dummy/db/schema.rb +98 -98
- data/spec/dummy/db/seeds/conversations.seeds.rb +160 -160
- data/spec/dummy/db/seeds/development/conversations.seeds.rb +6 -2
- data/spec/dummy/db/seeds/groups.seeds.rb +11 -12
- data/spec/dummy/db/seeds/test/attachments.seeds.rb +13 -3
- data/spec/dummy/db/seeds/test/conversations.seeds.rb +6 -2
- data/spec/dummy/db/seeds/unsubscribes.seeds.rb +1 -1
- data/spec/dummy/db/seeds/users.seeds.rb +47 -42
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/factories/attachment.rb +6 -2
- data/spec/factories/group.rb +1 -4
- data/spec/factories/message.rb +29 -23
- data/spec/factories/user.rb +6 -4
- data/spec/features/boxes_spec.rb +76 -24
- data/spec/features/conversations_spec.rb +19 -7
- data/spec/features/messages_spec.rb +24 -5
- data/spec/features/unsubscribes_spec.rb +36 -9
- data/spec/helpers/message_train/application_helper_spec.rb +1 -1
- data/spec/helpers/message_train/attachment_helper_spec.rb +27 -12
- data/spec/helpers/message_train/boxes_helper_spec.rb +1 -1
- data/spec/helpers/message_train/collectives_helper_spec.rb +25 -9
- data/spec/helpers/message_train/conversations_helper_spec.rb +239 -120
- data/spec/helpers/message_train/messages_helper_spec.rb +137 -81
- data/spec/message_train_spec.rb +3 -2
- data/spec/models/group_spec.rb +12 -9
- data/spec/models/message_train/attachment_spec.rb +33 -30
- data/spec/models/message_train/box_spec.rb +243 -60
- data/spec/models/message_train/conversation_spec.rb +16 -12
- data/spec/models/message_train/ignore_spec.rb +3 -1
- data/spec/models/message_train/message_spec.rb +22 -7
- data/spec/models/message_train/receipt_spec.rb +14 -4
- data/spec/models/role_spec.rb +10 -6
- data/spec/models/user_spec.rb +74 -22
- data/spec/rails_helper.rb +9 -4
- data/spec/spec_helper.rb +6 -54
- data/spec/support/controller_behaviors.rb +8 -5
- data/spec/support/controller_macros.rb +2 -2
- data/spec/support/factory_girl.rb +1 -1
- data/spec/support/feature_behaviors.rb +42 -13
- data/spec/support/loaded_site/attachments.rb +8 -0
- data/spec/support/loaded_site/conversations.rb +73 -0
- data/spec/support/{groups.rb → loaded_site/groups.rb} +1 -1
- data/spec/support/{loaded_site.rb → loaded_site/loaded_site.rb} +1 -1
- data/spec/support/{messages.rb → loaded_site/messages.rb} +13 -5
- data/spec/support/{roles.rb → loaded_site/roles.rb} +1 -1
- data/spec/support/{users.rb → loaded_site/users.rb} +1 -1
- data/spec/support/shared_connection.rb +8 -6
- data/spec/support/utilities.rb +10 -10
- metadata +67 -10
- data/spec/dummy/config/unused/temporary_i18n_debugging.rb +0 -12
- data/spec/support/attachments.rb +0 -4
- data/spec/support/conversations.rb +0 -23
@@ -18,19 +18,25 @@ module MessageTrain
|
|
18
18
|
context 'sets draft to true on a message to no one' do
|
19
19
|
subject { draft_conversation.messages.drafts.first }
|
20
20
|
its(:sender) { should eq first_user }
|
21
|
-
its(:receipts) { should have_exactly(1).item } #
|
21
|
+
its(:receipts) { should have_exactly(1).item } # sender
|
22
22
|
its(:recipients) { should be_empty }
|
23
23
|
its(:draft) { should be true }
|
24
24
|
end
|
25
25
|
context 'generates receipts when present' do
|
26
26
|
subject { sent_message }
|
27
27
|
its(:sender) { should eq first_user }
|
28
|
-
its(:receipts) { should have_exactly(2).items } #
|
28
|
+
its(:receipts) { should have_exactly(2).items } # sender and recipient
|
29
29
|
its(:recipients) { should include second_user }
|
30
30
|
its(:draft) { should be false }
|
31
31
|
end
|
32
32
|
context 'generates error when recipient_to_save does not exist' do
|
33
|
-
let(:message)
|
33
|
+
let(:message) do
|
34
|
+
first_user.box(:in).send_message(
|
35
|
+
subject: 'Message with missing recipient',
|
36
|
+
recipients_to_save: { 'users' => 'missing-user' },
|
37
|
+
body: 'Foo.'
|
38
|
+
)
|
39
|
+
end
|
34
40
|
subject { message.errors.full_messages.to_sentence }
|
35
41
|
it { should eq 'Recipient missing-user not found' }
|
36
42
|
end
|
@@ -62,7 +68,7 @@ module MessageTrain
|
|
62
68
|
describe '#missing_method' do
|
63
69
|
# Testing super on method_missing
|
64
70
|
it 'raises a NoMethodError' do
|
65
|
-
expect {unread_message.missing_method}.to raise_error(NoMethodError)
|
71
|
+
expect { unread_message.missing_method }.to raise_error(NoMethodError)
|
66
72
|
end
|
67
73
|
end
|
68
74
|
context '.with_receipts_by' do
|
@@ -74,15 +80,24 @@ module MessageTrain
|
|
74
80
|
it { should eq unread_message }
|
75
81
|
end
|
76
82
|
context '.with_trashed_to and #is_trashed_to?' do
|
77
|
-
subject
|
83
|
+
subject do
|
84
|
+
trashed_conversation.messages.with_trashed_to(first_user)
|
85
|
+
.first.is_trashed_to?(first_user)
|
86
|
+
end
|
78
87
|
it { should be true }
|
79
88
|
end
|
80
89
|
context '.with_deleted_to and #is_deleted_to?' do
|
81
|
-
subject
|
90
|
+
subject do
|
91
|
+
deleted_conversation.messages.with_deleted_to(first_user)
|
92
|
+
.first.is_deleted_to?(first_user)
|
93
|
+
end
|
82
94
|
it { should be true }
|
83
95
|
end
|
84
96
|
context '.with_read_to and #is_read_to?' do
|
85
|
-
subject
|
97
|
+
subject do
|
98
|
+
read_conversation.messages.with_read_to(first_user)
|
99
|
+
.first.is_read_to?(first_user)
|
100
|
+
end
|
86
101
|
it { should be true }
|
87
102
|
end
|
88
103
|
context '.mark' do
|
@@ -42,19 +42,29 @@ module MessageTrain
|
|
42
42
|
its(:count) { should be > 5 }
|
43
43
|
end
|
44
44
|
describe '.trashed_to' do
|
45
|
-
subject
|
45
|
+
subject do
|
46
|
+
MessageTrain::Receipt.trashed_to(first_user)
|
47
|
+
.first.message.conversation
|
48
|
+
end
|
46
49
|
its(:subject) { should eq 'Membered Group Trashed Conversation' }
|
47
50
|
end
|
48
51
|
describe '.untrashed_to' do
|
49
|
-
subject
|
52
|
+
subject do
|
53
|
+
MessageTrain::Receipt.untrashed_to(first_user).first
|
54
|
+
end
|
50
55
|
its(:marked_trash) { should be false }
|
51
56
|
end
|
52
57
|
describe '.read_to' do
|
53
|
-
subject
|
58
|
+
subject do
|
59
|
+
MessageTrain::Receipt.read_to(first_user).first.message.conversation
|
60
|
+
end
|
54
61
|
its(:subject) { should eq 'Membered Group Read Conversation' }
|
55
62
|
end
|
56
63
|
describe '.deleted_to' do
|
57
|
-
subject
|
64
|
+
subject do
|
65
|
+
MessageTrain::Receipt.deleted_to(first_user)
|
66
|
+
.first.message.conversation
|
67
|
+
end
|
58
68
|
its(:subject) { should eq 'Membered Group Deleted Conversation' }
|
59
69
|
end
|
60
70
|
describe '.undeleted_to' do
|
data/spec/models/role_spec.rb
CHANGED
@@ -67,7 +67,9 @@ RSpec.describe Role do
|
|
67
67
|
|
68
68
|
describe '#boxes_for_participant' do
|
69
69
|
context 'when participant is a valid sender' do
|
70
|
-
subject
|
70
|
+
subject do
|
71
|
+
admin_role.boxes_for_participant(superadmin_user).collect(&:division)
|
72
|
+
end
|
71
73
|
it { should_not include :in }
|
72
74
|
it { should include :sent }
|
73
75
|
it { should include :drafts }
|
@@ -76,7 +78,9 @@ RSpec.describe Role do
|
|
76
78
|
it { should_not include :ignored }
|
77
79
|
end
|
78
80
|
context 'when participant is a valid recipient' do
|
79
|
-
subject
|
81
|
+
subject do
|
82
|
+
admin_role.boxes_for_participant(admin_user).collect(&:division)
|
83
|
+
end
|
80
84
|
it { should include :in }
|
81
85
|
it { should_not include :sent }
|
82
86
|
it { should_not include :drafts }
|
@@ -92,7 +96,8 @@ RSpec.describe Role do
|
|
92
96
|
its(:first) { should be_a MessageTrain::Conversation }
|
93
97
|
it { should_not include unread_conversation }
|
94
98
|
it { should include role_conversation }
|
95
|
-
|
99
|
+
# Because received_through not set on sender receipts
|
100
|
+
it { should_not include role_draft }
|
96
101
|
end
|
97
102
|
context 'when participant is a valid recipient' do
|
98
103
|
subject { admin_role.all_conversations(admin_user) }
|
@@ -109,7 +114,8 @@ RSpec.describe Role do
|
|
109
114
|
its(:first) { should be_a MessageTrain::Message }
|
110
115
|
it { should_not include unread_message }
|
111
116
|
it { should include role_message }
|
112
|
-
|
117
|
+
# Because received_through not set on sender receipts
|
118
|
+
it { should_not include role_draft_message }
|
113
119
|
end
|
114
120
|
context 'when participant is a valid recipient' do
|
115
121
|
subject { admin_role.all_messages(admin_user) }
|
@@ -119,7 +125,5 @@ RSpec.describe Role do
|
|
119
125
|
it { should_not include role_draft_message }
|
120
126
|
end
|
121
127
|
end
|
122
|
-
|
123
128
|
end
|
124
|
-
|
125
129
|
end
|
data/spec/models/user_spec.rb
CHANGED
@@ -13,7 +13,6 @@ RSpec.describe User do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
describe 'Scopes and Methods' do
|
16
|
-
|
17
16
|
describe '#box' do
|
18
17
|
describe 'with valid number of arguments' do
|
19
18
|
subject { first_user.box }
|
@@ -23,26 +22,44 @@ RSpec.describe User do
|
|
23
22
|
its(:participant) { should be first_user }
|
24
23
|
end
|
25
24
|
describe 'with invalid number of arguments' do
|
26
|
-
it
|
27
|
-
expect
|
25
|
+
it 'should raise' do
|
26
|
+
expect do
|
27
|
+
first_user.box(:in, first_user, 'extra argument')
|
28
|
+
end.to(
|
29
|
+
raise_error(
|
30
|
+
RuntimeError,
|
31
|
+
'Wrong number of arguments for User (expected 0..2, got 3)'
|
32
|
+
)
|
33
|
+
)
|
28
34
|
end
|
29
35
|
end
|
30
36
|
end
|
31
37
|
|
32
38
|
describe '#collective_boxes' do
|
33
39
|
describe 'with 0 arguments' do
|
34
|
-
subject
|
40
|
+
subject do
|
41
|
+
first_user.collective_boxes[:groups].collect(&:parent)
|
42
|
+
end
|
35
43
|
it { should include membered_group }
|
36
44
|
it { should include first_group }
|
37
45
|
end
|
38
46
|
describe 'with 1 argument' do
|
39
|
-
subject
|
47
|
+
subject do
|
48
|
+
first_user.collective_boxes(:in)[:groups].collect(&:parent)
|
49
|
+
end
|
40
50
|
it { should include membered_group }
|
41
51
|
it { should include first_group }
|
42
52
|
end
|
43
53
|
describe 'with 3 arguments' do
|
44
|
-
it
|
45
|
-
expect
|
54
|
+
it 'should raise' do
|
55
|
+
expect do
|
56
|
+
first_user.collective_boxes(:in, first_user, 'extra argument')
|
57
|
+
end.to(
|
58
|
+
raise_error(
|
59
|
+
RuntimeError,
|
60
|
+
'Wrong number of arguments for User (expected 0..2, got 3)'
|
61
|
+
)
|
62
|
+
)
|
46
63
|
end
|
47
64
|
end
|
48
65
|
end
|
@@ -63,37 +80,61 @@ RSpec.describe User do
|
|
63
80
|
end
|
64
81
|
end
|
65
82
|
describe 'with 2 arguments' do
|
66
|
-
it
|
67
|
-
expect
|
83
|
+
it 'should raise' do
|
84
|
+
expect do
|
85
|
+
first_user.all_boxes(first_user, 'extra argument')
|
86
|
+
end.to(
|
87
|
+
raise_error(
|
88
|
+
RuntimeError,
|
89
|
+
'Wrong number of arguments for User (expected 0..1, got 2)'
|
90
|
+
)
|
91
|
+
)
|
68
92
|
end
|
69
93
|
end
|
70
94
|
end
|
71
95
|
|
72
96
|
describe '#conversations' do
|
73
97
|
context 'with division not set' do
|
74
|
-
subject
|
98
|
+
subject do
|
99
|
+
first_user.conversations.first.includes_receipts_to?(first_user)
|
100
|
+
end
|
75
101
|
it { should be true }
|
76
102
|
end
|
77
103
|
context 'with division as :in' do
|
78
|
-
subject
|
104
|
+
subject do
|
105
|
+
first_user.conversations(:in).first.includes_receipts_to?(first_user)
|
106
|
+
end
|
79
107
|
it { should be true }
|
80
108
|
end
|
81
109
|
context 'with division as :sent' do
|
82
|
-
subject
|
110
|
+
subject do
|
111
|
+
first_user.conversations(:sent)
|
112
|
+
.first.includes_receipts_by?(first_user)
|
113
|
+
end
|
83
114
|
it { should be true }
|
84
115
|
end
|
85
116
|
context 'with division as :trash' do
|
86
|
-
subject
|
87
|
-
|
117
|
+
subject do
|
118
|
+
first_user.conversations(:trash)
|
119
|
+
.first.includes_trashed_for?(first_user)
|
120
|
+
end
|
121
|
+
it { should be true }
|
88
122
|
end
|
89
123
|
describe 'with 23 arguments' do
|
90
|
-
it
|
91
|
-
expect
|
124
|
+
it 'should raise' do
|
125
|
+
expect do
|
126
|
+
first_user.conversations(:in, first_user, 'extra argument')
|
127
|
+
end.to(
|
128
|
+
raise_error(
|
129
|
+
RuntimeError,
|
130
|
+
'Wrong number of arguments for User (expected 0..2, got 3)'
|
131
|
+
)
|
132
|
+
)
|
92
133
|
end
|
93
134
|
end
|
94
135
|
context 'with impossible division' do
|
95
136
|
subject { first_user.conversations(:impossible).nil? }
|
96
|
-
it { should be true}
|
137
|
+
it { should be true }
|
97
138
|
end
|
98
139
|
end
|
99
140
|
|
@@ -123,8 +164,15 @@ RSpec.describe User do
|
|
123
164
|
end
|
124
165
|
end
|
125
166
|
describe 'with 2 arguments' do
|
126
|
-
it
|
127
|
-
expect
|
167
|
+
it 'should raise' do
|
168
|
+
expect do
|
169
|
+
first_user.all_conversations(first_user, 'extra argument')
|
170
|
+
end.to(
|
171
|
+
raise_error(
|
172
|
+
RuntimeError,
|
173
|
+
'Wrong number of arguments for User (expected 0..1, got 2)'
|
174
|
+
)
|
175
|
+
)
|
128
176
|
end
|
129
177
|
end
|
130
178
|
context 'when empty' do
|
@@ -159,8 +207,13 @@ RSpec.describe User do
|
|
159
207
|
end
|
160
208
|
end
|
161
209
|
describe 'with 2 arguments' do
|
162
|
-
it
|
163
|
-
expect{ first_user.all_messages(first_user, 'extra argument') }.to
|
210
|
+
it 'should raise' do
|
211
|
+
expect { first_user.all_messages(first_user, 'extra argument') }.to(
|
212
|
+
raise_error(
|
213
|
+
RuntimeError,
|
214
|
+
'Wrong number of arguments for User (expected 0..1, got 2)'
|
215
|
+
)
|
216
|
+
)
|
164
217
|
end
|
165
218
|
end
|
166
219
|
context 'when empty' do
|
@@ -193,5 +246,4 @@ RSpec.describe User do
|
|
193
246
|
it { should have_at_least(3).items }
|
194
247
|
end
|
195
248
|
end
|
196
|
-
|
197
249
|
end
|
data/spec/rails_helper.rb
CHANGED
@@ -5,7 +5,9 @@ Coveralls.wear!
|
|
5
5
|
ENV['RAILS_ENV'] ||= 'test'
|
6
6
|
require File.expand_path('../dummy/config/environment', __FILE__)
|
7
7
|
# Prevent database truncation if the environment is production
|
8
|
-
abort(
|
8
|
+
abort(
|
9
|
+
'The Rails environment is running in production mode!'
|
10
|
+
) if Rails.env.production?
|
9
11
|
require 'spec_helper'
|
10
12
|
require 'rspec/rails'
|
11
13
|
# Add additional requires below this line. Rails is not loaded until this point!
|
@@ -29,7 +31,10 @@ require 'rake'
|
|
29
31
|
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
30
32
|
# require only the support files necessary.
|
31
33
|
#
|
32
|
-
Dir[MessageTrain::Engine.root.join('spec/support/**/*.rb')]
|
34
|
+
Dir[MessageTrain::Engine.root.join('spec/support/**/*.rb')]
|
35
|
+
.each { |f| require f }
|
36
|
+
Dir[MessageTrain::Engine.root.join('spec/support/**/**/*.rb')]
|
37
|
+
.each { |f| require f }
|
33
38
|
|
34
39
|
# Checks for pending migrations before tests are run.
|
35
40
|
# If you are not using ActiveRecord, you can remove this line.
|
@@ -64,7 +69,7 @@ RSpec.configure do |config|
|
|
64
69
|
# You can disable this behaviour by removing the line below, and instead
|
65
70
|
# explicitly tag your specs with their type, e.g.:
|
66
71
|
#
|
67
|
-
# RSpec.describe UsersController, :
|
72
|
+
# RSpec.describe UsersController, type: :controller do
|
68
73
|
# # ...
|
69
74
|
# end
|
70
75
|
#
|
@@ -75,7 +80,7 @@ RSpec.configure do |config|
|
|
75
80
|
config.expect_with(:rspec) { |c| c.syntax = [:should, :expect] }
|
76
81
|
config.mock_with(:rspec) { |c| c.syntax = [:should, :expect] }
|
77
82
|
|
78
|
-
config.before(:each)
|
83
|
+
config.before(:each) { @routes = MessageTrain::Engine.routes }
|
79
84
|
config.include MessageTrain::Engine.routes.url_helpers
|
80
85
|
|
81
86
|
config.include Warden::Test::Helpers
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
# This file was generated by the `rails generate rspec:install` command.
|
2
|
-
# specs live under a `spec` directory, which RSpec adds to
|
1
|
+
# This file was generated by the `rails generate rspec:install` command.
|
2
|
+
# Conventionally, all specs live under a `spec` directory, which RSpec adds to
|
3
|
+
# the `$LOAD_PATH`.
|
4
|
+
#
|
3
5
|
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
4
6
|
# this file to always be loaded, without a need to explicitly require it in any
|
5
7
|
# files.
|
@@ -25,9 +27,9 @@ RSpec.configure do |config|
|
|
25
27
|
# and `failure_message` of custom matchers include text for helper methods
|
26
28
|
# defined using `chain`, e.g.:
|
27
29
|
# be_bigger_than(2).and_smaller_than(4).description
|
28
|
-
# # =>
|
30
|
+
# # => 'be bigger than 2 and smaller than 4'
|
29
31
|
# ...rather than:
|
30
|
-
# # =>
|
32
|
+
# # => 'be bigger than 2'
|
31
33
|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
32
34
|
end
|
33
35
|
|
@@ -39,54 +41,4 @@ RSpec.configure do |config|
|
|
39
41
|
# `true` in RSpec 4.
|
40
42
|
mocks.verify_partial_doubles = true
|
41
43
|
end
|
42
|
-
|
43
|
-
# The settings below are suggested to provide a good initial experience
|
44
|
-
# with RSpec, but feel free to customize to your heart's content.
|
45
|
-
=begin
|
46
|
-
# These two settings work together to allow you to limit a spec run
|
47
|
-
# to individual examples or groups you care about by tagging them with
|
48
|
-
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
49
|
-
# get run.
|
50
|
-
config.filter_run :focus
|
51
|
-
config.run_all_when_everything_filtered = true
|
52
|
-
|
53
|
-
# Allows RSpec to persist some state between runs in order to support
|
54
|
-
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
55
|
-
# you configure your source control system to ignore this file.
|
56
|
-
config.example_status_persistence_file_path = "spec/examples.txt"
|
57
|
-
|
58
|
-
# Limits the available syntax to the non-monkey patched syntax that is
|
59
|
-
# recommended. For more details, see:
|
60
|
-
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
61
|
-
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
62
|
-
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
63
|
-
config.disable_monkey_patching!
|
64
|
-
|
65
|
-
# Many RSpec users commonly either run the entire suite or an individual
|
66
|
-
# file, and it's useful to allow more verbose output when running an
|
67
|
-
# individual spec file.
|
68
|
-
if config.files_to_run.one?
|
69
|
-
# Use the documentation formatter for detailed output,
|
70
|
-
# unless a formatter has already been configured
|
71
|
-
# (e.g. via a command-line flag).
|
72
|
-
config.default_formatter = 'doc'
|
73
|
-
end
|
74
|
-
|
75
|
-
# Print the 10 slowest examples and example groups at the
|
76
|
-
# end of the spec run, to help surface which specs are running
|
77
|
-
# particularly slow.
|
78
|
-
config.profile_examples = 10
|
79
|
-
|
80
|
-
# Run specs in random order to surface order dependencies. If you find an
|
81
|
-
# order dependency and want to debug it, you can fix the order by providing
|
82
|
-
# the seed, which is printed after each run.
|
83
|
-
# --seed 1234
|
84
|
-
config.order = :random
|
85
|
-
|
86
|
-
# Seed global randomization in this process using the `--seed` CLI option.
|
87
|
-
# Setting this allows you to use `--seed` to deterministically reproduce
|
88
|
-
# test failures related to randomization by passing the same `--seed` value
|
89
|
-
# as the one that triggered the failure.
|
90
|
-
Kernel.srand config.seed
|
91
|
-
=end
|
92
44
|
end
|
@@ -37,7 +37,7 @@ end
|
|
37
37
|
shared_examples_for 'a redirect with a message' do |path, options|
|
38
38
|
it_behaves_like 'a redirect matching', path
|
39
39
|
options.each do |key, value|
|
40
|
-
context "sets #{key
|
40
|
+
context "sets #{key} message" do
|
41
41
|
subject { flash[key] }
|
42
42
|
it { should eq value }
|
43
43
|
end
|
@@ -57,7 +57,7 @@ end
|
|
57
57
|
shared_examples_for 'a page with a message' do |options|
|
58
58
|
it_behaves_like 'a successful page'
|
59
59
|
options.each do |key, value|
|
60
|
-
context "sets #{key
|
60
|
+
context "sets #{key} message" do
|
61
61
|
subject { flash[key] }
|
62
62
|
it { should eq value }
|
63
63
|
end
|
@@ -66,7 +66,7 @@ end
|
|
66
66
|
shared_examples_for 'a page with a message matching' do |options|
|
67
67
|
it_behaves_like 'a successful page'
|
68
68
|
options.each do |key, value|
|
69
|
-
context "sets #{key
|
69
|
+
context "sets #{key} message" do
|
70
70
|
subject { flash[key] }
|
71
71
|
it { should match value }
|
72
72
|
end
|
@@ -85,7 +85,10 @@ shared_examples_for 'a page with an error message matching' do |message|
|
|
85
85
|
it_behaves_like 'a page with a message matching', error: message
|
86
86
|
end
|
87
87
|
shared_examples_for 'a 403 Forbidden error' do
|
88
|
-
it_should_behave_like
|
88
|
+
it_should_behave_like(
|
89
|
+
'an error response with message',
|
90
|
+
'You are not authorized to access this page.'
|
91
|
+
)
|
89
92
|
end
|
90
93
|
shared_examples_for 'a redirect with error' do |path, message|
|
91
94
|
it_behaves_like 'a redirect to', path
|
@@ -113,4 +116,4 @@ shared_examples_for 'a response without error' do
|
|
113
116
|
subject { flash[:error] }
|
114
117
|
it { should be nil }
|
115
118
|
end
|
116
|
-
end
|
119
|
+
end
|
@@ -3,7 +3,11 @@ shared_examples_for 'an authenticated section' do |path|
|
|
3
3
|
before do
|
4
4
|
visit path
|
5
5
|
end
|
6
|
-
it_behaves_like
|
6
|
+
it_behaves_like(
|
7
|
+
'a bootstrap page with an alert',
|
8
|
+
'danger',
|
9
|
+
'You must sign in or sign up to continue.'
|
10
|
+
)
|
7
11
|
context 'displays a login form' do
|
8
12
|
subject { page }
|
9
13
|
it { should have_selector 'form.new_user input#user_email' }
|
@@ -20,15 +24,26 @@ shared_examples_for 'a bootstrap page' do |options = {}|
|
|
20
24
|
it { should have_title html_escape(options[:title]) }
|
21
25
|
it { should have_xpath '//h1', text: options[:title] }
|
22
26
|
end
|
23
|
-
it
|
27
|
+
it do
|
28
|
+
should(
|
29
|
+
have_selector(
|
30
|
+
'.navbar .navbar-header .navbar-brand',
|
31
|
+
text: BootstrapLeather.configuration.application_title
|
32
|
+
)
|
33
|
+
)
|
34
|
+
end
|
24
35
|
end
|
25
36
|
end
|
26
37
|
|
27
|
-
shared_examples_for
|
38
|
+
shared_examples_for(
|
39
|
+
'a bootstrap page with a dropdown navigation list'
|
40
|
+
) do |options|
|
28
41
|
if options[:text]
|
29
|
-
it
|
42
|
+
it do
|
43
|
+
should have_selector 'li.dropdown a.dropdown-toggle', text: options[:text]
|
44
|
+
end
|
30
45
|
else
|
31
|
-
it { should have_selector 'li.dropdown a.dropdown-toggle'}
|
46
|
+
it { should have_selector 'li.dropdown a.dropdown-toggle' }
|
32
47
|
end
|
33
48
|
end
|
34
49
|
|
@@ -42,20 +57,30 @@ shared_examples_for 'a bootstrap page without an alert' do |type|
|
|
42
57
|
it { should_not have_selector ".alert.alert-#{type}" }
|
43
58
|
end
|
44
59
|
|
45
|
-
shared_examples_for
|
60
|
+
shared_examples_for(
|
61
|
+
'a bootstrap page listing a collection of items'
|
62
|
+
) do |object, options = {}|
|
46
63
|
options[:minimum] ||= 1
|
47
64
|
options[:plural_title] ||= object.model_name.human.pluralize(2)
|
48
65
|
options[:plural_name] ||= object.table_name
|
49
|
-
collection_css_id = options[:plural_name].
|
66
|
+
collection_css_id = options[:plural_name].tr('_', '-')
|
50
67
|
member_css_class = options[:plural_name].singularize
|
51
68
|
it_behaves_like 'a bootstrap page', title: options[:plural_title].titlecase
|
52
69
|
context "displays a list of ##{collection_css_id} in .#{member_css_class}" do
|
53
70
|
subject { page }
|
54
|
-
it
|
71
|
+
it do
|
72
|
+
should(
|
73
|
+
have_css(
|
74
|
+
"##{collection_css_id} .#{member_css_class}",
|
75
|
+
minimum: options[:minimum])
|
76
|
+
)
|
77
|
+
end
|
55
78
|
end
|
56
79
|
end
|
57
80
|
|
58
|
-
shared_examples_for
|
81
|
+
shared_examples_for(
|
82
|
+
'a bootstrap page showing an item'
|
83
|
+
) do |object, title, options = {}|
|
59
84
|
options[:css_id] ||= object.table_name.singularize
|
60
85
|
it_behaves_like 'a bootstrap page', title: title
|
61
86
|
context "displays an item at ##{options[:css_id]}" do
|
@@ -66,11 +91,15 @@ end
|
|
66
91
|
|
67
92
|
shared_examples_for 'a bootstrap form with errors' do |error_fields|
|
68
93
|
subject { page }
|
69
|
-
|
70
|
-
it_behaves_like
|
94
|
+
error_fields.each do |field|
|
95
|
+
it_behaves_like(
|
96
|
+
'a bootstrap page with an alert',
|
97
|
+
'danger',
|
98
|
+
"#{field.to_s.humanize} can't be blank"
|
99
|
+
)
|
71
100
|
context 'shows which field has errors' do
|
72
101
|
subject { page }
|
73
|
-
it { should have_css('.form-group.has-error', text: field.to_s.humanize)}
|
102
|
+
it { should have_css('.form-group.has-error', text: field.to_s.humanize) }
|
74
103
|
end
|
75
104
|
end
|
76
|
-
end
|
105
|
+
end
|