message_train 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/app/controllers/message_train/unsubscribes_controller.rb +40 -25
- data/app/models/message_train/unsubscribe.rb +1 -1
- data/app/views/message_train/unsubscribes/index.html.haml +18 -9
- data/config/locales/en.yml +8 -1
- data/config/routes.rb +2 -0
- data/lib/message_train/mixin.rb +6 -2
- data/message_train.gemspec +3 -3
- data/spec/controllers/message_train/unsubscribes_controller_spec.rb +18 -4
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/features/unsubscribes_spec.rb +21 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15585f52023b76e3644608f8b946af0d1038d35a
|
4
|
+
data.tar.gz: e55821a75e12d95933e3af05b9a37076d594252a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4128dfbe8d5f208bd2896b3b21b938dfc97574a4ab4a482c677f96288ab48031d01928aba8a2040db7112737228aec976a2249730aef7ee1ed75dee5a94bb58b
|
7
|
+
data.tar.gz: 1451529ece9f6cb4832e95ff978cda5ca5aa680340b7ad50ff0e0481f4a84782d16c103dd23e5dc42607a759387cbf3e50f31af9b001da2fb35c6cebc376ca1a
|
data/README.rdoc
CHANGED
@@ -10,7 +10,7 @@ Messages can be saved as drafts instead of sending. Message composition features
|
|
10
10
|
|
11
11
|
Conversations are grouped into various boxes, depending on their status for that user: in, sent, all, drafts, trash, ignored. Any message can be trashed by the user, at which point the user has the option to permanently delete it.
|
12
12
|
|
13
|
-
Email messages are sent when a user receives a message, either directly or through a collective (unless they have unsubscribed from those notifications).
|
13
|
+
Email messages are sent when a user receives a message, either directly or through a collective (unless they have unsubscribed from those notifications or all notifications).
|
14
14
|
|
15
15
|
== Installation
|
16
16
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.1
|
@@ -8,44 +8,59 @@ module MessageTrain
|
|
8
8
|
|
9
9
|
# POST /unsubscribes
|
10
10
|
def create
|
11
|
-
|
12
|
-
|
13
|
-
@from = model.find(unsub[:from_id])
|
14
|
-
if @from == @box_user || @from.allows_receiving_by?(@box_user)
|
11
|
+
if params[:all]
|
12
|
+
@from = nil
|
15
13
|
@unsubscribe = @box_user.unsubscribe_from(@from)
|
16
14
|
if @unsubscribe.errors.empty?
|
17
|
-
|
18
|
-
flash[:notice] = :unsubscribe_message.l
|
19
|
-
else
|
20
|
-
name_column = MessageTrain.configuration.name_columns[@from.class.table_name.to_sym]
|
21
|
-
collective_name = @from.send(name_column)
|
22
|
-
collective_type = @from.class.name
|
23
|
-
flash[:notice] = :collective_unsubscribe_message.l(collective_name: collective_name, collective_type: collective_type)
|
24
|
-
end
|
15
|
+
flash[:notice] = :unsubscribe_from_all_message.l
|
25
16
|
else
|
26
17
|
flash[:error] = @unsubscribe.errors.full_messages.to_sentence
|
27
18
|
end
|
28
|
-
redirect_to message_train.unsubscribes_url
|
29
19
|
else
|
30
|
-
|
31
|
-
|
20
|
+
unsub = unsubscribe_params
|
21
|
+
model = unsub[:from_type].constantize
|
22
|
+
@from = model.find(unsub[:from_id])
|
23
|
+
if @from == @box_user || @from.allows_receiving_by?(@box_user)
|
24
|
+
@unsubscribe = @box_user.unsubscribe_from(@from)
|
25
|
+
if @unsubscribe.errors.empty?
|
26
|
+
if @from == @box_user
|
27
|
+
flash[:notice] = :unsubscribe_message.l
|
28
|
+
else
|
29
|
+
name_column = MessageTrain.configuration.name_columns[@from.class.table_name.to_sym]
|
30
|
+
collective_name = @from.send(name_column)
|
31
|
+
collective_type = @from.class.name
|
32
|
+
flash[:notice] = :collective_unsubscribe_message.l(collective_name: collective_name, collective_type: collective_type)
|
33
|
+
end
|
34
|
+
else
|
35
|
+
flash[:error] = @unsubscribe.errors.full_messages.to_sentence
|
36
|
+
end
|
37
|
+
else
|
38
|
+
flash[:error] = :you_are_not_in_that_collective_type.l(collective_type: model.name)
|
39
|
+
raise ActiveRecord::RecordNotFound
|
40
|
+
end
|
32
41
|
end
|
42
|
+
redirect_to message_train.unsubscribes_url
|
33
43
|
end
|
34
44
|
|
35
45
|
# DELETE /unsubscribes/:id
|
36
46
|
def destroy
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
message = :unsubscribe_removed_message.l
|
47
|
+
if params[:all]
|
48
|
+
@unsubscribe = @box_user.unsubscribes.where(from: nil).destroy_all
|
49
|
+
flash[:notice] = :unsubscribe_all_removed_message.l
|
41
50
|
else
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
51
|
+
@unsubscribe = @box_user.unsubscribes.find(params[:id])
|
52
|
+
@from = @unsubscribe.from
|
53
|
+
if @from == @box_user
|
54
|
+
message = :unsubscribe_removed_message.l
|
55
|
+
else
|
56
|
+
name_column = MessageTrain.configuration.name_columns[@unsubscribe.from.class.table_name.to_sym]
|
57
|
+
collective_name = @unsubscribe.from.send(name_column)
|
58
|
+
collective_type = @unsubscribe.from_type
|
59
|
+
message = :collective_unsubscribe_removed_message.l(collective_name: collective_name, collective_type: collective_type)
|
60
|
+
end
|
61
|
+
@unsubscribe.destroy
|
62
|
+
flash[:notice] = message
|
46
63
|
end
|
47
|
-
@unsubscribe.destroy
|
48
|
-
flash[:notice] = message
|
49
64
|
redirect_to message_train.unsubscribes_url
|
50
65
|
end
|
51
66
|
|
@@ -1,10 +1,19 @@
|
|
1
1
|
- add_title :manage_your_email_notifications.l
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
-
|
10
|
-
|
2
|
+
- if current_user.unsubscribed_from_all?
|
3
|
+
%p= :you_have_chosen_not_to_be_emailed.l
|
4
|
+
%p= icon_button_to 'primary', 'check', :enable_some_notifications.l, message_train.unsubscribes_all_path, method: :delete
|
5
|
+
- else
|
6
|
+
.row
|
7
|
+
.col-md-10
|
8
|
+
%table#subscriptions.table.table-bordered.table-condensed
|
9
|
+
- @subscriptions.each do |subscription|
|
10
|
+
%tr.subscription
|
11
|
+
%td= subscription[:from_name]
|
12
|
+
- if subscription[:unsubscribe].nil?
|
13
|
+
%td= :subscribed.l
|
14
|
+
%td= button_to :disable_notifications.l, message_train.unsubscribes_path(unsubscribe: { from_type: subscription[:from_type], from_id: subscription[:from_id] }), class: 'btn btn-danger', id: "unsubscribe-#{subscription[:from_type].downcase}-#{subscription[:from_id]}", confirm: :are_you_sure.l
|
15
|
+
- else
|
16
|
+
%td= :unsubscribed.l
|
17
|
+
%td= button_to :enable_notifications.l, message_train.unsubscribe_path(subscription[:unsubscribe].id), method: :delete, class: 'btn btn-primary', id: "remove-unsubscribe-#{subscription[:unsubscribe].id}"
|
18
|
+
.col-md-2
|
19
|
+
%p= icon_button_to 'danger btn-lg', 'remove', :disable_all_notifications.l, message_train.unsubscribes_all_path, method: :post
|
data/config/locales/en.yml
CHANGED
@@ -45,9 +45,11 @@ en:
|
|
45
45
|
compose_to_collective: "Compose to %{collective}"
|
46
46
|
delete_forever_this_cannot_be_undone: 'Delete forever? This cannot be undone.'
|
47
47
|
deleted: 'Deleted'
|
48
|
+
disable_all_notifications: 'Disable All Notifications'
|
48
49
|
disable_notifications: 'Disable Notifications'
|
49
50
|
edit_draft: 'Edit Draft'
|
50
51
|
enable_notifications: 'Enable Notifications'
|
52
|
+
enable_some_notifications: 'Enable Some Notifications'
|
51
53
|
from_sender: "From: %{sender}"
|
52
54
|
ignored: 'Ignored'
|
53
55
|
invalid_sender_for_thing: "Invalid sender for %{thing}"
|
@@ -60,7 +62,7 @@ en:
|
|
60
62
|
message_sent: 'Message sent.'
|
61
63
|
messages: 'Messages'
|
62
64
|
messages_to_collective: "Messages to %{collective}"
|
63
|
-
|
65
|
+
messages_directly_to_myself: 'Messages Directly to Myself'
|
64
66
|
name_not_found: "%{name} not found"
|
65
67
|
new_message: 'New Message'
|
66
68
|
new_message_on_site_name: "New Message on %{site_name}"
|
@@ -74,19 +76,24 @@ en:
|
|
74
76
|
remove_attachment: 'Remove Attachment'
|
75
77
|
save_as_draft: 'Save As Draft'
|
76
78
|
send: 'Send'
|
79
|
+
subscribed: 'Subscribed'
|
77
80
|
table_recipients: "%{table} Recipients"
|
78
81
|
to_recipient: 'To: %{recipient}'
|
79
82
|
toggle_dropdown: 'Toggle Dropdown'
|
80
83
|
trashed: 'Trashed'
|
81
84
|
unignored: 'Unignored'
|
82
85
|
unread: 'Unread'
|
86
|
+
unsubscribed: 'Unsubscribed'
|
83
87
|
unsubscribe_message: "You are now unsubscribed from messages to you, which means that you will not be notified by email of any messages received in your inbox."
|
88
|
+
unsubscribe_from_all_message: 'You have unsubscribed from all messages, which means that you will not be notified by email of any messages received in any of your boxes.'
|
84
89
|
unsubscribe_from_option: "You received this email because you are set to receive notifications of messages to %{from}. To unsubscribe, please visit this link:"
|
90
|
+
unsubscribe_all_removed_message: 'You are no longer unsubscribed from all messages, which means that you will now be notified by email of any messages received in boxes you are subscribed to.'
|
85
91
|
unsubscribe_removed_message: "You are no longer unsubscribed from messages to you, which means that you will now be notified by email of any messages received in your inbox"
|
86
92
|
untrashed: 'Untrashed'
|
87
93
|
update_successful: 'Update successful'
|
88
94
|
updated_at_time: "Updated at %{time}"
|
89
95
|
wrong_number_of_arguments_for_thing_expected_right_got_wrong: "Wrong number of arguments for %{thing} (expected %{right}, got %{wrong})"
|
90
96
|
you_are_not_in_that_collective_type: "You are not in that %{collective_type}"
|
97
|
+
you_have_chosen_not_to_be_emailed: 'You have chosen not to be emailed when new messages arrive.'
|
91
98
|
you_must_sign_in_or_sign_up_to_continue: 'You must sign in or sign up to continue.'
|
92
99
|
your_inbox: 'your inbox'
|
data/config/routes.rb
CHANGED
@@ -11,6 +11,8 @@ MessageTrain::Engine.routes.draw do
|
|
11
11
|
authenticated MessageTrain.configuration.user_route_authentication_method do
|
12
12
|
concerns :boxable
|
13
13
|
resources :collectives, as: :collective, only: [], concerns: :boxable
|
14
|
+
post 'unsubscribes/all', to: 'unsubscribes#create', all: true
|
15
|
+
delete 'unsubscribes/all', to: 'unsubscribes#destroy', all: true
|
14
16
|
resources :unsubscribes, only: [:index, :create, :destroy]
|
15
17
|
end
|
16
18
|
|
data/lib/message_train/mixin.rb
CHANGED
@@ -231,8 +231,12 @@ module MessageTrain
|
|
231
231
|
end
|
232
232
|
}
|
233
233
|
|
234
|
+
send(:define_method, :unsubscribed_from_all?) {
|
235
|
+
unsubscribes.where(from: nil).exists?
|
236
|
+
}
|
237
|
+
|
234
238
|
send(:define_method, :unsubscribed_from?) { |from|
|
235
|
-
unsubscribes.where(from: from).exists?
|
239
|
+
unsubscribed_from_all? or unsubscribes.where(from: from).exists?
|
236
240
|
}
|
237
241
|
|
238
242
|
send(:define_method, :unsubscribe_from) { |from|
|
@@ -245,7 +249,7 @@ module MessageTrain
|
|
245
249
|
from: self,
|
246
250
|
from_type: self.class.name,
|
247
251
|
from_id: self.id,
|
248
|
-
from_name: :
|
252
|
+
from_name: :messages_directly_to_myself.l,
|
249
253
|
unsubscribe: self.unsubscribes.find_by(from: self)
|
250
254
|
}
|
251
255
|
collective_boxes.values.each do |boxes|
|
data/message_train.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: message_train 0.5.
|
5
|
+
# stub: message_train 0.5.1 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "message_train"
|
9
|
-
s.version = "0.5.
|
9
|
+
s.version = "0.5.1"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Karen Lundgren"]
|
14
|
-
s.date = "2016-
|
14
|
+
s.date = "2016-03-01"
|
15
15
|
s.description = "Rails 4 Engine providing private/public messaging for any object, such as Users or Groups"
|
16
16
|
s.email = "karen.e.lundgren@gmail.com"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -44,13 +44,27 @@ describe MessageTrain::UnsubscribesController do
|
|
44
44
|
it_should_behave_like 'a redirect with a message', '/unsubscribes', notice: 'You are now unsubscribed from Membered Group, which means that you will not be notified by email of any messages received by that Group.'
|
45
45
|
it_should_behave_like 'a response without error'
|
46
46
|
end
|
47
|
+
describe 'with :all set to true' do
|
48
|
+
before do
|
49
|
+
post :create, all: true
|
50
|
+
end
|
51
|
+
it_should_behave_like 'a redirect with a message', '/unsubscribes', notice: 'You have unsubscribed from all messages, which means that you will not be notified by email of any messages received in any of your boxes.'
|
52
|
+
it_should_behave_like 'a response without error'
|
53
|
+
end
|
47
54
|
end
|
48
55
|
|
49
56
|
describe "DELETE #destroy" do
|
50
|
-
|
51
|
-
|
57
|
+
describe 'with an id' do
|
58
|
+
before do
|
59
|
+
delete :destroy, id: first_user.unsubscribes.where(from_type: 'Group', from_id: unsubscribed_group.id).first.id
|
60
|
+
end
|
61
|
+
it_should_behave_like 'a redirect with a message', '/unsubscribes', notice: '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.'
|
62
|
+
end
|
63
|
+
describe 'with :all set to true' do
|
64
|
+
before do
|
65
|
+
delete :destroy, all: true
|
66
|
+
end
|
67
|
+
it_should_behave_like 'a redirect with a message', '/unsubscribes', notice: 'You are no longer unsubscribed from all messages, which means that you will now be notified by email of any messages received in boxes you are subscribed to.'
|
52
68
|
end
|
53
|
-
it_should_behave_like 'a redirect with a message', '/unsubscribes', notice: '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.'
|
54
69
|
end
|
55
|
-
|
56
70
|
end
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|
@@ -22,11 +22,20 @@ RSpec.feature 'Unsubscribes' do
|
|
22
22
|
end
|
23
23
|
describe 'Unsubscribing' do
|
24
24
|
describe 'at /unsubscribes' do
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
describe 'with a specific item' do
|
26
|
+
before do
|
27
|
+
visit '/unsubscribes'
|
28
|
+
find("#unsubscribe-group-#{membered_group.id.to_s}").click
|
29
|
+
end
|
30
|
+
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.'
|
31
|
+
end
|
32
|
+
describe 'with all button' do
|
33
|
+
before do
|
34
|
+
visit '/unsubscribes'
|
35
|
+
click_link 'Disable All Notifications'
|
36
|
+
end
|
37
|
+
it_behaves_like 'a bootstrap page with an alert', 'info', 'You have unsubscribed from all messages, which means that you will not be notified by email of any messages received in any of your boxes.'
|
28
38
|
end
|
29
|
-
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.'
|
30
39
|
end
|
31
40
|
end
|
32
41
|
describe 'Removing an Unsubscribe' do
|
@@ -37,6 +46,14 @@ RSpec.feature 'Unsubscribes' do
|
|
37
46
|
end
|
38
47
|
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.'
|
39
48
|
end
|
49
|
+
describe 'with all button' do
|
50
|
+
before do
|
51
|
+
visit '/unsubscribes'
|
52
|
+
click_link 'Disable All Notifications'
|
53
|
+
click_link 'Enable Some Notifications'
|
54
|
+
end
|
55
|
+
it_behaves_like 'a bootstrap page with an alert', 'info', 'You are no longer unsubscribed from all messages, which means that you will now be notified by email of any messages received in boxes you are subscribed to.'
|
56
|
+
end
|
40
57
|
end
|
41
58
|
end
|
42
59
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: message_train
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karen Lundgren
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|