Skip to content

Commit

Permalink
Update templates (#786)
Browse files Browse the repository at this point in the history
* Stylistic changes

To make them look more like Devise templates

* Replace p tags with div tags with specific classes (using Rails/Devise conventions)

* Remove deprecated devise_error_messages! with partial

* Add partial for error rendering

Replaces devise_error_messages!

* Replace deprecated devise_error_messages! with error_notification for simple_form

* Update test templates

* Remove whitespace

* Add error partial to test/rails_app

* Remove error partial

* Change devise dependency from ~> to >=

* Do not test Ruby 2.2.10

* Remove explicit jdk version from travis

* Update changelog

* Whitespace

* Remove commented-out methods

* Wrap elements in div tags with specific CSS classes

To match Devise

* Change devise_invitable version to 2.0.0 in README [ci skip]

* Fix weird layout in README [skip ci]

* Remove instructions describing old devise releases from README [skip ci]

* Clarify instructions on how to use devise_invitable with different devise releases

* Annotate variables  in README so they stand out from the rest of the text [skip ci]

* Consistent case when using Devise and DeviseInvitable [skip ci]

* Replace a closing tag with an opening tag [skip ci]

* Annotate code in README [skip ci]

* Remove instructions on how to use devise_invitable with older devise releases (3.2) [skip ci]

* Whitespace for alignment [skip ci]

* Annotate code, rewrite sentences in README [skip ci]

* Annotate even more code, rewrite sentences [skip ci]

* Annotate even more code, for the last time! [skip ci]

* Add a note about requirements [skip ci]

* Change jruby-9.2.6.0 to jruby-head

* Specify xenial dist for Travis tests

* Remove jruby-head from travis

Too unpredictable

* Stylistic changes
  • Loading branch information
jmstfv authored and scambra committed Feb 25, 2019
1 parent 8c313de commit 2616684
Show file tree
Hide file tree
Showing 25 changed files with 182 additions and 148 deletions.
23 changes: 13 additions & 10 deletions .travis.yml
@@ -1,42 +1,45 @@
dist: xenial
language: ruby
sudo: false

cache: bundler

before_install:
- gem update --system
- gem install bundler
sudo: false
cache: bundler

rvm:
- 2.2.10
- 2.3.8
- 2.4.5
- 2.5.3
- 2.6.1
- ruby-head
- jruby-9.2.6.0
jdk:
- openjdk11

script: bundle exec rake test

env:
matrix:
- DEVISE_ORM=active_record
- DEVISE_ORM=mongoid

gemfile:
- Gemfile
- gemfiles/Gemfile.rails-5.0
- gemfiles/Gemfile.rails-5.1
- gemfiles/Gemfile.rails-5.2
- gemfiles/Gemfile.rails-master
install: "travis_retry bundle install"

install: travis_retry bundle install

services:
- mongodb

matrix:
exclude:
- rvm: 2.2.10
gemfile: gemfiles/Gemfile.rails-master
- rvm: 2.3.8
gemfile: gemfiles/Gemfile.rails-master
- rvm: 2.4.5
gemfile: gemfiles/Gemfile.rails-master
allow_failures:
- rvm: jruby-9.2.6.0
- rvm: ruby-head
- gemfile: gemfiles/Gemfile.rails-master
6 changes: 6 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,9 @@
## 2.0.0
- Remove deprecated devise_error_messages! from templates ([#786](https://github.com/scambra/devise_invitable/pull/785))
- Drop Devise < 4.6 support ([#786](https://github.com/scambra/devise_invitable/pull/786))
- Drop Rails 4.2 support ([#785](https://github.com/scambra/devise_invitable/pull/785))
- Drop Ruby 2.1 support

## 1.7.5
- Add add_taken_error ([#768](https://github.com/scambra/devise_invitable/pull/768))
- Add invitation_taken? ([#769](https://github.com/scambra/devise_invitable/pull/769))
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Expand Up @@ -3,7 +3,7 @@ PATH
specs:
devise_invitable (1.7.5)
actionmailer (>= 5.0)
devise (~> 4.6)
devise (>= 4.6)

GEM
remote: https://rubygems.org/
Expand Down
107 changes: 52 additions & 55 deletions README.rdoc

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/controllers/devise/invitations_controller.rb
Expand Up @@ -62,7 +62,7 @@ def update
end
else
resource.invitation_token = raw_invitation_token
respond_with_navigational(resource){ render :edit }
respond_with_navigational(resource) { render :edit }
end
end

Expand Down
22 changes: 14 additions & 8 deletions app/views/devise/invitations/edit.html.erb
@@ -1,16 +1,22 @@
<h2><%= t 'devise.invitations.edit.header' %></h2>
<h2><%= t "devise.invitations.edit.header" %></h2>

<%= form_for resource, :as => resource_name, :url => invitation_path(resource_name), :html => { :method => :put } do |f| %>
<%= devise_error_messages! %>
<%= form_for(resource, as: resource_name, url: invitation_path(resource_name), html: { method: :put }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
<%= f.hidden_field :invitation_token, readonly: true %>
<% if f.object.class.require_password_on_accepting %>
<p><%= f.label :password %><br />
<%= f.password_field :password %></p>
<div class="field">
<%= f.label :password %><br />
<%= f.password_field :password %></p>
</div>

<p><%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation %></p>
<div class="field">
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation %>
</div>
<% end %>

<p><%= f.submit t("devise.invitations.edit.submit_button") %></p>
<div class="actions">
<%= f.submit t("devise.invitations.edit.submit_button") %>
</div>
<% end %>
18 changes: 11 additions & 7 deletions app/views/devise/invitations/new.html.erb
@@ -1,12 +1,16 @@
<h2><%= t "devise.invitations.new.header" %></h2>

<%= form_for resource, :as => resource_name, :url => invitation_path(resource_name), :html => {:method => :post} do |f| %>
<%= devise_error_messages! %>
<%= form_for(resource, as: resource_name, url: invitation_path(resource_name), html: { method: :post }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
<% resource.class.invite_key_fields.each do |field| -%>
<p><%= f.label field %><br />
<%= f.text_field field %></p>
<% end -%>
<% resource.class.invite_key_fields.each do |field| -%>
<div class="field">
<%= f.label field %><br />
<%= f.text_field field %>
</div>
<% end -%>

<p><%= f.submit t("devise.invitations.new.submit_button") %></p>
<div class="actions">
<%= f.submit t("devise.invitations.new.submit_button") %>
</div>
<% end %>
2 changes: 1 addition & 1 deletion devise_invitable.gemspec
Expand Up @@ -19,7 +19,7 @@ Gem::Specification.new do |s|
s.required_ruby_version = '>= 2.2.2'

s.add_runtime_dependency 'actionmailer', '>= 5.0'
s.add_runtime_dependency 'devise', '>= 4.6'
s.add_runtime_dependency 'devise', '>= 4.6'

s.add_development_dependency 'bundler', '~> 2.0.1'
end
1 change: 0 additions & 1 deletion gemfiles/Gemfile.rails-5.0
Expand Up @@ -22,4 +22,3 @@ group :test do
gem 'rspec-rails'
gem 'shoulda'
end

1 change: 0 additions & 1 deletion gemfiles/Gemfile.rails-5.1
Expand Up @@ -22,4 +22,3 @@ group :test do
gem 'rspec-rails'
gem 'shoulda'
end

1 change: 0 additions & 1 deletion gemfiles/Gemfile.rails-5.2
Expand Up @@ -22,4 +22,3 @@ group :test do
gem 'rspec-rails'
gem 'shoulda'
end

4 changes: 0 additions & 4 deletions lib/generators/devise_invitable/devise_invitable_generator.rb
Expand Up @@ -5,10 +5,6 @@ class DeviseInvitableGenerator < Rails::Generators::NamedBase

desc 'Add :invitable directive in the given model. Also generate migration for ActiveRecord'

# def devise_generate_model
# invoke "devise", [name]
# end

def inject_devise_invitable_content
path = File.join('app', 'models', "#{file_path}.rb")
inject_into_file(path, 'invitable, :', after: 'devise :') if File.exists?(path)
Expand Down
4 changes: 0 additions & 4 deletions lib/generators/devise_invitable/install_generator.rb
Expand Up @@ -4,10 +4,6 @@ class InstallGenerator < Rails::Generators::Base
source_root File.expand_path('../../templates', __FILE__)
desc 'Add DeviseInvitable config variables to the Devise initializer and copy DeviseInvitable locale files to your application.'

# def devise_install
# invoke "devise:install"
# end

def add_config_options_to_initializer
devise_initializer_path = 'config/initializers/devise.rb'
if File.exist?(devise_initializer_path)
Expand Down
@@ -1,11 +1,15 @@
<h2><%= t 'devise.invitations.edit.header' %></h2>
<h2><%= t "devise.invitations.edit.header" %></h2>

<%= simple_form_for resource, as: resource_name, url: invitation_path(resource_name), html: { method: :put } do |f| %>
<%= devise_error_messages! %>
<%= simple_form_for(resource, as: resource_name, url: invitation_path(resource_name), html: { method: :put }) do |f| %>
<%= f.error_notification %>
<%= f.hidden_field :invitation_token %>

<%= f.input :password %>
<%= f.input :password_confirmation %>
<div class="form-inputs">
<%= f.input :password %>
<%= f.input :password_confirmation %>
</div>

<%= f.button :submit, t("devise.invitations.edit.submit_button") %>
<div class="form-actions">
<%= f.button :submit, t("devise.invitations.edit.submit_button") %>
</div>
<% end %>
@@ -1,11 +1,15 @@
<h2><%= t "devise.invitations.new.header" %></h2>

<%= simple_form_for resource, as: resource_name, url: invitation_path(resource_name), html: { method: :post} do |f| %>
<%= devise_error_messages! %>
<%= simple_form_for(resource, as: resource_name, url: invitation_path(resource_name), html: { method: :post }) do |f| %>
<%= f.error_notification %>
<% resource.class.invite_key_fields.each do |field| -%>
<%= f.input field %>
<% end -%>
<% resource.class.invite_key_fields.each do |field| -%>
<div class="form-inputs">
<%= f.input field %>
</div>
<% end -%>

<%= f.button :submit, t("devise.invitations.new.submit_button") %>
<div class="form-actions">
<%= f.button :submit, t("devise.invitations.new.submit_button") %>
</div>
<% end %>
14 changes: 9 additions & 5 deletions test/rails_app/app/views/admins/new.html.erb
@@ -1,12 +1,16 @@
<h2>Send invitation</h2>

<%= form_for resource, :as => resource_name, :url => admin_path do |f| %>
<%= devise_error_messages! %>
<%= form_for(resource, as: resource_name, url: admin_path) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>

<p><%= f.label :email %><br />
<%= f.text_field :email %></p>
<div class="field">
<%= f.label :email %><br />
<%= f.text_field :email %>
</div>

<p><%= f.submit "Send an invitation" %></p>
<div class="actions">
<%= f.submit "Send an invitation" %>
</div>
<% end %>
<%= link_to "Home", after_sign_in_path_for(resource_name) %><br />
20 changes: 14 additions & 6 deletions test/rails_app/app/views/devise/sessions/new.html.erb
@@ -1,17 +1,25 @@
<h2>Log 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 class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>

<div><%= f.label :password %><br />
<%= f.password_field :password, autocomplete: "off" %></div>
<div class="field">
<%= f.label :password %><br />
<%= f.password_field :password, autocomplete: "off" %>
</div>

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

<div><%= f.submit "Log in" %></div>
<div class="actions">
<%= f.submit "Log in" %>
</div>
<% end %>
<%= render "devise/shared/links" %>
14 changes: 9 additions & 5 deletions test/rails_app/app/views/free_invitations/new.html.erb
@@ -1,12 +1,16 @@
<h2>Send invitation</h2>

<%= form_for resource, :as => resource_name, :url => free_invitation_path do |f| %>
<%= devise_error_messages! %>
<%= form_for(resource, as: resource_name, url: free_invitation_path) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>

<p><%= f.label :email %><br />
<%= f.text_field :email %></p>
<div class="field">
<%= f.label :email %><br />
<%= f.text_field :email %>
</div>

<p><%= f.submit "Send an invitation" %></p>
<div class="actions">
<%= f.submit "Send an invitation" %>
</div>
<% end %>
<%= link_to "Home", after_sign_in_path_for(resource_name) %><br />
7 changes: 3 additions & 4 deletions test/rails_app/app/views/layouts/application.html.erb
Expand Up @@ -7,10 +7,9 @@
<%= csrf_meta_tag %>
</head>
<body>
<%= content_tag :p, flash[:notice], id: 'notice' unless flash[:notice].blank? %>
<%= content_tag :p, flash[:alert], id: 'alert' unless flash[:alert].blank? %>
<%= content_tag :p, flash[:notice], :id => 'notice' unless flash[:notice].blank? %>
<%= content_tag :p, flash[:alert], :id => 'alert' unless flash[:alert].blank? %>
<%= yield %>

<%= yield %>
</body>
</html>
24 changes: 15 additions & 9 deletions test/rails_app/app/views/users/invitations/new.html.erb
@@ -1,15 +1,21 @@
<h2>Send an invitation</h2>

<%= form_for resource, :as => resource_name, :url => invitation_path(resource_name), :html => { :method => :post } do |f| %>
<%= devise_error_messages! %>
<%= form_for(resource, as: resource_name, url: invitation_path(resource_name), html: { method: :post }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>

<p><%= f.label :username %></p>
<p><%= f.text_field :username %></p>

<p><%= f.label :email %></p>
<p><%= f.text_field :email %></p>

<p><%= f.submit "Send an invitation" %></p>
<div class="field">
<%= f.label :username %>
<%= f.text_field :username %>
</div>

<div class="field">
<%= f.label :email %>
<%= f.text_field :email %>
</div>

<div class="actions">
<%= f.submit "Send an invitation" %>
</div>
<% end %>
<%= link_to "Home", after_sign_in_path_for(resource_name) %><br />
12 changes: 6 additions & 6 deletions test/rails_app/config/application.rb
@@ -1,8 +1,8 @@
require File.expand_path('../boot', __FILE__)

require "action_controller/railtie"
require "action_mailer/railtie"
require "rails/test_unit/railtie"
require 'action_controller/railtie'
require 'action_mailer/railtie'
require 'rails/test_unit/railtie'

Bundler.require(:default, DEVISE_ORM) if defined?(Bundler)

Expand All @@ -14,13 +14,13 @@
PARENT_MODEL_CLASS = DEVISE_ORM == :active_record ? ActiveRecord::Base : Object
Mongoid.load!(File.expand_path('../../mongoid.yml', __FILE__)) if DEVISE_ORM == :mongoid && Mongoid::VERSION < '3.0.0'

require "devise"
require "devise_invitable"
require 'devise'
require 'devise_invitable'

module RailsApp
class Application < Rails::Application
config.filter_parameters << :password
config.action_mailer.default_url_options = { :host => "localhost:3000" }
config.action_mailer.default_url_options = { host: 'localhost:3000' }
if DEVISE_ORM == :active_record && Rails.version.start_with?('5')
config.active_record.maintain_test_schema = false
config.active_record.sqlite3.represent_boolean_as_integer = true if config.active_record.sqlite3
Expand Down
4 changes: 2 additions & 2 deletions test/rails_app/config/boot.rb
@@ -1,9 +1,9 @@
unless defined?(DEVISE_ORM)
DEVISE_ORM = (ENV["DEVISE_ORM"] || :active_record).to_sym
DEVISE_ORM = (ENV['DEVISE_ORM'] || :active_record).to_sym
end

begin
require File.expand_path("../../../../.bundle/environment", __FILE__)
require File.expand_path('../../../../.bundle/environment', __FILE__)
rescue LoadError
require 'rubygems'
require 'bundler'
Expand Down
2 changes: 1 addition & 1 deletion test/rails_app/config/initializers/session_store.rb
@@ -1,6 +1,6 @@
# Be sure to restart your server when you modify this file.

RailsApp::Application.config.session_store :cookie_store, :key => '_test_app_session'
RailsApp::Application.config.session_store :cookie_store, key: '_test_app_session'

# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
Expand Down

0 comments on commit 2616684

Please sign in to comment.