Skip to content

Commit 2f67ea0

Browse files
committed
Fix spec for devise
1 parent 6d35ff2 commit 2f67ea0

File tree

12 files changed

+667
-2
lines changed

12 files changed

+667
-2
lines changed

spec/features/smoke_spec.rb

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
require 'spec_helper'
22

33
describe 'browse the test app' do
4-
before { Mongoid.purge! }
4+
let(:password) { 'foobar•secret' }
5+
let(:email) { 'john@doe.com' }
6+
7+
before do
8+
Mongoid.purge!
9+
AdminUser.create! email: email, password: password
10+
end
511
before { visit '/admin' }
612

713
it 'does something' do
8-
I18n.backend.reload!
14+
I18n.t('active_admin.devise.login.submit').should eq('Login')
15+
16+
# Auth
17+
fill_in 'Email', with: email
18+
fill_in 'Password', with: password
19+
click_on 'Login'
920

1021
# New
1122
click_on 'Posts'

test_app/app/admin/admin_users.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
ActiveAdmin.register AdminUser do
2+
index do
3+
column :email
4+
column :current_sign_in_at
5+
column :last_sign_in_at
6+
column :sign_in_count
7+
default_actions
8+
end
9+
10+
filter :email
11+
12+
form do |f|
13+
f.inputs "Admin Details" do
14+
f.input :email
15+
f.input :password
16+
f.input :password_confirmation
17+
end
18+
f.actions
19+
end
20+
end
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//= require active_admin/base
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// SASS variable overrides must be declared before loading up Active Admin's styles.
2+
//
3+
// To view the variables that Active Admin provides, take a look at
4+
// `app/assets/stylesheets/active_admin/mixins/_variables.css.scss` in the
5+
// Active Admin source.
6+
//
7+
// For example, to change the sidebar width:
8+
// $sidebar-width: 242px;
9+
10+
// Active Admin's got SASS!
11+
@import "active_admin/mixins";
12+
@import "active_admin/base";
13+
14+
// Overriding any non-variable SASS must be done after the fact.
15+
// For example, to change the default status-tag color:
16+
//
17+
// body.active_admin {
18+
// .status_tag { background: #6090DB; }
19+
// }
20+
//
21+
// Notice that Active Admin CSS rules are nested within a
22+
// 'body.active_admin' selector to prevent conflicts with
23+
// other pages in the app. It is best to wrap your changes in a
24+
// namespace so they are properly recognized. You have options
25+
// if you e.g. want different styles for different namespaces:
26+
//
27+
// .active_admin applies to any Active Admin namespace
28+
// .admin_namespace applies to the admin namespace (eg: /admin)
29+
// .other_namespace applies to a custom namespace named other (eg: /other)

