simple_contact 0.0.3 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.rdoc +37 -2
  4. data/app/controllers/simple_contact/application_controller.rb +2 -4
  5. data/app/controllers/simple_contact/contact_controller.rb +12 -16
  6. data/app/mailers/simple_contact/contact_mailer.rb +4 -6
  7. data/app/models/simple_contact/message.rb +13 -15
  8. data/config/routes.rb +1 -0
  9. data/lib/simple_contact/version.rb +1 -1
  10. data/test/controllers/contact_controller_test.rb +33 -0
  11. data/test/dummy/db/development.sqlite3 +0 -0
  12. data/test/dummy/db/test.sqlite3 +0 -0
  13. data/test/dummy/log/development.log +5 -0
  14. data/test/dummy/log/test.log +1619 -0
  15. data/test/factories/messages.rb +10 -0
  16. data/test/mailers/contact_mailer_test.rb +25 -0
  17. data/test/models/message_test.rb +42 -0
  18. data/test/test_helper.rb +9 -4
  19. metadata +32 -24
  20. data/app/assets/javascripts/simple_contact/application.js +0 -15
  21. data/app/assets/javascripts/simple_contact/contact.js +0 -2
  22. data/app/assets/stylesheets/simple_contact/application.css +0 -13
  23. data/app/assets/stylesheets/simple_contact/contact.css +0 -4
  24. data/app/helpers/simple_contact/application_helper.rb +0 -4
  25. data/app/helpers/simple_contact/contact_helper.rb +0 -4
  26. data/test/fixtures/simple_contact/messages.yml +0 -11
  27. data/test/functional/simple_contact/contact_controller_test.rb +0 -9
  28. data/test/functional/simple_contact/contact_mailer_test.rb +0 -9
  29. data/test/integration/navigation_test.rb +0 -10
  30. data/test/unit/helpers/simple_contact/contact_helper_test.rb +0 -6
  31. data/test/unit/simple_contact/message_test.rb +0 -9
@@ -0,0 +1,10 @@
1
+ # Read about factories at https://github.com/thoughtbot/factory_girl
2
+ require 'ffaker'
3
+ FactoryGirl.define do
4
+ factory :message, class: SimpleContact::Message do
5
+ body { Faker::Lorem.paragraph }
6
+ email { Faker::Internet.email }
7
+ name { Faker::Name.name }
8
+ subject { Faker::Lorem.sentence }
9
+ end
10
+ end
@@ -0,0 +1,25 @@
1
+ require 'test_helper'
2
+
3
+ class SimpleContact::ContactMailerTest < ActionMailer::TestCase
4
+
5
+ before do
6
+ @routes = SimpleContact::Engine.routes
7
+ ENV['SIMPLE_CONTACT_TO_EMAIL'] = 'test@example.com'
8
+ ENV['SIMPLE_CONTACT_SUBJECT_PREFIX'] = "[Simple Contact]"
9
+ @message = build(:message)
10
+ @email = SimpleContact::ContactMailer.contact_message(@message).deliver
11
+ end
12
+
13
+ it "is delivered to simple_contact_to_email" do
14
+ assert_equal @email.to.pop, ENV['SIMPLE_CONTACT_TO_EMAIL']
15
+ end
16
+
17
+ it "is delivered from the senders email" do
18
+ assert_equal @email.from.pop, @message.email
19
+ end
20
+
21
+ it "is delivered with an appropriate subject" do
22
+ assert_equal @email.subject, "#{ENV['SIMPLE_CONTACT_SUBJECT_PREFIX']} #{@message.subject}"
23
+ end
24
+
25
+ end
@@ -0,0 +1,42 @@
1
+ require "test_helper"
2
+
3
+ class SimpleContact::MessageTest < ActiveSupport::TestCase
4
+
5
+ def setup
6
+ @message = build(:message)
7
+ end
8
+
9
+ def test_valid
10
+ assert @message.valid?
11
+ assert_match /\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z/, @message.email
12
+ end
13
+
14
+ test "rejects a message without a body" do
15
+ @message.body = nil
16
+ assert @message.invalid?
17
+ end
18
+
19
+ test "rejects a message without a subject" do
20
+ @message.subject = nil
21
+ assert @message.invalid?
22
+ end
23
+
24
+ test "rejects a message without a name" do
25
+ @message.name = nil
26
+ assert @message.invalid?
27
+ end
28
+
29
+ test "rejects a message without a email" do
30
+ @message.email = nil
31
+ assert @message.invalid?, "Doesn't have an email"
32
+ end
33
+
34
+ test "checks that email has a valid format" do
35
+ @message.email = 'invalid@example,com'
36
+ assert @message.invalid?, "email format was not invalid"
37
+ refute_match /\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z/, @message.email
38
+ end
39
+
40
+
41
+ end
42
+
data/test/test_helper.rb CHANGED
@@ -1,8 +1,12 @@
1
+ require "coveralls"
2
+ Coveralls.wear!('rails')
1
3
  ENV["RAILS_ENV"] = "test"
