Permalink
Browse files

Update to latest Rails & Contact Us versions.

  • Loading branch information...
1 parent c8145e8 commit cec96abe2dfa32a4a0138f38fc347e23b53ac91b @JDutil committed Feb 14, 2013
View
10 Gemfile
@@ -1,11 +1,11 @@
source 'http://rubygems.org'
-gem 'rails', '3.0.20'
+gem 'rails', '3.2.12'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
-gem 'contact_us', '~> 0.1.2'
+gem 'contact_us', '~> 0.4.0'
gem 'formtastic'
gem 'sass'
@@ -36,7 +36,7 @@ end
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
group :development, :test do
- gem "capybara", "~> 0.4.1"
- gem "rspec-rails", "~> 2.6"
- gem "simplecov", "~> 0.4.2"
+ gem "capybara", "~> 1.0"
+ gem "rspec-rails", "~> 2.10"
+ gem "simplecov"
end
View
193 Gemfile.lock
@@ -1,137 +1,136 @@
GEM
remote: http://rubygems.org/
specs:
- abstract (1.0.0)
- actionmailer (3.0.20)
- actionpack (= 3.0.20)
- mail (~> 2.2.19)
- actionpack (3.0.20)
- activemodel (= 3.0.20)
- activesupport (= 3.0.20)
- builder (~> 2.1.2)
- erubis (~> 2.6.6)
- i18n (~> 0.5.0)
- rack (~> 1.2.5)
- rack-mount (~> 0.6.14)
- rack-test (~> 0.5.7)
- tzinfo (~> 0.3.23)
- activemodel (3.0.20)
- activesupport (= 3.0.20)
- builder (~> 2.1.2)
- i18n (~> 0.5.0)
- activerecord (3.0.20)
- activemodel (= 3.0.20)
- activesupport (= 3.0.20)
- arel (~> 2.0.10)
- tzinfo (~> 0.3.23)
- activeresource (3.0.20)
- activemodel (= 3.0.20)
- activesupport (= 3.0.20)
- activesupport (3.0.20)
- arel (2.0.10)
- builder (2.1.2)
- capybara (0.4.1.2)
- celerity (>= 0.7.9)
- culerity (>= 0.2.4)
+ actionmailer (3.2.12)
+ actionpack (= 3.2.12)
+ mail (~> 2.4.4)
+ actionpack (3.2.12)
+ activemodel (= 3.2.12)
+ activesupport (= 3.2.12)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ journey (~> 1.0.4)
+ rack (~> 1.4.5)
+ rack-cache (~> 1.2)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.2.1)
+ activemodel (3.2.12)
+ activesupport (= 3.2.12)
+ builder (~> 3.0.0)
+ activerecord (3.2.12)
+ activemodel (= 3.2.12)
+ activesupport (= 3.2.12)
+ arel (~> 3.0.2)
+ tzinfo (~> 0.3.29)
+ activeresource (3.2.12)
+ activemodel (= 3.2.12)
+ activesupport (= 3.2.12)
+ activesupport (3.2.12)
+ i18n (~> 0.6)
+ multi_json (~> 1.0)
+ arel (3.0.2)
+ builder (3.0.4)
+ capybara (1.1.4)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
- selenium-webdriver (>= 0.0.27)
- xpath (~> 0.1.3)
- celerity (0.9.0)
- childprocess (0.2.2)
- ffi (~> 1.0.6)
- contact_us (0.1.2)
- formtastic (>= 1.2.0)
+ selenium-webdriver (~> 2.0)
+ xpath (~> 0.1.4)
+ childprocess (0.3.8)
+ ffi (~> 1.0, >= 1.0.11)
+ contact_us (0.4.0)
rails (>= 3.0.0)
- culerity (0.2.15)
diff-lcs (1.1.3)
- erubis (2.6.6)
- abstract (>= 1.0.0)
- ffi (1.0.9)
- formtastic (1.2.4)
- actionpack (>= 2.3.7)
- activesupport (>= 2.3.7)
- i18n (~> 0.4)
- i18n (0.5.0)
- json (1.7.6)
- json_pure (1.5.4)
- spruz (~> 0.2.8)
- mail (2.2.19)
- activesupport (>= 2.3.6)
+ erubis (2.7.0)
+ ffi (1.3.1)
+ formtastic (2.2.1)
+ actionpack (>= 3.0)
+ hike (1.2.1)
+ i18n (0.6.1)
+ journey (1.0.4)
+ json (1.7.7)
+ mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
- mime-types (1.19)
- nokogiri (1.5.0)
+ mime-types (1.21)
+ multi_json (1.6.0)
+ nokogiri (1.5.6)
pg (0.11.0)
polyglot (0.3.3)
- rack (1.2.7)
- rack-mount (0.6.14)
- rack (>= 1.0.0)
- rack-test (0.5.7)
+ rack (1.4.5)
+ rack-cache (1.2)
+ rack (>= 0.4)
+ rack-ssl (1.3.3)
+ rack
+ rack-test (0.6.2)
rack (>= 1.0)
- rails (3.0.20)
- actionmailer (= 3.0.20)
- actionpack (= 3.0.20)
- activerecord (= 3.0.20)
- activeresource (= 3.0.20)
- activesupport (= 3.0.20)
+ rails (3.2.12)
+ actionmailer (= 3.2.12)
+ actionpack (= 3.2.12)
+ activerecord (= 3.2.12)
+ activeresource (= 3.2.12)
+ activesupport (= 3.2.12)
bundler (~> 1.0)
- railties (= 3.0.20)
- railties (3.0.20)
- actionpack (= 3.0.20)
- activesupport (= 3.0.20)
+ railties (= 3.2.12)
+ railties (3.2.12)
+ actionpack (= 3.2.12)
+ activesupport (= 3.2.12)
+ rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
- thor (~> 0.14.4)
+ thor (>= 0.14.6, < 2.0)
rake (10.0.3)
- rdoc (3.12)
+ rdoc (3.12.1)
json (~> 1.4)
- rspec (2.6.0)
- rspec-core (~> 2.6.0)
- rspec-expectations (~> 2.6.0)
- rspec-mocks (~> 2.6.0)
- rspec-core (2.6.4)
- rspec-expectations (2.6.0)
- diff-lcs (~> 1.1.2)
- rspec-mocks (2.6.0)
- rspec-rails (2.6.1)
- actionpack (~> 3.0)
- activesupport (~> 3.0)
- railties (~> 3.0)
- rspec (~> 2.6.0)
- rubyzip (0.9.4)
+ rspec-core (2.12.2)
+ rspec-expectations (2.12.1)
+ diff-lcs (~> 1.1.3)
+ rspec-mocks (2.12.2)
+ rspec-rails (2.12.2)
+ actionpack (>= 3.0)
+ activesupport (>= 3.0)
+ railties (>= 3.0)
+ rspec-core (~> 2.12.0)
+ rspec-expectations (~> 2.12.0)
+ rspec-mocks (~> 2.12.0)
+ rubyzip (0.9.9)
sass (3.1.7)
- selenium-webdriver (2.5.0)
- childprocess (>= 0.2.1)
- ffi (>= 1.0.7)
- json_pure
+ selenium-webdriver (2.29.0)
+ childprocess (>= 0.2.5)
+ multi_json (~> 1.0)
rubyzip
+ websocket (~> 1.0.4)
simplecov (0.4.2)
simplecov-html (~> 0.4.4)
simplecov-html (0.4.5)
- spruz (0.2.13)
- sqlite3 (1.3.4)
- thor (0.14.6)
+ sprockets (2.2.2)
+ hike (~> 1.2)
+ multi_json (~> 1.0)
+ rack (~> 1.0)
+ tilt (~> 1.1, != 1.3.0)
+ sqlite3 (1.3.7)
+ thor (0.17.0)
+ tilt (1.3.3)
treetop (1.4.12)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.35)
+ websocket (1.0.7)
xpath (0.1.4)
nokogiri (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
- capybara (~> 0.4.1)
- contact_us (~> 0.1.2)
+ capybara (~> 1.0)
+ contact_us (~> 0.4.0)
formtastic
pg
- rails (= 3.0.20)
- rspec-rails (~> 2.6)
+ rails (= 3.2.12)
+ rspec-rails (~> 2.10)
sass
- simplecov (~> 0.4.2)
+ simplecov
sqlite3
View
3 app/views/contact_us/contact_mailer/contact_email.html.erb
@@ -1,3 +0,0 @@
-<p><%= @message %></p>
-<p>---------------------</p>
-<p><%= t('.sent_by_contact_form') %></p>
View
4 app/views/contact_us/contact_mailer/contact_email.text.plain.erb
@@ -1,4 +0,0 @@
-<%= @message %>
-
--------------------------------------
-<%= t('.sent_by_contact_form') %>
View
6 app/views/contact_us/contacts/new.html.erb
@@ -1,6 +0,0 @@
-<h2><%= t('.contact_us') %></h2>
-<%= semantic_form_for @contact, :url => contacts_path do |f| %>
- <%= f.input :email, :label => t('.email') %>
- <%= f.input :message, :as => :text, :label => t('.message') %>
- <%= f.commit_button t('.submit'), :button_html => { :alt => t('.submit'), :id => 'contact_us_contact_submit', :title => t('.submit') } %>
-<% end %>
View
1 config/environments/development.rb
@@ -11,7 +11,6 @@
# Show full error reports and disable caching
config.consider_all_requests_local = true
- config.action_view.debug_rjs = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send
View
25 config/initializers/contact_us.rb
@@ -1,6 +1,27 @@
# Use this hook to configure contact mailer.
ContactUs.setup do |config|
+
# ==> Mailer Configuration
- # Configure the e-mail address which will be shown in ContactMailer.
- config.mailer_to = "contact+demo@burlingtonwebapps.com"
+
+ # Configure the e-mail address which email notifications should be sent from. If emails must be sent from a verified email address you may set it here.
+ # Example:
+ # config.mailer_from = "contact@please-change-me.com"
+ config.mailer_from = nil
+
+ # Configure the e-mail address which should receive the contact form email notifications.
+ config.mailer_to = "support@burlingtonwebapps.com"
+
+ # ==> Form Configuration
+
+ # Configure the form to ask for the users name.
+ config.require_name = false
+
+ # Configure the form to ask for a subject.
+ config.require_subject = false
+
+ # Configure the form gem to use.
+ # Example:
+ # config.form_gem = 'formtastic
+ config.form_gem = 'formtastic'
+
end
View
16 db/schema.rb
@@ -0,0 +1,16 @@
+# encoding: UTF-8
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended to check this file into your version control system.
+
+ActiveRecord::Schema.define(:version => 0) do
+
+end
View
110 spec/integration/contact_us_lint_spec.rb
@@ -2,28 +2,35 @@
describe 'Contact Us page' do
- before do
- visit contact_us_path
- end
-
- it 'displays contact form' do
- page.should have_selector "form#new_contact_us_contact"
- end
-
- it "displays an input for email" do
- page.should have_selector "input#contact_us_contact_email"
+ after do
+ ActionMailer::Base.deliveries = []
+ ContactUs.mailer_from = nil
+ ContactUs.mailer_to = nil
+ ContactUs.require_name = false
+ ContactUs.require_subject = false
end
- it "displays a textarea for message" do
- page.should have_selector "textarea#contact_us_contact_message"
+ before do
+ ActionMailer::Base.deliveries = []
+ ContactUs.mailer_to = 'test@test.com'
end
- it "displays a submit button" do
- page.should have_selector "input#contact_us_contact_submit"
+ it 'displays default contact form properly', js:true do
+ visit contact_us_path
+ within "form#new_contact_us_contact" do
+ page.should have_selector "input#contact_us_contact_email"
+ page.should have_selector "textarea#contact_us_contact_message"
+ page.should_not have_selector "input#contact_us_contact_name"
+ page.should_not have_selector "input#contact_us_contact_subject"
+ page.should have_selector "input[type=submit]"
+ end
end
context "Submitting the form" do
- after { ActionMailer::Base.deliveries = [] }
+
+ before do
+ visit contact_us_path
+ end
context "when valid" do
before do
@@ -42,7 +49,7 @@
it "The email should have the correct attributes" do
mail = ActionMailer::Base.deliveries.last
- mail.to.should == [ContactUs.mailer_to]
+ mail.to.should == ['test@test.com']
mail.from.should == ['test@example.com']
mail.body.should match 'howdy'
end
@@ -57,8 +64,12 @@
end
it "I should see two error messages" do
- page.should have_content "is invalid"
- page.should have_content "can't be blank"
+ within '#contact_us_contact_email_input' do
+ page.should have_content "is invalid"
+ end
+ within '#contact_us_contact_message_input' do
+ page.should have_content "can't be blank"
+ end
end
it "An email should not have been sent" do
@@ -67,4 +78,67 @@
end
end
end
+
+ context 'with name and subject configuration' do
+
+ before do
+ ContactUs.require_name = true
+ ContactUs.require_subject = true
+ visit contact_us_path
+ end
+
+ it "displays an input for name and subject" do
+ page.should have_selector "input#contact_us_contact_name"
+ page.should have_selector "input#contact_us_contact_subject"
+ end
+
+ context "Submitting the form" do
+ context "when valid" do
+ before do
+ fill_in 'Email', :with => 'test@example.com'
+ fill_in 'Message', :with => 'howdy'
+ fill_in 'contact_us_contact[name]', :with => 'Jeff'
+ fill_in 'contact_us_contact[subject]', :with => 'Testing contact form.'
+ click_button 'Submit'
+ end
+
+ it "I should be redirected to the homepage" do
+ current_path.should == "/"
+ end
+
+ it "An email should have been sent" do
+ ActionMailer::Base.deliveries.size.should == 1
+ end
+
+ it "The email should have the correct attributes" do
+ mail = ActionMailer::Base.deliveries.last
+ mail.body.should match 'howdy'
+ mail.body.should match 'Jeff'
+ mail.from.should == ['test@example.com']
+ mail.subject.should match 'Testing contact form.'
+ mail.to.should == ['test@test.com']
+ end
+ end
+
+ context "when name and subject are blank" do
+ before do
+ click_button 'Submit'
+ end
+
+ it "I should see error messages" do
+ within '#contact_us_contact_name_input' do
+ page.should have_content "can't be blank"
+ end
+ within '#contact_us_contact_subject_input' do
+ page.should have_content "can't be blank"
+ end
+ end
+
+ it "An email should not have been sent" do
+ ActionMailer::Base.deliveries.size.should == 0
+ end
+ end
+ end
+ end
+
end

0 comments on commit cec96ab

Please sign in to comment.