Skip to content

Commit

Permalink
Test Rails 4.2. Everything works!
Browse files Browse the repository at this point in the history
  • Loading branch information
brianhempel committed Mar 30, 2015
1 parent e18a5b2 commit 35c6001
Show file tree
Hide file tree
Showing 67 changed files with 1,183 additions and 9 deletions.
14 changes: 10 additions & 4 deletions Gemfile
Expand Up @@ -8,11 +8,13 @@ RAILS_VERS = case ENV['RAILS_VERS']
when '4.0'
'~>4.0.5'
when '4.1'
'~>4.1.2.rc2'
'~>4.1.10'
when '4.2'
'~>4.2.1'
when nil
nil
else
raise "Invalid RAILS_VERS. Available versions are 3.2 and 4.0."
raise "Invalid RAILS_VERS. Available versions are 3.1, 3.2, 4.0, 4.1, and 4.2."
end

gemspec :name => 'mongo_session_store-rails4'
Expand Down Expand Up @@ -48,8 +50,12 @@ group :development, :test do
else
gem 'sqlite3' # for devise User storage
end
RAILS_VERS ? gem('rails', RAILS_VERS) : gem('rails')
gem 'minitest' if ENV['RAILS_VERS'] == '4.1'
if RAILS_VERS
gem 'rails', RAILS_VERS
gem 'minitest' if ENV['RAILS_VERS'] >= '4.1'
else
gem 'rails'
end

gem 'rspec-rails', '2.12.0'
gem 'devise'
Expand Down
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -4,7 +4,7 @@

MongoSessionStore is a collection of Rails-compatible session stores for MongoMapper and Mongoid, but also included is a generic Mongo store that works with any (or no!) Mongo ODM.