2
4
  require File.expand_path("../dummy/config/environment.rb", __FILE__)
3
5
  require "rails/test_help"
4
6
  require "minitest/rails"
5
-
7
+ require "minitest/spec" # require this if you wan't spec syntax support
8
+ require 'factory_girl'
9
+ FactoryGirl.find_definitions
6
10
 
7
11
  # To add Capybara feature tests add `gem "minitest-rails-capybara"`
8
12
  # to the test group in the Gemfile and uncomment the following:
@@ -12,8 +16,9 @@ require "minitest/rails"
12
16
  require "minitest/pride"
13
17
 
14
18
  class ActiveSupport::TestCase
15
- # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
16
- fixtures :all
19
+ include FactoryGirl::Syntax::Methods
20
+ end
17
21
 
18
- # Add more helper methods to be used by all tests here...
22
+ class ActionController::TestCase
23
+ include FactoryGirl::Syntax::Methods
19
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_contact
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Eggett
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: factory_girl_rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 4.2.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 4.2.0
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: ffaker
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -67,19 +81,19 @@ dependencies:
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: factory_girl_rails
84
+ name: coveralls
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - ~>
87
+ - - '>='
74
88
  - !ruby/object:Gem::Version
75
- version: 4.2.0
89
+ version: '0'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - ~>
94
+ - - '>='
81
95
  - !ruby/object:Gem::Version
82
- version: 4.2.0
96
+ version: '0'
83
97
  description: Provides a stupidly simple contact form with bootstrap class theming
84
98
  for rails
85
99
  email:
@@ -88,14 +102,8 @@ executables: []
88
102
  extensions: []
89
103
  extra_rdoc_files: []
90
104
  files:
91
- - app/assets/javascripts/simple_contact/application.js
92
- - app/assets/javascripts/simple_contact/contact.js
93
- - app/assets/stylesheets/simple_contact/application.css
94
- - app/assets/stylesheets/simple_contact/contact.css
95
105
  - app/controllers/simple_contact/application_controller.rb
96
106
  - app/controllers/simple_contact/contact_controller.rb
97
- - app/helpers/simple_contact/application_helper.rb
98
- - app/helpers/simple_contact/contact_helper.rb
99
107
  - app/mailers/simple_contact/contact_mailer.rb
100
108
  - app/models/simple_contact/message.rb
101
109
  - app/views/simple_contact/contact/new.html.erb
@@ -109,6 +117,7 @@ files:
109
117
  - MIT-LICENSE
110
118
  - Rakefile
111
119
  - README.rdoc
120
+ - test/controllers/contact_controller_test.rb
112
121
  - test/dummy/app/assets/javascripts/application.js
113
122
  - test/dummy/app/assets/javascripts/home.js
114
123
  - test/dummy/app/assets/stylesheets/application.css
@@ -136,7 +145,9 @@ files:
136
145
  - test/dummy/config/routes.rb
137
146
  - test/dummy/config.ru
138
147
  - test/dummy/db/development.sqlite3
148
+ - test/dummy/db/test.sqlite3
139
149
  - test/dummy/log/development.log
150
+ - test/dummy/log/test.log
140
151
  - test/dummy/public/404.html
141
152
  - test/dummy/public/422.html
142
153
  - test/dummy/public/500.html
@@ -171,14 +182,11 @@ files:
171
182
  - test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af
172
183
  - test/dummy/tmp/cache/assets/E0C/150/sprockets%2F598d5d80d9cf96a6afbcff06f31d5ca4
173
184
  - test/dummy/tmp/restart.txt
174
- - test/fixtures/simple_contact/messages.yml
175
- - test/functional/simple_contact/contact_controller_test.rb
176
- - test/functional/simple_contact/contact_mailer_test.rb
177
- - test/integration/navigation_test.rb
185
+ - test/factories/messages.rb
186
+ - test/mailers/contact_mailer_test.rb
187
+ - test/models/message_test.rb
178
188
  - test/simple_contact_test.rb
179
189
  - test/test_helper.rb
