any_login 1.6.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/any_login/application_controller.rb +9 -0
- data/app/views/any_login/_any_login.html.erb +1 -0
- data/app/views/any_login/assets/_css.html.erb +73 -1
- data/app/views/any_login/assets/_js.html.erb +205 -1
- data/config/routes.rb +1 -0
- data/lib/any_login/helpers.rb +31 -4
- data/lib/any_login/version.rb +1 -1
- data/lib/any_login.rb +24 -0
- data/lib/generators/any_login/templates/any_login.rb +3 -0
- data/test/authlogic/integration/navigation_test.rb +1 -0
- data/test/clearance/integration/navigation_test.rb +1 -0
- data/test/devise/integration/navigation_test.rb +1 -0
- data/test/devise/integration/search_test.rb +169 -0
- data/test/devise/unit/collection_test.rb +2 -2
- data/test/devise/unit/helpers_test.rb +14 -0
- data/test/devise/unit/search_test.rb +52 -0
- data/test/rails_apps/authlogic/db/schema.rb +3 -5
- data/test/rails_apps/clearance/db/schema.rb +10 -12
- data/test/rails_apps/devise/db/schema.rb +7 -9
- data/test/rails_apps/devise/db/test.sqlite3 +0 -0
- data/test/rails_apps/devise/log/test.log +519 -1999
- data/test/rails_apps/devise/tmp/local_secret.txt +1 -1
- data/test/rails_apps/sorcery/db/schema.rb +3 -5
- data/test/sorcery/integration/navigation_test.rb +1 -0
- metadata +27 -68
- data/test/rails_apps/authlogic/db/development.sqlite3 +0 -0
- data/test/rails_apps/authlogic/db/test.sqlite3 +0 -0
- data/test/rails_apps/authlogic/db/test.sqlite3-shm +0 -0
- data/test/rails_apps/authlogic/db/test.sqlite3-wal +0 -0
- data/test/rails_apps/authlogic/log/development.log +0 -438
- data/test/rails_apps/authlogic/log/test.log +0 -1144
- data/test/rails_apps/authlogic/tmp/development_secret.txt +0 -1
- data/test/rails_apps/authlogic/tmp/local_secret.txt +0 -1
- data/test/rails_apps/clearance/db/development.sqlite3 +0 -0
- data/test/rails_apps/clearance/db/test.sqlite3 +0 -0
- data/test/rails_apps/clearance/db/test.sqlite3-shm +0 -0
- data/test/rails_apps/clearance/db/test.sqlite3-wal +0 -0
- data/test/rails_apps/clearance/log/development.log +0 -388
- data/test/rails_apps/clearance/log/test.log +0 -1110
- data/test/rails_apps/clearance/tmp/development_secret.txt +0 -1
- data/test/rails_apps/clearance/tmp/local_secret.txt +0 -1
- data/test/rails_apps/devise/db/development.sqlite3 +0 -0
- data/test/rails_apps/devise/db/test.sqlite3-shm +0 -0
- data/test/rails_apps/devise/db/test.sqlite3-wal +0 -0
- data/test/rails_apps/devise/log/development.log +0 -1081
- data/test/rails_apps/devise/tmp/development_secret.txt +0 -1
- data/test/rails_apps/sorcery/db/development.sqlite3 +0 -0
- data/test/rails_apps/sorcery/db/test.sqlite3 +0 -0
- data/test/rails_apps/sorcery/db/test.sqlite3-shm +0 -0
- data/test/rails_apps/sorcery/db/test.sqlite3-wal +0 -0
- data/test/rails_apps/sorcery/log/development.log +0 -247
- data/test/rails_apps/sorcery/log/test.log +0 -532
- data/test/rails_apps/sorcery/tmp/development_secret.txt +0 -1
- data/test/rails_apps/sorcery/tmp/local_secret.txt +0 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
require_relative "../test_helper_devise"
|
|
2
|
+
|
|
3
|
+
module AnyLogin
|
|
4
|
+
class SearchTest < ActiveSupport::TestCase
|
|
5
|
+
setup do
|
|
6
|
+
@previous_search_by = AnyLogin.search_by
|
|
7
|
+
@previous_limit = AnyLogin.limit
|
|
8
|
+
@alice = ::User.create!(name: "Alice Smith", email: "alice@example.com", password: "password123")
|
|
9
|
+
@bob = ::User.create!(name: "Bob Jones", email: "bob@sample.org", password: "password123")
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
teardown do
|
|
13
|
+
AnyLogin.search_by = @previous_search_by
|
|
14
|
+
AnyLogin.limit = @previous_limit
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
test "search is disabled by default" do
|
|
18
|
+
AnyLogin.search_by = nil
|
|
19
|
+
|
|
20
|
+
assert_equal false, AnyLogin.search_enabled?
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
test "matches any of the given attributes, ignoring case" do
|
|
24
|
+
AnyLogin.search_by = [:email, :name]
|
|
25
|
+
|
|
26
|
+
assert_equal [@alice], AnyLogin.search("SMITH")
|
|
27
|
+
assert_equal [@bob], AnyLogin.search("sample")
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
test "treats LIKE wildcards in the query literally" do
|
|
31
|
+
AnyLogin.search_by = [:email]
|
|
32
|
+
underscored = ::User.create!(name: "John", email: "john_doe@example.com", password: "password123")
|
|
33
|
+
::User.create!(name: "Johnx", email: "johnxdoe@example.com", password: "password123")
|
|
34
|
+
|
|
35
|
+
assert_equal [underscored], AnyLogin.search("john_doe")
|
|
36
|
+
assert_empty AnyLogin.search("%")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
test "uses a custom proc" do
|
|
40
|
+
AnyLogin.search_by = proc { |query| ::User.where(name: query) }
|
|
41
|
+
|
|
42
|
+
assert_equal [@bob], AnyLogin.search("Bob Jones")
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
test "respects the limit" do
|
|
46
|
+
AnyLogin.search_by = [:email]
|
|
47
|
+
AnyLogin.limit = 1
|
|
48
|
+
|
|
49
|
+
assert_equal 1, AnyLogin.search("e").size
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -10,13 +10,12 @@
|
|
|
10
10
|
#
|
|
11
11
|
# It's strongly recommended that you check this file into your version control system.
|
|
12
12
|
|
|
13
|
-
ActiveRecord::Schema.define(version: 2022_08_25_195914) do
|
|
14
|
-
|
|
13
|
+
ActiveRecord::Schema[8.0].define(version: 2022_08_25_195914) do
|
|
15
14
|
create_table "users", force: :cascade do |t|
|
|
16
15
|
t.string "name"
|
|
17
16
|
t.integer "age"
|
|
18
|
-
t.datetime "created_at",
|
|
19
|
-
t.datetime "updated_at",
|
|
17
|
+
t.datetime "created_at", null: false
|
|
18
|
+
t.datetime "updated_at", null: false
|
|
20
19
|
t.string "email", default: "", null: false
|
|
21
20
|
t.string "encrypted_password", default: "", null: false
|
|
22
21
|
t.string "reset_password_token"
|
|
@@ -42,5 +41,4 @@ ActiveRecord::Schema.define(version: 2022_08_25_195914) do
|
|
|
42
41
|
t.index ["email"], name: "index_users_on_email", unique: true
|
|
43
42
|
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
|
44
43
|
end
|
|
45
|
-
|
|
46
44
|
end
|
|
@@ -10,21 +10,20 @@
|
|
|
10
10
|
#
|
|
11
11
|
# It's strongly recommended that you check this file into your version control system.
|
|
12
12
|
|
|
13
|
-
ActiveRecord::Schema.define(version: 2015_10_07_170422) do
|
|
14
|
-
|
|
13
|
+
ActiveRecord::Schema[8.0].define(version: 2015_10_07_170422) do
|
|
15
14
|
create_table "users", force: :cascade do |t|
|
|
16
15
|
t.string "name"
|
|
17
16
|
t.integer "age"
|
|
18
|
-
t.datetime "created_at",
|
|
19
|
-
t.datetime "updated_at",
|
|
17
|
+
t.datetime "created_at", null: false
|
|
18
|
+
t.datetime "updated_at", null: false
|
|
20
19
|
t.string "email", default: "", null: false
|
|
21
20
|
t.string "encrypted_password", default: "", null: false
|
|
22
21
|
t.string "reset_password_token"
|
|
23
|
-
t.datetime "reset_password_sent_at"
|
|
24
|
-
t.datetime "remember_created_at"
|
|
22
|
+
t.datetime "reset_password_sent_at", precision: nil
|
|
23
|
+
t.datetime "remember_created_at", precision: nil
|
|
25
24
|
t.integer "sign_in_count", default: 0, null: false
|
|
26
|
-
t.datetime "current_sign_in_at"
|
|
27
|
-
t.datetime "last_sign_in_at"
|
|
25
|
+
t.datetime "current_sign_in_at", precision: nil
|
|
26
|
+
t.datetime "last_sign_in_at", precision: nil
|
|
28
27
|
t.string "current_sign_in_ip"
|
|
29
28
|
t.string "last_sign_in_ip"
|
|
30
29
|
t.string "role"
|
|
@@ -35,9 +34,9 @@ ActiveRecord::Schema.define(version: 2015_10_07_170422) do
|
|
|
35
34
|
t.string "persistence_token"
|
|
36
35
|
t.integer "login_count"
|
|
37
36
|
t.integer "failed_login_count"
|
|
38
|
-
t.datetime "last_request_at"
|
|
39
|
-
t.datetime "current_login_at"
|
|
40
|
-
t.datetime "last_login_at"
|
|
37
|
+
t.datetime "last_request_at", precision: nil
|
|
38
|
+
t.datetime "current_login_at", precision: nil
|
|
39
|
+
t.datetime "last_login_at", precision: nil
|
|
41
40
|
t.string "current_login_ip"
|
|
42
41
|
t.string "last_login_ip"
|
|
43
42
|
t.string "confirmation_token", limit: 128
|
|
@@ -45,5 +44,4 @@ ActiveRecord::Schema.define(version: 2015_10_07_170422) do
|
|
|
45
44
|
t.index ["remember_token"], name: "index_users_on_remember_token"
|
|
46
45
|
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
|
47
46
|
end
|
|
48
|
-
|
|
49
47
|
end
|
|
@@ -10,26 +10,24 @@
|
|
|
10
10
|
#
|
|
11
11
|
# It's strongly recommended that you check this file into your version control system.
|
|
12
12
|
|
|
13
|
-
ActiveRecord::Schema.define(version: 2015_09_09_210357) do
|
|
14
|
-
|
|
13
|
+
ActiveRecord::Schema[8.0].define(version: 2015_09_09_210357) do
|
|
15
14
|
create_table "users", force: :cascade do |t|
|
|
16
15
|
t.string "name"
|
|
17
16
|
t.integer "age"
|
|
18
|
-
t.datetime "created_at",
|
|
19
|
-
t.datetime "updated_at",
|
|
17
|
+
t.datetime "created_at", null: false
|
|
18
|
+
t.datetime "updated_at", null: false
|
|
20
19
|
t.string "email", default: "", null: false
|
|
21
20
|
t.string "encrypted_password", default: "", null: false
|
|
22
21
|
t.string "reset_password_token"
|
|
23
|
-
t.datetime "reset_password_sent_at"
|
|
24
|
-
t.datetime "remember_created_at"
|
|
22
|
+
t.datetime "reset_password_sent_at"
|
|
23
|
+
t.datetime "remember_created_at"
|
|
25
24
|
t.integer "sign_in_count", default: 0, null: false
|
|
26
|
-
t.datetime "current_sign_in_at"
|
|
27
|
-
t.datetime "last_sign_in_at"
|
|
25
|
+
t.datetime "current_sign_in_at"
|
|
26
|
+
t.datetime "last_sign_in_at"
|
|
28
27
|
t.string "current_sign_in_ip"
|
|
29
28
|
t.string "last_sign_in_ip"
|
|
30
29
|
t.string "role"
|
|
31
30
|
t.index ["email"], name: "index_users_on_email", unique: true
|
|
32
31
|
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
|
33
32
|
end
|
|
34
|
-
|
|
35
33
|
end
|
|
Binary file
|