MongoSessionStore is tested [on Travis CI](https://travis-ci.org/brianhempel/mongo_session_store) against Ruby 1.9.3, 2.0.0, 2.1.2, and JRuby with Rails 3.1 through 4.1.
MongoSessionStore is tested [on Travis CI](https://travis-ci.org/brianhempel/mongo_session_store) against Ruby 1.9.3, 2.0.0, 2.1.2, and JRuby with Rails 3.1 through 4.2.

Mongoid users: This gem is compatible with both Mongoid 3 and 4.

Expand All @@ -14,7 +14,7 @@ See the [Changelog](#changelog) if you need support for an older version of Ruby

## Usage

MongoSessionStore is compatible with Rails 3.1 through 4.1.
MongoSessionStore is compatible with Rails 3.1 through 4.2.

In your Gemfile:

Expand Down Expand Up @@ -61,7 +61,7 @@ MongoStore::Session.where('updated_at' => { '$gt' => 2.days.ago })
## Changelog
6.0.0 supports the Mongo 2.0 driver for the generic MongoStore. The other stores are unchanged.
6.0.0 supports the Mongo 2.0 driver for the generic MongoStore. The other stores are unchanged. Tests added for Rails 4.2.
5.1.0 generates a new session ID when a session is not found. Previously, when a session ID is provided in the request but the session was not found (because for example, it was removed from Mongo by a sweeper job) a new session with the provided ID would be created. This would cause a write error if two simultaneous requests both create a session with the same ID and both try to insert a new document with that ID.
Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Expand Up @@ -20,12 +20,12 @@ def set_versions(rails_vers, orm)
success
end

@rails_versions = ['3.1', '3.2', '4.0', '4.1']
@rails_versions = ['3.1', '3.2', '4.0', '4.1', '4.2']
@orms = ['mongo_mapper', 'mongoid', 'mongo']

task :default => :test_all

desc 'Test each session store against Rails 3.1, 3.2, 4.0, and 4.1'
desc 'Test each session store against Rails 3.1, 3.2, 4.0, 4.1, and 4.2'
task :test_all do
# inspired by http://pivotallabs.com/users/jdean/blog/articles/1728-testing-your-gem-against-multiple-rubies-and-rails-versions-with-rvm

Expand Down
17 changes: 17 additions & 0 deletions spec/rails_4.2_app/.gitignore
@@ -0,0 +1,17 @@
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'

# Ignore bundler config.
/.bundle

# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal

# Ignore all logfiles and tempfiles.
/log/*
!/log/.keep
/tmp
6 changes: 6 additions & 0 deletions spec/rails_4.2_app/Rakefile
@@ -0,0 +1,6 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)

Rails.application.load_tasks
Empty file.
13 changes: 13 additions & 0 deletions spec/rails_4.2_app/app/assets/javascripts/application.js
@@ -0,0 +1,13 @@
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require_tree .
15 changes: 15 additions & 0 deletions spec/rails_4.2_app/app/assets/stylesheets/application.css
@@ -0,0 +1,15 @@
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_tree .
*= require_self
*/
5 changes: 5 additions & 0 deletions spec/rails_4.2_app/app/controllers/application_controller.rb
@@ -0,0 +1,5 @@
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
end
Empty file.
4 changes: 4 additions & 0 deletions spec/rails_4.2_app/app/controllers/home_controller.rb
@@ -0,0 +1,4 @@
class HomeController < ApplicationController
def index
end
end
2 changes: 2 additions & 0 deletions spec/rails_4.2_app/app/helpers/application_helper.rb
@@ -0,0 +1,2 @@
module ApplicationHelper
end
Empty file.
Empty file.
Empty file.
5 changes: 5 additions & 0 deletions spec/rails_4.2_app/app/models/user.rb
@@ -0,0 +1,5 @@
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable
end
12 changes: 12 additions & 0 deletions spec/rails_4.2_app/app/views/devise/confirmations/new.html.erb
@@ -0,0 +1,12 @@
<h2>Resend confirmation instructions</h2>

<%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %>
<%= devise_error_messages! %>

<div><%= f.label :email %><br />
<%= f.email_field :email, :autofocus => true %></div>

<div><%= f.submit "Resend confirmation instructions" %></div>
<% end %>
<%= render "devise/shared/links" %>
@@ -0,0 +1,5 @@
<p>Welcome <%= @email %>!</p>

<p>You can confirm your account email through the link below:</p>

<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @token) %></p>
@@ -0,0 +1,8 @@
<p>Hello <%= @resource.email %>!</p>

<p>Someone has requested a link to change your password. You can do this through the link below.</p>

<p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @token) %></p>

<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>
@@ -0,0 +1,7 @@
<p>Hello <%= @resource.email %>!</p>

<p>Your account has been locked due to an excessive number of unsuccessful sign in attempts.</p>

<p>Click the link below to unlock your account:</p>

<p><%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @token) %></p>
16 changes: 16 additions & 0 deletions spec/rails_4.2_app/app/views/devise/passwords/edit.html.erb
@@ -0,0 +1,16 @@
<h2>Change your password</h2>

<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %>
<%= devise_error_messages! %>
<%= f.hidden_field :reset_password_token %>

<div><%= f.label :password, "New password" %><br />
<%= f.password_field :password, :autofocus => true %></div>

<div><%= f.label :password_confirmation, "Confirm new password" %><br />
<%= f.password_field :password_confirmation %></div>

<div><%= f.submit "Change my password" %></div>
<% end %>
<%= render "devise/shared/links" %>
12 changes: 12 additions & 0 deletions spec/rails_4.2_app/app/views/devise/passwords/new.html.erb
@@ -0,0 +1,12 @@
<h2>Forgot your password?</h2>

<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %>
<%= devise_error_messages! %>

<div><%= f.label :email %><br />
<%= f.email_field :email, :autofocus => true %></div>

<div><%= f.submit "Send me reset password instructions" %></div>
<% end %>
<%= render "devise/shared/links" %>
29 changes: 29 additions & 0 deletions spec/rails_4.2_app/app/views/devise/registrations/edit.html.erb
@@ -0,0 +1,29 @@
<h2>Edit <%= resource_name.to_s.humanize %></h2>

