contact_us 1.0.0 → 1.0.1
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/.rspec +1 -1
- data/.travis.yml +3 -3
- data/CHANGELOG.md +4 -0
- data/README.md +4 -4
- data/config/locales/contact_us.zh-TW.yml +22 -0
- data/contact_us.gemspec +1 -1
- data/lib/contact_us/version.rb +1 -1
- data/spec/controllers/contact_us/contact_controller_spec.rb +11 -11
- data/spec/lib/contact_us_spec.rb +6 -6
- data/spec/lib/install_spec.rb +10 -10
- data/spec/mailers/contact_us/contact_mailer_spec.rb +9 -9
- data/spec/models/contact_us/contact_spec.rb +13 -13
- data/spec/spec_helper.rb +1 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25ce3fc3f61176e4316093a69ae09512d69e4a99
|
4
|
+
data.tar.gz: d0928b97ea89efb8689f0701b0e36cb7e95a6749
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7bcd8411ea722451e81c8358ef20ab0d32599747a3b2ea9c606286b32b4863faef3ec5728f24feb719017137039f3805965b1c3165e6faf0beef59efae38db2
|
7
|
+
data.tar.gz: 8cb4ef14ed3f465becd3271acdb2da7c3a0d19f44fd49996ef45be716476ace326d872cdecac5cf6d1edf1bec319744e51752e8c6f9873124b5059288460d072
|
data/.rspec
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Contact Us [](http://travis-ci.org/JDutil/contact_us) [](https://gemnasium.com/jdutil/contact_us) [][pledgie]
|
2
2
|
A Rails 3+ Engine providing a basic contact form.
|
3
3
|
|
4
4
|
[travis]: http://travis-ci.org/jdutil/contact_us
|
@@ -7,7 +7,7 @@ A Rails 3+ Engine providing a basic contact form.
|
|
7
7
|
|
8
8
|
There is also a demo application showing how the ContactUs form works:
|
9
9
|
|
10
|
-
* [View Demo Form In Action](http://contact-us-demo.
|
10
|
+
* [View Demo Form In Action](http://contact-us-demo.herokuapp.com)
|
11
11
|
* [View Demo Applications Source Code](http://github.com/jdutil/contact_us_demo)
|
12
12
|
|
13
13
|
## REQUIREMENTS
|
@@ -24,7 +24,7 @@ It is also recommended to use Formtastic or SimpleForm (see configuration) in or
|
|
24
24
|
In your `Gemfile`, add the following dependencies:
|
25
25
|
|
26
26
|
```ruby
|
27
|
-
gem 'contact_us', '~> 0.
|
27
|
+
gem 'contact_us', '~> 1.0.1'
|
28
28
|
```
|
29
29
|
|
30
30
|
From `Rails.root` in your Terminal run:
|
@@ -127,7 +127,7 @@ Visit your website and navigate to `/contact-us` to see the form in action.
|
|
127
127
|
|
128
128
|
Contact Us has 100% test coverage, and provides simple integration specs you can drop directly into your apps test suite if you use RSpec & Capybara.
|
129
129
|
|
130
|
-
Simply copy the `spec/integration/contact_us_lint_spec.rb` file, and add it to your integration specs.
|
130
|
+
Simply copy the `spec/integration/contact_us_lint_spec.rb` file, and add it to your integration specs.
|
131
131
|
|
132
132
|
## ISSUES
|
133
133
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
zh:
|
2
|
+
contact_us:
|
3
|
+
contact_mailer:
|
4
|
+
contact_email:
|
5
|
+
sent_by_contact_form: "由【聯絡我們】頁發送 %{email}"
|
6
|
+
sent_by_name: "由 %{name} 寄出 從 %{email}"
|
7
|
+
subject: "由 %{email} 寄出的訊息"
|
8
|
+
contacts:
|
9
|
+
new: &new
|
10
|
+
contact_us: "聯絡我們"
|
11
|
+
email: "電子郵件"
|
12
|
+
message: "訊息"
|
13
|
+
name: "姓名"
|
14
|
+
subject: "主題"
|
15
|
+
submit: "發送"
|
16
|
+
new_formtastic:
|
17
|
+
<<: *new
|
18
|
+
new_simple_form:
|
19
|
+
<<: *new
|
20
|
+
notices:
|
21
|
+
error: "請檢查是否正確填寫所有欄位。"
|
22
|
+
success: "訊息已成功送出。"
|
data/contact_us.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
22
|
s.add_development_dependency "capybara", "~> 2.0"
|
23
|
-
s.add_development_dependency "rspec-rails", "~>
|
23
|
+
s.add_development_dependency "rspec-rails", "~> 3.1"
|
24
24
|
s.add_development_dependency "shoulda-matchers", ">= 1.5.4"
|
25
25
|
s.add_development_dependency "simplecov", "~> 0.7"
|
26
26
|
s.add_development_dependency "sqlite3", "~> 1.3.5"
|
data/lib/contact_us/version.rb
CHANGED
@@ -11,25 +11,25 @@ describe ContactUs::ContactsController do
|
|
11
11
|
it 'should redirect with success message if valid contact' do
|
12
12
|
ContactUs.success_redirect = nil
|
13
13
|
post :create, :contact_us_contact => { :email => 'test@test.com', :message => 'test' }
|
14
|
-
assigns(:contact).valid
|
15
|
-
flash[:notice].
|
16
|
-
response.
|
14
|
+
expect(assigns(:contact).valid?).to eql(true)
|
15
|
+
expect(flash[:notice]).to eql('Contact email was successfully sent.')
|
16
|
+
expect(response).to redirect_to('/')
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'should redirect to custom URL with success message if valid contact' do
|
20
20
|
ContactUs.success_redirect = '/success'
|
21
21
|
post :create, :contact_us_contact => { :email => 'test@test.com', :message => 'test' }
|
22
|
-
assigns(:contact).valid
|
23
|
-
flash[:notice].
|
24
|
-
response.
|
22
|
+
expect(assigns(:contact).valid?).to eql(true)
|
23
|
+
expect(flash[:notice]).to eql('Contact email was successfully sent.')
|
24
|
+
expect(response).to redirect_to('/success')
|
25
25
|
ContactUs.success_redirect = '/'
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'should render new with error message if invalid contact' do
|
29
29
|
post :create, :contact_us_contact => { :email => 'test@test.com', :message => '' }
|
30
|
-
assigns(:contact).valid
|
31
|
-
flash[:error].
|
32
|
-
response.
|
30
|
+
expect(assigns(:contact).valid?).to eql(false)
|
31
|
+
expect(flash[:error]).to eql('You must enter both fields.')
|
32
|
+
expect(response).to render_template('new')
|
33
33
|
end
|
34
34
|
|
35
35
|
end
|
@@ -38,8 +38,8 @@ describe ContactUs::ContactsController do
|
|
38
38
|
|
39
39
|
it 'should assign contact for form and render page successfully' do
|
40
40
|
get :new
|
41
|
-
assigns(:contact).
|
42
|
-
response.
|
41
|
+
expect(assigns(:contact)).to be_an_instance_of(ContactUs::Contact)
|
42
|
+
expect(response).to be_success
|
43
43
|
end
|
44
44
|
|
45
45
|
end
|
data/spec/lib/contact_us_spec.rb
CHANGED
@@ -11,13 +11,13 @@ describe ContactUs do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should be valid" do
|
14
|
-
ContactUs.
|
14
|
+
expect(ContactUs).to be_a(Module)
|
15
15
|
end
|
16
16
|
|
17
17
|
describe 'setup block' do
|
18
18
|
it 'should yield self' do
|
19
19
|
ContactUs.setup do |config|
|
20
|
-
ContactUs.
|
20
|
+
expect(ContactUs).to eql(config)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -25,28 +25,28 @@ describe ContactUs do
|
|
25
25
|
describe 'mailer_from' do
|
26
26
|
it 'should be configurable' do
|
27
27
|
ContactUs.mailer_from = "contact@please-change-me.com"
|
28
|
-
ContactUs.mailer_from.
|
28
|
+
expect(ContactUs.mailer_from).to eql("contact@please-change-me.com")
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
describe 'mailer_to' do
|
33
33
|
it 'should be configurable' do
|
34
34
|
ContactUs.mailer_to = "contact@please-change-me.com"
|
35
|
-
ContactUs.mailer_to.
|
35
|
+
expect(ContactUs.mailer_to).to eql("contact@please-change-me.com")
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
describe 'require_name' do
|
40
40
|
it 'should be configurable' do
|
41
41
|
ContactUs.require_name = true
|
42
|
-
ContactUs.require_name.
|
42
|
+
expect(ContactUs.require_name).to eql(true)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
describe 'require_subject' do
|
47
47
|
it 'should be configurable' do
|
48
48
|
ContactUs.require_subject = true
|
49
|
-
ContactUs.require_subject.
|
49
|
+
expect(ContactUs.require_subject).to eql(true)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
data/spec/lib/install_spec.rb
CHANGED
@@ -13,11 +13,11 @@ describe "Rake tasks" do
|
|
13
13
|
|
14
14
|
before(:each) do
|
15
15
|
@destination_root = File.expand_path("../../dummy", __FILE__)
|
16
|
-
File.exists?(@destination_root + "/config/initializers/contact_us.rb").
|
17
|
-
File.exists?(@destination_root + "/config/locales/contact_us.en.yml").
|
18
|
-
File.directory?(@destination_root + "/app/views/contact_us").
|
19
|
-
File.directory?(@destination_root + "/app/views/contact_us/contact_mailer").
|
20
|
-
File.directory?(@destination_root + "/app/views/contact_us/contacts").
|
16
|
+
expect(File.exists?(@destination_root + "/config/initializers/contact_us.rb")).to eql(false)
|
17
|
+
expect(File.exists?(@destination_root + "/config/locales/contact_us.en.yml")).to eql(false)
|
18
|
+
expect(File.directory?(@destination_root + "/app/views/contact_us")).to eql(false)
|
19
|
+
expect(File.directory?(@destination_root + "/app/views/contact_us/contact_mailer")).to eql(false)
|
20
|
+
expect(File.directory?(@destination_root + "/app/views/contact_us/contacts")).to eql(false)
|
21
21
|
end
|
22
22
|
|
23
23
|
describe "contact_us:install" do
|
@@ -27,7 +27,7 @@ describe "Rake tasks" do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
it "creates initializer file" do
|
30
|
-
File.exists?(File.join(@destination_root + "/config/initializers/contact_us.rb")).
|
30
|
+
expect(File.exists?(File.join(@destination_root + "/config/initializers/contact_us.rb"))).to eql(true)
|
31
31
|
end
|
32
32
|
|
33
33
|
end
|
@@ -38,7 +38,7 @@ describe "Rake tasks" do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
it "creates locales files" do
|
41
|
-
File.exists?(File.join(@destination_root + "/config/locales/contact_us.en.yml")).
|
41
|
+
expect(File.exists?(File.join(@destination_root + "/config/locales/contact_us.en.yml"))).to eql(true)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -49,9 +49,9 @@ describe "Rake tasks" do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
it "creates view files" do
|
52
|
-
File.directory?(@destination_root + "/app/views/contact_us").
|
53
|
-
File.directory?(@destination_root + "/app/views/contact_us/contact_mailer").
|
54
|
-
File.directory?(@destination_root + "/app/views/contact_us/contacts").
|
52
|
+
expect(File.directory?(@destination_root + "/app/views/contact_us")).to eql(true)
|
53
|
+
expect(File.directory?(@destination_root + "/app/views/contact_us/contact_mailer")).to eql(true)
|
54
|
+
expect(File.directory?(@destination_root + "/app/views/contact_us/contacts")).to eql(true)
|
55
55
|
end
|
56
56
|
|
57
57
|
end
|
@@ -10,13 +10,13 @@ describe ContactUs::ContactMailer do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should render successfully" do
|
13
|
-
|
13
|
+
expect { ContactUs::ContactMailer.contact_email(@contact) }.not_to raise_error
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should use the ContactUs.mailer_from setting when it is set" do
|
17
17
|
ContactUs.mailer_from = "contact@please-change-me.com"
|
18
18
|
@mailer = ContactUs::ContactMailer.contact_email(@contact)
|
19
|
-
@mailer.from.
|
19
|
+
expect(@mailer.from).to eql([ContactUs.mailer_from])
|
20
20
|
ContactUs.mailer_from = nil
|
21
21
|
end
|
22
22
|
|
@@ -27,33 +27,33 @@ describe ContactUs::ContactMailer do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should have the initializers to address" do
|
30
|
-
@mailer.to.
|
30
|
+
expect(@mailer.to).to eql([ContactUs.mailer_to])
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should use the users email in the from field when ContactUs.mailer_from is not set" do
|
34
|
-
@mailer.from.
|
34
|
+
expect(@mailer.from).to eql([@contact.email])
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should use the users email in the reply_to field" do
|
38
|
-
@mailer.reply_to.
|
38
|
+
expect(@mailer.reply_to).to eql([@contact.email])
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should have users email in the subject line" do
|
42
|
-
@mailer.subject.
|
42
|
+
expect(@mailer.subject).to eql("Contact Us message from #{@contact.email}")
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should have the message in the body" do
|
46
|
-
@mailer.body.
|
46
|
+
expect(@mailer.body).to match("<p>Thanks!</p>")
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should deliver successfully" do
|
50
|
-
|
50
|
+
expect { ContactUs::ContactMailer.contact_email(@contact).deliver_now }.not_to raise_error
|
51
51
|
end
|
52
52
|
|
53
53
|
describe "and delivered" do
|
54
54
|
|
55
55
|
it "should be added to the delivery queue" do
|
56
|
-
|
56
|
+
expect { ContactUs::ContactMailer.contact_email(@contact).deliver_now }.to change(ActionMailer::Base.deliveries,:size).by(1)
|
57
57
|
end
|
58
58
|
|
59
59
|
end
|
@@ -5,10 +5,10 @@ describe ContactUs::Contact do
|
|
5
5
|
|
6
6
|
describe "Validations" do
|
7
7
|
|
8
|
-
it {
|
9
|
-
it {
|
10
|
-
it {
|
11
|
-
it {
|
8
|
+
it {is_expected.to validate_presence_of(:email)}
|
9
|
+
it {is_expected.to validate_presence_of(:message)}
|
10
|
+
it {is_expected.not_to validate_presence_of(:name)}
|
11
|
+
it {is_expected.not_to validate_presence_of(:subject)}
|
12
12
|
|
13
13
|
context 'with name and subject settings' do
|
14
14
|
|
@@ -22,8 +22,8 @@ describe ContactUs::Contact do
|
|
22
22
|
ContactUs.require_subject =true
|
23
23
|
end
|
24
24
|
|
25
|
-
it {
|
26
|
-
it {
|
25
|
+
it {is_expected.to validate_presence_of(:name)}
|
26
|
+
it {is_expected.to validate_presence_of(:subject)}
|
27
27
|
|
28
28
|
end
|
29
29
|
|
@@ -34,8 +34,8 @@ describe ContactUs::Contact do
|
|
34
34
|
describe '#read_attribute_for_validation' do
|
35
35
|
it 'should return attributes set during initialization' do
|
36
36
|
contact = ContactUs::Contact.new(:email => "Valid@Email.com", :message => "Test")
|
37
|
-
contact.read_attribute_for_validation(:email).
|
38
|
-
contact.read_attribute_for_validation(:message).
|
37
|
+
expect(contact.read_attribute_for_validation(:email)).to eql("Valid@Email.com")
|
38
|
+
expect(contact.read_attribute_for_validation(:message)).to eql("Test")
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -43,21 +43,21 @@ describe ContactUs::Contact do
|
|
43
43
|
|
44
44
|
it 'should return false if records invalid' do
|
45
45
|
contact = ContactUs::Contact.new(:email => "Valid@Email.com", :message => "")
|
46
|
-
contact.save.
|
46
|
+
expect(contact.save).to eql(false)
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'should send email and return true if records valid' do
|
50
50
|
mail = Mail.new(:from=>"Valid@Email.com", :to => "test@test.com")
|
51
|
-
mail.
|
51
|
+
allow(mail).to receive(:deliver_now).and_return(true)
|
52
52
|
contact = ContactUs::Contact.new(:email => "Valid@Email.com", :message => "Test")
|
53
|
-
ContactUs::ContactMailer.
|
54
|
-
contact.save.
|
53
|
+
expect(ContactUs::ContactMailer).to receive(:contact_email).with(contact).and_return(mail)
|
54
|
+
expect(contact.save).to eql(true)
|
55
55
|
end
|
56
56
|
|
57
57
|
end
|
58
58
|
|
59
59
|
describe '#to_key' do
|
60
|
-
it { subject.
|
60
|
+
it { expect(subject).to respond_to(:to_key) }
|
61
61
|
end
|
62
62
|
|
63
63
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contact_us
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Dutil
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '3.1'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '3.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: shoulda-matchers
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -159,6 +159,7 @@ files:
|
|
159
159
|
- config/locales/contact_us.pt-BR.yml
|
160
160
|
- config/locales/contact_us.pt-PT.yml
|
161
161
|
- config/locales/contact_us.ru.yml
|
162
|
+
- config/locales/contact_us.zh-TW.yml
|
162
163
|
- config/locales/contact_us.zh.yml
|
163
164
|
- config/routes.rb
|
164
165
|
- contact_us.gemspec
|