msg 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.md +9 -0
- data/Rakefile +35 -0
- data/app/assets/images/msg/message.png +0 -0
- data/app/assets/images/msg/ping.png +0 -0
- data/app/assets/images/msg/sending.png +0 -0
- data/app/assets/javascripts/lib/jquery.peity.js +261 -0
- data/app/assets/javascripts/msg.js.coffee +6 -0
- data/app/assets/stylesheets/msg.css.sass +218 -0
- data/app/controllers/msg/bounces_controller.rb +67 -0
- data/app/controllers/msg/engine_controller.rb +23 -0
- data/app/controllers/msg/envelopes_controller.rb +22 -0
- data/app/controllers/msg/messages_controller.rb +85 -0
- data/app/controllers/msg/sendings_controller.rb +58 -0
- data/app/helpers/msg/msg_helper.rb +40 -0
- data/app/mailers/msg/devise_mailer.rb +20 -0
- data/app/mailers/msg/msg_mailer.rb +23 -0
- data/app/models/msg/bounce.rb +19 -0
- data/app/models/msg/envelope.rb +56 -0
- data/app/models/msg/message.rb +26 -0
- data/app/models/msg/sending.rb +54 -0
- data/app/views/layouts/msg/default.html.haml +30 -0
- data/app/views/layouts/msg/email.html.haml +10 -0
- data/app/views/msg/bounces/_listing.html.haml +5 -0
- data/app/views/msg/bounces/_report.html.haml +10 -0
- data/app/views/msg/bounces/index.html.haml +5 -0
- data/app/views/msg/devise_mailer/confirmation_instructions.en.html.haml +1 -0
- data/app/views/msg/devise_mailer/reset_password_instructions.en.html.haml +1 -0
- data/app/views/msg/envelopes/_listing.html.haml +5 -0
- data/app/views/msg/messages/_action_menu.html.haml +10 -0
- data/app/views/msg/messages/_form.html.haml +38 -0
- data/app/views/msg/messages/_instructions.html.haml +28 -0
- data/app/views/msg/messages/_message.html.haml +11 -0
- data/app/views/msg/messages/_saved_messages.html.haml +2 -0
- data/app/views/msg/messages/_transactional_messages.html.haml +3 -0
- data/app/views/msg/messages/edit.html.haml +7 -0
- data/app/views/msg/messages/index.html.haml +23 -0
- data/app/views/msg/messages/new.html.haml +7 -0
- data/app/views/msg/messages/preview.html.haml +4 -0
- data/app/views/msg/messages/show.html.haml +25 -0
- data/app/views/msg/msg_mailer/message_in_envelope.html.haml +2 -0
- data/app/views/msg/sendings/_form.html.haml +45 -0
- data/app/views/msg/sendings/_listing.html.haml +17 -0
- data/app/views/msg/sendings/_report.html.haml +8 -0
- data/app/views/msg/sendings/_sending.html.haml +22 -0
- data/app/views/msg/sendings/_sendings.html.haml +2 -0
- data/app/views/msg/sendings/index.html.haml +8 -0
- data/app/views/msg/sendings/new.html.haml +9 -0
- data/app/views/msg/sendings/review.html.haml +2 -0
- data/app/views/msg/sendings/show.html.haml +50 -0
- data/app/views/msg/shared/_toolbar.html.haml +17 -0
- data/config/cucumber.yml +8 -0
- data/config/locales/en.yml +76 -0
- data/config/routes.rb +26 -0
- data/db/migrate/20130320141926_msg_data.rb +54 -0
- data/db/migrate/20130327134754_sending_circumstances.rb +6 -0
- data/lib/msg.rb +88 -0
- data/lib/msg/engine.rb +23 -0
- data/lib/msg/receivers.rb +64 -0
- data/lib/msg/version.rb +3 -0
- data/lib/tasks/cucumber.rake +65 -0
- data/lib/tasks/msg_tasks.rake +4 -0
- data/spec/controllers/msg/bounces_controller_spec.rb +48 -0
- data/spec/controllers/msg/envelopes_controller_spec.rb +22 -0
- data/spec/controllers/msg/messages_controller_spec.rb +9 -0
- data/spec/controllers/msg/sendings_controller_spec.rb +47 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/models/user.rb +14 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +59 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +41 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/devise.rb +285 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +9 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/2013032210540_users.rb +49 -0
- data/spec/dummy/db/migrate/20130326093048_msg_data.msg.rb +55 -0
- data/spec/dummy/db/schema.rb +96 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +143 -0
- data/spec/dummy/log/test.log +1022 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories/msg/bounces.rb +9 -0
- data/spec/factories/msg/envelopes.rb +10 -0
- data/spec/factories/msg/messages.rb +10 -0
- data/spec/factories/msg/sendings.rb +7 -0
- data/spec/factories/users.rb +11 -0
- data/spec/helpers/msg/msg_helper_spec.rb +17 -0
- data/spec/lib/msg_spec.rb +15 -0
- data/spec/mailers/msg/devise_mailer_spec.rb +21 -0
- data/spec/mailers/msg/msg_mailer_spec.rb +36 -0
- data/spec/models/msg/bounce_spec.rb +19 -0
- data/spec/models/msg/envelope_spec.rb +62 -0
- data/spec/models/msg/message_spec.rb +19 -0
- data/spec/models/msg/sending_spec.rb +10 -0
- data/spec/routing/sendings_routing_spec.rb +31 -0
- data/spec/spec_helper.rb +70 -0
- metadata +446 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/404.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
</div>
|
24
|
+
</body>
|
25
|
+
</html>
|
File without changes
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# Specs in this file have access to a helper object that includes
|
4
|
+
# the SendingsHelper. For example:
|
5
|
+
#
|
6
|
+
# describe SendingsHelper do
|
7
|
+
# describe "string concat" do
|
8
|
+
# it "concats two strings with spaces" do
|
9
|
+
# helper.concat_strings("this","that").should == "this that"
|
10
|
+
# end
|
11
|
+
# end
|
12
|
+
# end
|
13
|
+
module Msg
|
14
|
+
describe MsgHelper do
|
15
|
+
pending "add some examples to (or delete) #{__FILE__}"
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Msg do
|
4
|
+
|
5
|
+
it "should provide defaults" do
|
6
|
+
Msg.default_from_address = nil
|
7
|
+
Msg.default_from_address.should_not be_nil
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should accept overrides" do
|
11
|
+
Msg.default_from_address = "my@email.org"
|
12
|
+
Msg.default_from_address.should eq "my@email.org"
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module Msg
|
4
|
+
describe DeviseMailer do
|
5
|
+
|
6
|
+
context "sending a transactional message" do
|
7
|
+
before do
|
8
|
+
# @email = Msg::DeviseMailer
|
9
|
+
# @email.deliver
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should have the right to: address"
|
13
|
+
it "should have the right from: address"
|
14
|
+
it "should have the right subject"
|
15
|
+
it "should have the right body"
|
16
|
+
it "should have the right message id"
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
include EmailSpec::Helpers
|
3
|
+
include EmailSpec::Matchers
|
4
|
+
module Msg
|
5
|
+
describe MsgMailer do
|
6
|
+
|
7
|
+
context "sending a message in an envelope" do
|
8
|
+
before do
|
9
|
+
@envelope = FactoryGirl.create(:valid_envelope)
|
10
|
+
@email = Msg::MsgMailer.message_in_envelope(@envelope)
|
11
|
+
@email.deliver
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should have the right to: address" do
|
15
|
+
@email.should deliver_to "#{@envelope.receiver.name} <#{@envelope.receiver.email}>"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should have the right from: address" do
|
19
|
+
@email.should deliver_from @envelope.from_address
|
20
|
+
end
|
21
|
+
it "should have the right subject" do
|
22
|
+
@email.should have_subject @envelope.subject
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should have the right body" do
|
26
|
+
@email.should have_body_text @envelope.send(:render_with_tracker)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should have the right message id" do
|
30
|
+
@email["Message-ID"].should eq @envelope.email_id
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Msg
|
4
|
+
describe Msg::Bounce do
|
5
|
+
|
6
|
+
# we get our bounce notifications from SNS so they have a very consistent structure
|
7
|
+
|
8
|
+
before :each do
|
9
|
+
@bounce = FactoryGirl.create(:valid_bounce)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should require an envelope" do
|
13
|
+
@bounce.should be_valid
|
14
|
+
@bounce.envelope = nil
|
15
|
+
@bounce.should_not be_valid
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Msg
|
4
|
+
describe Envelope do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
@envelope = FactoryGirl.create(:valid_envelope)
|
8
|
+
@message = @envelope.message
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should require a receiver" do
|
12
|
+
@envelope.should be_valid
|
13
|
+
@envelope.receiver = nil
|
14
|
+
@envelope.should_not be_valid
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should require a sending" do
|
18
|
+
@envelope.should be_valid
|
19
|
+
@envelope.sending = nil
|
20
|
+
@envelope.should_not be_valid
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should generate a tracker url" do
|
24
|
+
pending "tracker?"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should by default be marked unopened" do
|
28
|
+
@envelope.opened_at.should be_nil
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should be marked opened once opened" do
|
32
|
+
@envelope.open!
|
33
|
+
@envelope.opened_at.should_not be_nil
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should store the message subject" do
|
37
|
+
@envelope.subject.should_not be_nil
|
38
|
+
@envelope.subject.should eq @message.subject
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should store the message to: address" do
|
42
|
+
@envelope.to_address.should_not be_nil
|
43
|
+
@envelope.to_address.should eq @envelope.receiver.email
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should store the message from: address" do
|
47
|
+
@envelope.from_address.should_not be_nil
|
48
|
+
@envelope.from_address.should eq "#{@message.from_name} <#{@message.from_address}>"
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should render the message contents and append a tracker dot" do
|
52
|
+
@envelope.send(:render_with_tracker).should eq "#{@message.body}<img src=\"#{@envelope.url_to_open}\" />"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should send the message" do
|
56
|
+
@envelope.send(:send_email)
|
57
|
+
@envelope.sent_at.should_not be_nil
|
58
|
+
pending "test for send"
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Msg
|
4
|
+
describe Message do
|
5
|
+
|
6
|
+
# Receivers must define a for_email method, which returns the hash we pass to the mustache
|
7
|
+
# template. In the dummy we can use any old value just to test that they get through.
|
8
|
+
it "should interpolate values provided by the receiver"
|
9
|
+
|
10
|
+
# after rendering and before sending we have to strip out anything foolish or malicious
|
11
|
+
# that has been entered by a user.
|
12
|
+
it "should sanitize html in the rendered template"
|
13
|
+
it "should accept tags allowed in Msg configuration"
|
14
|
+
it "should reject tags not allowed in Msg configuration"
|
15
|
+
it "should accept attributes allowed in Msg configuration"
|
16
|
+
it "should reject attributes not allowed in Msg configuration"
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
module Msg
|
3
|
+
describe SendingsController do
|
4
|
+
describe "routing" do
|
5
|
+
it "routes to #index" do
|
6
|
+
pending
|
7
|
+
get("/sendings").should route_to("msg/sendings#index")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "routes to #show" do
|
11
|
+
pending
|
12
|
+
get("/sendings/1").should route_to("msg/sendings#show", :id => "1")
|
13
|
+
end
|
14
|
+
|
15
|
+
it "routes to #new" do
|
16
|
+
pending
|
17
|
+
get("/sendings/new").should route_to("msg/sendings#new")
|
18
|
+
end
|
19
|
+
|
20
|
+
it "routes to #create" do
|
21
|
+
pending
|
22
|
+
post("/sendings").should route_to("msg/sendings#create")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "routes to #destroy" do
|
26
|
+
pending
|
27
|
+
delete("/sendings/1").should route_to("msg/sendings#destroy", :id => "1")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spork'
|
2
|
+
#uncomment the following line to use spork with the debugger
|
3
|
+
#require 'spork/ext/ruby-debug'
|
4
|
+
|
5
|
+
Spork.prefork do
|
6
|
+
ENV["RAILS_ENV"] = 'test' #bah
|
7
|
+
require File.expand_path("../dummy/config/environment", __FILE__)
|
8
|
+
|
9
|
+
require 'bundler/setup'
|
10
|
+
require 'rspec/rails'
|
11
|
+
require 'rspec/autorun'
|
12
|
+
require 'factory_girl_rails'
|
13
|
+
require 'database_cleaner'
|
14
|
+
require 'email_spec'
|
15
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
16
|
+
# in spec/support/ and its subdirectories.
|
17
|
+
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
18
|
+
|
19
|
+
RSpec.configure do |config|
|
20
|
+
# ## Mock Framework
|
21
|
+
#
|
22
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
23
|
+
#
|
24
|
+
# config.mock_with :mocha
|
25
|
+
# config.mock_with :flexmock
|
26
|
+
# config.mock_with :rr
|
27
|
+
|
28
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
29
|
+
# config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
30
|
+
|
31
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
32
|
+
# examples within a transaction, remove the following line or assign false
|
33
|
+
# instead of true.
|
34
|
+
config.use_transactional_fixtures = false
|
35
|
+
|
36
|
+
# If true, the base class of anonymous controllers will be inferred
|
37
|
+
# automatically. This will be the default behavior in future versions of
|
38
|
+
# rspec-rails.
|
39
|
+
config.infer_base_class_for_anonymous_controllers = true
|
40
|
+
|
41
|
+
# Run specs in random order to surface order dependencies. If you find an
|
42
|
+
# order dependency and want to debug it, you can fix the order by providing
|
43
|
+
# the seed, which is printed after each run.
|
44
|
+
# --seed 1234
|
45
|
+
config.order = "random"
|
46
|
+
|
47
|
+
config.before(:suite) do
|
48
|
+
DatabaseCleaner.strategy = :transaction
|
49
|
+
DatabaseCleaner.clean_with(:truncation)
|
50
|
+
end
|
51
|
+
config.before(:each) do
|
52
|
+
DatabaseCleaner.start
|
53
|
+
end
|
54
|
+
config.after(:each) do
|
55
|
+
DatabaseCleaner.clean
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
## controller methods
|
61
|
+
# devise sign_in
|
62
|
+
def sign_in_admin
|
63
|
+
sign_in FactoryGirl.create(:admin)
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
Spork.each_run do
|
69
|
+
|
70
|
+
end
|