<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
<%= devise_error_messages! %>

<div><%= f.label :email %><br />
<%= f.email_field :email, :autofocus => true %></div>

<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
<div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div>
<% end %>

<div><%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
<%= f.password_field :password, :autocomplete => "off" %></div>

<div><%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation %></div>

<div><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
<%= f.password_field :current_password %></div>

<div><%= f.submit "Update" %></div>
<% end %>

<h3>Cancel my account</h3>

<p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete %></p>

<%= link_to "Back", :back %>
18 changes: 18 additions & 0 deletions spec/rails_4.2_app/app/views/devise/registrations/new.html.erb
@@ -0,0 +1,18 @@
<h2>Sign up</h2>

<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>

<div><%= f.label :email %><br />
<%= f.email_field :email, :autofocus => true %></div>

<div><%= f.label :password %><br />
<%= f.password_field :password %></div>

<div><%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation %></div>

<div><%= f.submit "Sign up" %></div>
<% end %>
<%= render "devise/shared/links" %>
17 changes: 17 additions & 0 deletions spec/rails_4.2_app/app/views/devise/sessions/new.html.erb
@@ -0,0 +1,17 @@
<h2>Sign in</h2>

<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
<div><%= f.label :email %><br />
<%= f.email_field :email, :autofocus => true %></div>

<div><%= f.label :password %><br />
<%= f.password_field :password %></div>

<% if devise_mapping.rememberable? -%>
<div><%= f.check_box :remember_me %> <%= f.label :remember_me %></div>
<% end -%>

<div><%= f.submit "Sign in" %></div>
<% end %>
<%= render "devise/shared/links" %>
25 changes: 25 additions & 0 deletions spec/rails_4.2_app/app/views/devise/shared/_links.erb
@@ -0,0 +1,25 @@
<%- if controller_name != 'sessions' %>
<%= link_to "Sign in", new_session_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.omniauthable? %>
<%- resource_class.omniauth_providers.each do |provider| %>
<%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
<% end -%>
<% end -%>
12 changes: 12 additions & 0 deletions spec/rails_4.2_app/app/views/devise/unlocks/new.html.erb
@@ -0,0 +1,12 @@
<h2>Resend unlock instructions</h2>

<%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| %>
<%= devise_error_messages! %>

<div><%= f.label :email %><br />
<%= f.email_field :email, :autofocus => true %></div>

<div><%= f.submit "Resend unlock instructions" %></div>
<% end %>
<%= render "devise/shared/links" %>
10 changes: 10 additions & 0 deletions spec/rails_4.2_app/app/views/home/index.html.erb
@@ -0,0 +1,10 @@
You are logged
<% if user_signed_in? %>
in as <%= current_user.email %>.
<form method="post" action="<%= destroy_user_session_path %>">
<input type="hidden" name="_method" value="delete" />
<input type="submit" value="Sign out" />
</form>
<% else %>
out. <%= link_to "Sign in", new_user_session_path %>
<% end %>
17 changes: 17 additions & 0 deletions spec/rails_4.2_app/app/views/layouts/application.html.erb
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<title>Rails41App</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>

<%= notice %>
<%= alert %>
<%= yield %>

</body>
</html>
3 changes: 3 additions & 0 deletions spec/rails_4.2_app/bin/bundle
@@ -0,0 +1,3 @@
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
load Gem.bin_path('bundler', 'bundle')
8 changes: 8 additions & 0 deletions spec/rails_4.2_app/bin/rails
@@ -0,0 +1,8 @@
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'
8 changes: 8 additions & 0 deletions spec/rails_4.2_app/bin/rake
@@ -0,0 +1,8 @@
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
require_relative '../config/boot'
require 'rake'
Rake.application.run

0 comments on commit 35c6001

Please sign in to comment.