test_app/app/models/admin_user.rb

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
class AdminUser
2+
include Mongoid::Document
3+
# Include default devise modules. Others available are:
4+
# :token_authenticatable, :confirmable,
5+
# :lockable, :timeoutable and :omniauthable
6+
devise :database_authenticatable,
7+
:recoverable, :rememberable, :trackable, :validatable
8+
9+
## Database authenticatable
10+
field :email, :type => String, :default => ""
11+
field :encrypted_password, :type => String, :default => ""
12+
13+
## Recoverable
14+
field :reset_password_token, :type => String
15+
field :reset_password_sent_at, :type => Time
16+
17+
## Rememberable
18+
field :remember_created_at, :type => Time
19+
20+
## Trackable
21+
field :sign_in_count, :type => Integer, :default => 0
22+
field :current_sign_in_at, :type => Time
23+
field :last_sign_in_at, :type => Time
24+
field :current_sign_in_ip, :type => String
25+
field :last_sign_in_ip, :type => String
26+
27+
## Confirmable
28+
# field :confirmation_token, :type => String
29+
# field :confirmed_at, :type => Time
30+
# field :confirmation_sent_at, :type => Time
31+
# field :unconfirmed_email, :type => String # Only if using reconfirmable
32+
33+
## Lockable
34+
# field :failed_attempts, :type => Integer, :default => 0 # Only if lock strategy is :failed_attempts
35+
# field :unlock_token, :type => String # Only if unlock strategy is :email or :both
36+
# field :locked_at, :type => Time
37+
38+
## Token authenticatable
39+
# field :authentication_token, :type => String
40+
end
Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
ActiveAdmin.setup do |config|
2+
3+
# == Site Title
4+
#
5+
# Set the title that is displayed on the main layout
6+
# for each of the active admin pages.
7+
#
8+
config.site_title = "Test App"
9+
10+
# Set the link url for the title. For example, to take
11+
# users to your main site. Defaults to no link.
12+
#
13+
# config.site_title_link = "/"
14+
15+
# Set an optional image to be displayed for the header
16+
# instead of a string (overrides :site_title)
17+
#
18+
# Note: Recommended image height is 21px to properly fit in the header
19+
#
20+
# config.site_title_image = "/images/logo.png"
21+
22+
# == Default Namespace
23+
#
24+
# Set the default namespace each administration resource
25+
# will be added to.
26+
#
27+
# eg:
28+
# config.default_namespace = :hello_world
29+
#
30+
# This will create resources in the HelloWorld module and
31+
# will namespace routes to /hello_world/*
32+
#
33+
# To set no namespace by default, use:
34+
# config.default_namespace = false
35+
#
36+
# Default:
37+
# config.default_namespace = :admin
38+
#
39+
# You can customize the settings for each namespace by using
40+
# a namespace block. For example, to change the site title
41+
# within a namespace:
42+
#
43+
# config.namespace :admin do |admin|
44+
# admin.site_title = "Custom Admin Title"
45+
# end
46+
#
47+
# This will ONLY change the title for the admin section. Other
48+
# namespaces will continue to use the main "site_title" configuration.
49+
50+
# == User Authentication
51+
#
52+
# Active Admin will automatically call an authentication
53+
# method in a before filter of all controller actions to
54+
# ensure that there is a currently logged in admin user.
55+
#
56+
# This setting changes the method which Active Admin calls
57+
# within the controller.
58+
config.authentication_method = :authenticate_admin_user!
59+
60+
61+
# == Current User
62+
#
63+
# Active Admin will associate actions with the current
64+
# user performing them.
65+
#
66+
# This setting changes the method which Active Admin calls
67+
# to return the currently logged in user.
68+
config.current_user_method = :current_admin_user
69+
70+
71+
# == Logging Out
72+
#
73+
# Active Admin displays a logout link on each screen. These
74+
# settings configure the location and method used for the link.
75+
#
76+
# This setting changes the path where the link points to. If it's
77+
# a string, the strings is used as the path. If it's a Symbol, we
78+
# will call the method to return the path.
79+
#
80+
# Default:
81+
config.logout_link_path = :destroy_admin_user_session_path
82+
83+
# This setting changes the http method used when rendering the
84+
# link. For example :get, :delete, :put, etc..
85+
#
86+
# Default:
87+
# config.logout_link_method = :get
88+
89+
# == Root
90+
#
91+
# Set the action to call for the root path. You can set different
92+
# roots for each namespace.
93+
#
94+
# Default:
95+
# config.root_to = 'dashboard#index'
96+
97+
# == Admin Comments
98+
#
99+
# Admin comments allow you to add comments to any model for admin use.
100+
# Admin comments are enabled by default.
101+
#
102+
# Default:
103+
# config.allow_comments = true
104+
#
105+
# You can turn them on and off for any given namespace by using a
106+
# namespace config block.
107+
#
108+
# Eg:
109+
# config.namespace :without_comments do |without_comments|
110+
# without_comments.allow_comments = false
111+
# end
112+
113+
114+
# == Batch Actions
115+
#
116+
# Enable and disable Batch Actions
117+
#
118+
config.batch_actions = true
119+
120+
121+
# == Controller Filters
122+
#
123+
# You can add before, after and around filters to all of your
124+
# Active Admin resources and pages from here.
125+
#
126+
# config.before_filter :do_something_awesome
127+
128+
129+
# == Register Stylesheets & Javascripts
130+
#
131+
# We recommend using the built in Active Admin layout and loading
132+
# up your own stylesheets / javascripts to customize the look
133+
# and feel.
134+
#
135+
# To load a stylesheet:
136+
# config.register_stylesheet 'my_stylesheet.css'
137+
138+
# You can provide an options hash for more control, which is passed along to stylesheet_link_tag():
139+
# config.register_stylesheet 'my_print_stylesheet.css', :media => :print
140+
#
141+
# To load a javascript file:
142+
# config.register_javascript 'my_javascript.js'
143+
144+
145+
# == CSV options
146+
#
147+
# Set the CSV builder separator (default is ",")
148+
# config.csv_column_separator = ','
149+
#
150+
# Set the CSV builder options (default is {})
151+
# config.csv_options = {}
152+
153+
154+
# == Menu System
155+
#
156+
# You can add a navigation menu to be used in your application, or configure a provided menu
157+
#
158+
# To change the default utility navigation to show a link to your website & a logout btn
159+
#
160+
# config.namespace :admin do |admin|
161+
# admin.build_menu :utility_navigation do |menu|
162+
# menu.add label: "My Great Website", url: "http://www.mygreatwebsite.com", html_options: { target: :blank }
163+
# admin.add_logout_button_to_menu menu
164+
# end
165+
# end
166+
#
167+
# If you wanted to add a static menu item to the default menu provided:
168+
#
169+
# config.namespace :admin do |admin|
170+
# admin.build_menu :default do |menu|
171+
# menu.add label: "My Great Website", url: "http://www.mygreatwebsite.com", html_options: { target: :blank }
172+
# end
173+
# end
174+
175+
# == Download Links
176+
#
177+
# You can disable download links on resource listing pages,
178+
# or customize the formats shown per namespace/globally
179+
#
180+
# To disable/customize for the :admin namespace:
181+
#
182+
# config.namespace :admin do |admin|
183+
#
184+
# # Disable the links entirely
185+
# admin.download_links = false
186+
#
187+
# # Only show XML & PDF options
188+
# admin.download_links = [:xml, :pdf]
189+
#
190+
# end
191+
192+
193+
# == Pagination
194+
#
195+
# Pagination is enabled by default for all resources.
196+
# You can control the default per page count for all resources here.
197+
#
198+
# config.default_per_page = 30
199+
200+
201+
# == Filters
202+
#
203+
# By default the index screen includes a “Filters” sidebar on the right
204+
# hand side with a filter for each attribute of the registered model.
205+
# You can enable or disable them for all resources here.
206+
#
207+
# config.filters = true
208+
209+
210+
end

0 commit comments

Comments
 (0)