Merge pull request #72 from AyuntamientoMadrid/confirmable-users

Confirmable users
This commit is contained in:
Enrique García
2015-07-31 15:03:47 +02:00
10 changed files with 56 additions and 15 deletions

View File

@@ -41,10 +41,8 @@ gem 'ckeditor'
group :development, :test do group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console # Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug' gem 'byebug'
# Access an IRB console on exception pages or by using <%= console %> in views # Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0' gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring' gem 'spring'
gem 'rspec-rails', '~> 3.0' gem 'rspec-rails', '~> 3.0'
@@ -52,6 +50,7 @@ group :development, :test do
gem 'factory_girl_rails' gem 'factory_girl_rails'
gem 'launchy' gem 'launchy'
gem 'quiet_assets' gem 'quiet_assets'
gem 'letter_opener_web', '~> 1.2.0'
end end
group :test do group :test do

View File

@@ -108,6 +108,11 @@ GEM
json (1.8.3) json (1.8.3)
launchy (2.4.3) launchy (2.4.3)
addressable (~> 2.3) addressable (~> 2.3)
letter_opener (1.4.1)
launchy (~> 2.2)
letter_opener_web (1.2.3)
letter_opener (~> 1.0)
rails (>= 3.2)
loofah (2.0.2) loofah (2.0.2)
nokogiri (>= 1.5.9) nokogiri (>= 1.5.9)
mail (2.6.3) mail (2.6.3)
@@ -234,6 +239,7 @@ DEPENDENCIES
jbuilder (~> 2.0) jbuilder (~> 2.0)
jquery-rails jquery-rails
launchy launchy
letter_opener_web (~> 1.2.0)
pg pg
poltergeist poltergeist
quiet_assets quiet_assets
@@ -247,3 +253,6 @@ DEPENDENCIES
turbolinks turbolinks
uglifier (>= 1.3.0) uglifier (>= 1.3.0)
web-console (~> 2.0) web-console (~> 2.0)
BUNDLED WITH
1.10.5

View File

@@ -1,5 +1,5 @@
class User < ActiveRecord::Base class User < ActiveRecord::Base
devise :database_authenticatable, :registerable, devise :database_authenticatable, :registerable, :confirmable,
:recoverable, :rememberable, :trackable, :validatable :recoverable, :rememberable, :trackable, :validatable
def name def name

View File

@@ -17,6 +17,9 @@ Rails.application.configure do
config.action_mailer.raise_delivery_errors = false config.action_mailer.raise_delivery_errors = false
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
# Deliver emails to a development mailbox at /letter_opener
config.action_mailer.delivery_method = :letter_opener
# Print deprecation notices to the Rails logger. # Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log config.active_support.deprecation = :log

View File

@@ -30,6 +30,10 @@ Rails.application.configure do
# The :test delivery method accumulates sent emails in the # The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array. # ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test config.action_mailer.delivery_method = :test
config.action_mailer.default_url_options = {
host: 'test'
}
config.action_mailer.asset_host = 'http://madrid.test'
# Randomize the order test cases are executed. # Randomize the order test cases are executed.
config.active_support.test_order = :random config.active_support.test_order = :random

View File

@@ -61,4 +61,8 @@ Rails.application.routes.draw do
# # (app/controllers/admin/products_controller.rb) # # (app/controllers/admin/products_controller.rb)
# resources :products # resources :products
# end # end
if Rails.env.development?
mount LetterOpenerWeb::Engine, at: "/letter_opener"
end
end end

View File

@@ -0,0 +1,13 @@
class AddConfirmableToDeviseForUsers < ActiveRecord::Migration
def change
# Confirmable
add_column :users, :confirmation_token, :string
add_column :users, :confirmed_at, :datetime
add_column :users, :confirmation_sent_at, :datetime
# Reconfirmable
add_column :users, :unconfirmed_email, :string
add_index :users, :confirmation_token, unique: true
end
end

View File