180
- - test/unit/helpers/simple_contact/contact_helper_test.rb
181
- - test/unit/simple_contact/message_test.rb
182
190
  homepage: http://github.com/beneggett/simple_contact
183
191
  licenses: []
184
192
  metadata: {}
@@ -204,6 +212,7 @@ specification_version: 4
204
212
  summary: Provides a stupidly simple contact form with bootstrap class theming for
205
213
  rails
206
214
  test_files:
215
+ - test/controllers/contact_controller_test.rb
207
216
  - test/dummy/app/assets/javascripts/application.js
208
217
  - test/dummy/app/assets/javascripts/home.js
209
218
  - test/dummy/app/assets/stylesheets/application.css
@@ -231,7 +240,9 @@ test_files:
231
240
  - test/dummy/config/routes.rb
232
241
  - test/dummy/config.ru
233
242
  - test/dummy/db/development.sqlite3
243
+ - test/dummy/db/test.sqlite3
234
244
  - test/dummy/log/development.log
245
+ - test/dummy/log/test.log
235
246
  - test/dummy/public/404.html
236
247
  - test/dummy/public/422.html
237
248
  - test/dummy/public/500.html
@@ -266,11 +277,8 @@ test_files:
266
277
  - test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af
267
278
  - test/dummy/tmp/cache/assets/E0C/150/sprockets%2F598d5d80d9cf96a6afbcff06f31d5ca4
268
279
  - test/dummy/tmp/restart.txt
269
- - test/fixtures/simple_contact/messages.yml
270
- - test/functional/simple_contact/contact_controller_test.rb
271
- - test/functional/simple_contact/contact_mailer_test.rb
272
- - test/integration/navigation_test.rb
280
+ - test/factories/messages.rb
281
+ - test/mailers/contact_mailer_test.rb
282
+ - test/models/message_test.rb
273
283
  - test/simple_contact_test.rb
274
284
  - test/test_helper.rb
275
- - test/unit/helpers/simple_contact/contact_helper_test.rb
276
- - test/unit/simple_contact/message_test.rb
@@ -1,15 +0,0 @@
1
- // This is a manifest file that'll be compiled into application.js, which will include all the files
2
- // listed below.
3
- //
4
- // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
- //
7
- // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // the compiled file.
9
- //
10
- // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
- // GO AFTER THE REQUIRES BELOW.
12
- //
13
- //= require jquery
14
- //= require jquery_ujs
15
- //= require_tree .
@@ -1,2 +0,0 @@
1
- // Place all the behaviors and hooks related to the matching controller here.
2
- // All this logic will automatically be available in application.js.
@@ -1,13 +0,0 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the top of the
9
- * compiled file, but it's generally better to create a new file per style scope.
10
- *
11
- *= require_self
12
- *= require_tree .
13
- */
@@ -1,4 +0,0 @@
1
- /*
2
- Place all the styles related to the matching controller here.
3
- They will automatically be included in application.css.
4
- */
@@ -1,4 +0,0 @@
1
- module SimpleContact
2
- module ApplicationHelper
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module SimpleContact
2
- module ContactHelper
3
- end
4
- end
@@ -1,11 +0,0 @@
1
- # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
-
3
- # This model initially had no columns defined. If you add columns to the
4
- # model remove the '{}' from the fixture names and add the columns immediately
5
- # below each fixture, per the syntax in the comments below
6
- #
7
- one: {}
8
- # column: value
9
- #
10
- two: {}
11
- # column: value
@@ -1,9 +0,0 @@
1
- require 'test_helper'
2
-
3
- module SimpleContact
4
- class ContactControllerTest < ActionController::TestCase
5
- # test "the truth" do
6
- # assert true
7
- # end
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- require 'test_helper'
2
-
3
- module SimpleContact
4
- class ContactMailerTest < ActionMailer::TestCase
5
- # test "the truth" do
6
- # assert true
7
- # end
8
- end
9
- end
@@ -1,10 +0,0 @@
1
- require 'test_helper'
2
-
3
- class NavigationTest < ActionDispatch::IntegrationTest
4
- fixtures :all
5
-
6
- # test "the truth" do
7
- # assert true
8
- # end
9
- end
10
-
@@ -1,6 +0,0 @@
1
- require 'test_helper'
2
-
3
- module SimpleContact
4
- class ContactHelperTest < ActionView::TestCase
5
- end
6
- end
@@ -1,9 +0,0 @@
1
- require 'test_helper'
2
-
3
- module SimpleContact
4
- class MessageTest < ActiveSupport::TestCase
5
- # test "the truth" do
6
- # assert true
7
- # end
8
- end
9
- end