@@ -11,7 +11,10 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20150718091702) do ActiveRecord::Schema.define(version: 20150731110702) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
create_table "comments", force: :cascade do |t| create_table "comments", force: :cascade do |t|
t.integer "commentable_id" t.integer "commentable_id"
@@ -27,8 +30,8 @@ ActiveRecord::Schema.define(version: 20150718091702) do
t.datetime "updated_at" t.datetime "updated_at"
end end
add_index "comments", ["commentable_id", "commentable_type"], name: "index_comments_on_commentable_id_and_commentable_type" add_index "comments", ["commentable_id", "commentable_type"], name: "index_comments_on_commentable_id_and_commentable_type", using: :btree
add_index "comments", ["user_id"], name: "index_comments_on_user_id" add_index "comments", ["user_id"], name: "index_comments_on_user_id", using: :btree
create_table "debates", force: :cascade do |t| create_table "debates", force: :cascade do |t|
t.string "title" t.string "title"
@@ -48,15 +51,15 @@ ActiveRecord::Schema.define(version: 20150718091702) do
t.datetime "created_at" t.datetime "created_at"
end end
add_index "taggings", ["tag_id"], name: "index_taggings_on_tag_id" add_index "taggings", ["tag_id"], name: "index_taggings_on_tag_id", using: :btree
add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context" add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context", using: :btree
create_table "tags", force: :cascade do |t| create_table "tags", force: :cascade do |t|
t.string "name" t.string "name"
t.integer "taggings_count", default: 0 t.integer "taggings_count", default: 0
end end
add_index "tags", ["name"], name: "index_tags_on_name", unique: true add_index "tags", ["name"], name: "index_tags_on_name", unique: true, using: :btree
create_table "users", force: :cascade do |t| create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false t.string "email", default: "", null: false
@@ -73,10 +76,15 @@ ActiveRecord::Schema.define(version: 20150718091702) do
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.string "first_name" t.string "first_name"
t.string "last_name" t.string "last_name"
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.string "unconfirmed_email"
end end
add_index "users", ["email"], name: "index_users_on_email", unique: true add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
create_table "votes", force: :cascade do |t| create_table "votes", force: :cascade do |t|
t.integer "votable_id" t.integer "votable_id"
@@ -90,7 +98,7 @@ ActiveRecord::Schema.define(version: 20150718091702) do
t.datetime "updated_at" t.datetime "updated_at"
end end
add_index "votes", ["votable_id", "votable_type", "vote_scope"], name: "index_votes_on_votable_id_and_votable_type_and_vote_scope" add_index "votes", ["votable_id", "votable_type", "vote_scope"], name: "index_votes_on_votable_id_and_votable_type_and_vote_scope", using: :btree
add_index "votes", ["voter_id", "voter_type", "vote_scope"], name: "index_votes_on_voter_id_and_voter_type_and_vote_scope" add_index "votes", ["voter_id", "voter_type", "vote_scope"], name: "index_votes_on_voter_id_and_voter_type_and_vote_scope", using: :btree
end end

View File

@@ -5,6 +5,7 @@ FactoryGirl.define do
last_name 'Carmena' last_name 'Carmena'
sequence(:email) { |n| "manuela#{n}@madrid.es" } sequence(:email) { |n| "manuela#{n}@madrid.es" }
password 'judgmentday' password 'judgmentday'
confirmed_at { Time.now }
end end
factory :debate do factory :debate do
@@ -19,7 +20,7 @@ FactoryGirl.define do
association :voter, factory: :user association :voter, factory: :user
vote_flag true vote_flag true
end end
factory :comment do factory :comment do
commentable commentable
user user

View File

@@ -14,7 +14,7 @@ feature 'Users' do
click_button 'Sign up' click_button 'Sign up'
expect(page).to have_content 'Welcome! You have signed up successfully.' expect(page).to have_content "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
end end
scenario 'Sign in' do scenario 'Sign in' do