godmin 1.3.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +9 -1
- data/app/views/godmin/resource/_table.html.erb +3 -0
- data/app/views/godmin/resource/columns/_actions.html.erb +1 -1
- data/lib/godmin/authentication.rb +1 -1
- data/lib/godmin/authentication/sessions_controller.rb +1 -1
- data/lib/godmin/paginator.rb +12 -4
- data/lib/godmin/version.rb +1 -1
- data/template.rb +2 -2
- data/test/dummy/app/controllers/another_admin_sessions_controller.rb +10 -0
- data/test/dummy/app/models/another_admin_user.rb +7 -0
- data/test/dummy/config/routes.rb +3 -0
- data/test/dummy/db/migrate/20170207081043_create_another_admin_user.rb +10 -0
- data/test/dummy/db/schema.rb +8 -1
- data/test/integration/authentication_test.rb +7 -0
- data/test/lib/godmin/engine_wrapper_test.rb +1 -1
- data/test/lib/godmin/paginator_test.rb +11 -0
- data/test/lib/godmin/resources/resource_service/batch_actions_test.rb +1 -1
- data/test/lib/godmin/resources/resource_service/filters_test.rb +1 -1
- data/test/lib/godmin/resources/resource_service/ordering_test.rb +1 -1
- data/test/test_helper.rb +5 -2
- metadata +9 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec0d4e9f977de0473f9c482b30fe336208e58adb
|
4
|
+
data.tar.gz: f266d7bfba24bdc6947934bf1df1a970dbfe433b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fe30fb7f586871bea01de9696db6a9f40c5b6ce516388844f0de96a04c8f51a05444b7c178ea0176ff38bac6c9d260614be81a952f31b144f67b46496f6550a
|
7
|
+
data.tar.gz: 9581339c532af064381e0a56bae194919d9cfe8b52ba65e642ee309e3e7413c291eede9c2dcc0465050d967b99416bc79cc0243e2391ff0ac0fa256be746683e
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
### 1.4.0 - 2017-02-15
|
4
|
+
Features
|
5
|
+
- Support group queries in scopes and filters (https://github.com/varvet/godmin/pull/208)
|
6
|
+
- Change color of remove buttons, so they're not grabbing all the attention (https://github.com/varvet/godmin/pull/212)
|
7
|
+
|
8
|
+
Bug fixes
|
9
|
+
- Fix permitted params in sessions controller to work with models other than `AdminUser` (https://github.com/varvet/godmin/pull/210)
|
10
|
+
|
11
|
+
Other
|
12
|
+
- Remove authentication alert (https://github.com/varvet/godmin/pull/207)
|
13
|
+
- Add table caption for tests (https://github.com/varvet/godmin/pull/187)
|
14
|
+
|
3
15
|
### 1.3.1 - 2016-09-27
|
4
16
|
Bug fixes
|
5
17
|
- Fix FileSystemResolver issue (https://github.com/varvet/godmin/pull/202)
|
data/README.md
CHANGED
@@ -47,7 +47,7 @@ Godmin supports two common admin scenarios:
|
|
47
47
|
|
48
48
|
If you want to set up an example app that you can play around with, run the following:
|
49
49
|
```sh
|
50
|
-
rails new sandbox -m https://raw.githubusercontent.com/varvet/godmin/master/template.rb
|
50
|
+
rails new sandbox --skip-spring -m https://raw.githubusercontent.com/varvet/godmin/master/template.rb
|
51
51
|
```
|
52
52
|
|
53
53
|
### Standalone installation
|
@@ -637,6 +637,14 @@ class AdminUser < ActiveRecord::Base
|
|
637
637
|
end
|
638
638
|
```
|
639
639
|
|
640
|
+
By default the user model is called `AdminUser`. If you'd like to change this, you can pass an argument to the authentication generator:
|
641
|
+
|
642
|
+
```
|
643
|
+
$ bin/rails generate godmin:authentication SuperUser
|
644
|
+
or for an engine:
|
645
|
+
$ admin/bin/rails generate godmin:authentication SuperUser
|
646
|
+
```
|
647
|
+
|
640
648
|
By default the model is generated with an `email` field as the login column. This can changed in the migration prior to migrating if, for instance, a `username` column is more appropriate.
|
641
649
|
|
642
650
|
The following route is generated:
|
@@ -20,7 +20,7 @@
|
|
20
20
|
translate_scoped("actions.destroy"),
|
21
21
|
resource,
|
22
22
|
method: :delete,
|
23
|
-
class: "btn btn-
|
23
|
+
class: "btn btn-default",
|
24
24
|
title: translate_scoped("actions.destroy_title", resource: resource),
|
25
25
|
data: { confirm: translate_scoped("actions.confirm_message") }
|
26
26
|
) %>
|
data/lib/godmin/paginator.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
module Godmin
|
2
2
|
class Paginator
|
3
|
-
WINDOW_SIZE = 7
|
3
|
+
WINDOW_SIZE = 7
|
4
4
|
|
5
5
|
attr_reader :per_page, :current_page
|
6
6
|
|
7
7
|
def initialize(resources, per_page: 25, current_page: nil)
|
8
|
-
@resources
|
9
|
-
@per_page
|
8
|
+
@resources = resources
|
9
|
+
@per_page = per_page
|
10
10
|
@current_page = current_page ? current_page.to_i : 1
|
11
11
|
end
|
12
12
|
|
@@ -35,7 +35,15 @@ module Godmin
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def total_resources
|
38
|
-
@total_resources ||=
|
38
|
+
@total_resources ||= begin
|
39
|
+
count = @resources.count
|
40
|
+
|
41
|
+
if count.respond_to?(:count)
|
42
|
+
count.count
|
43
|
+
else
|
44
|
+
count
|
45
|
+
end
|
46
|
+
end
|
39
47
|
end
|
40
48
|
|
41
49
|
private
|
data/lib/godmin/version.rb
CHANGED
data/template.rb
CHANGED
@@ -3,7 +3,7 @@ require "active_support/all"
|
|
3
3
|
def install_standalone
|
4
4
|
set_ruby_version
|
5
5
|
|
6
|
-
gem "godmin", "1.3.
|
6
|
+
gem "godmin", "1.3.1"
|
7
7
|
|
8
8
|
after_bundle do
|
9
9
|
create_database
|
@@ -36,7 +36,7 @@ def install_engine
|
|
36
36
|
|
37
37
|
inject_into_file "admin/admin.gemspec", before: /^end/ do
|
38
38
|
<<-END.strip_heredoc.indent(2)
|
39
|
-
s.add_dependency "godmin", "~> 1.3.
|
39
|
+
s.add_dependency "godmin", "~> 1.3.1"
|
40
40
|
END
|
41
41
|
end
|
42
42
|
|
data/test/dummy/config/routes.rb
CHANGED
@@ -3,6 +3,9 @@ Rails.application.routes.draw do
|
|
3
3
|
resources :authenticated_articles
|
4
4
|
resources :authorized_articles
|
5
5
|
resource :session, only: [:new, :create, :destroy]
|
6
|
+
|
7
|
+
resource :another_admin_session, only: [:create]
|
8
|
+
|
6
9
|
root to: "application#welcome"
|
7
10
|
mount Admin::Engine, at: "admin"
|
8
11
|
end
|
data/test/dummy/db/schema.rb
CHANGED
@@ -10,7 +10,7 @@
|
|
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:
|
13
|
+
ActiveRecord::Schema.define(version: 20170207081043) do
|
14
14
|
|
15
15
|
create_table "admin_users", force: :cascade do |t|
|
16
16
|
t.string "email"
|
@@ -19,6 +19,13 @@ ActiveRecord::Schema.define(version: 20150907133753) do
|
|
19
19
|
t.datetime "updated_at", null: false
|
20
20
|
end
|
21
21
|
|
22
|
+
create_table "another_admin_users", force: :cascade do |t|
|
23
|
+
t.string "email"
|
24
|
+
t.text "password_digest"
|
25
|
+
t.datetime "created_at", null: false
|
26
|
+
t.datetime "updated_at", null: false
|
27
|
+
end
|
28
|
+
|
22
29
|
create_table "articles", force: :cascade do |t|
|
23
30
|
t.string "title"
|
24
31
|
t.text "body"
|
@@ -14,4 +14,11 @@ class AuthenticationTest < ActionDispatch::IntegrationTest
|
|
14
14
|
visit authenticated_articles_path
|
15
15
|
assert_not_equal authenticated_articles_path, current_path
|
16
16
|
end
|
17
|
+
|
18
|
+
def test_sign_in_with_non_default_user
|
19
|
+
AnotherAdminUser.create!(email: "another_admin@example.com", password: "password")
|
20
|
+
post another_admin_session_path, another_admin_user: { email: "another_admin@example.com", password: "password" }
|
21
|
+
|
22
|
+
assert_redirected_to root_path
|
23
|
+
end
|
17
24
|
end
|
@@ -80,5 +80,16 @@ module Godmin
|
|
80
80
|
paginator = Paginator.new(@resources)
|
81
81
|
assert_equal 50, paginator.total_resources
|
82
82
|
end
|
83
|
+
|
84
|
+
def test_total_resource_with_grouped_count
|
85
|
+
resources_class = Class.new do
|
86
|
+
def count
|
87
|
+
{ 1 => 1, 2 => 2 }
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
paginator = Paginator.new(resources_class.new)
|
92
|
+
assert_equal 2, paginator.total_resources
|
93
|
+
end
|
83
94
|
end
|
84
95
|
end
|
@@ -14,7 +14,7 @@ module Godmin
|
|
14
14
|
|
15
15
|
def test_batch_action_when_it_does_not_exist
|
16
16
|
assert_not @article_service.batch_action(:foobar, [:foo, :bar])
|
17
|
-
|
17
|
+
assert_nil @article_service.called_methods[:batch_actions][:foobar]
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_batch_action_exists
|
@@ -25,7 +25,7 @@ module Godmin
|
|
25
25
|
|
26
26
|
def test_does_not_call_filter_when_empty_multiselect
|
27
27
|
@article_service.apply_filters({ tags: [""] }, :resources)
|
28
|
-
|
28
|
+
assert_nil @article_service.called_methods[:filters][:tags]
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_filter_map_with_default_options
|
@@ -25,7 +25,7 @@ module Godmin
|
|
25
25
|
def test_apply_order_without_order
|
26
26
|
resources = @resources_class.new
|
27
27
|
@article_service.apply_order("", resources)
|
28
|
-
|
28
|
+
assert_nil resources.order_param
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_apply_order_with_custom_ordering_method
|
data/test/test_helper.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# TODO: This does not work anymore. We need to update this according to:
|
2
|
+
# https://docs.codeclimate.com/docs/ruby
|
3
|
+
#
|
4
|
+
# require "codeclimate-test-reporter"
|
5
|
+
# CodeClimate::TestReporter.start
|
3
6
|
|
4
7
|
# Configure Rails Environment
|
5
8
|
ENV["RAILS_ENV"] = "test"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: godmin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jens Ljungblad
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2017-02-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bcrypt
|
@@ -410,6 +410,7 @@ files:
|
|
410
410
|
- test/dummy/admin/lib/admin/version.rb
|
411
411
|
- test/dummy/app/assets/javascripts/application.js
|
412
412
|
- test/dummy/app/assets/stylesheets/application.css
|
413
|
+
- test/dummy/app/controllers/another_admin_sessions_controller.rb
|
413
414
|
- test/dummy/app/controllers/application_controller.rb
|
414
415
|
- test/dummy/app/controllers/articles_controller.rb
|
415
416
|
- test/dummy/app/controllers/authenticated_articles_controller.rb
|
@@ -417,6 +418,7 @@ files:
|
|
417
418
|
- test/dummy/app/controllers/sessions_controller.rb
|
418
419
|
- test/dummy/app/models/.keep
|
419
420
|
- test/dummy/app/models/admin_user.rb
|
421
|
+
- test/dummy/app/models/another_admin_user.rb
|
420
422
|
- test/dummy/app/models/article.rb
|
421
423
|
- test/dummy/app/policies/article_policy.rb
|
422
424
|
- test/dummy/app/services/article_service.rb
|
@@ -447,6 +449,7 @@ files:
|
|
447
449
|
- test/dummy/config/routes.rb
|
448
450
|
- test/dummy/db/migrate/20150717121532_create_articles.rb
|
449
451
|
- test/dummy/db/migrate/20150907133753_create_admin_users.rb
|
452
|
+
- test/dummy/db/migrate/20170207081043_create_another_admin_user.rb
|
450
453
|
- test/dummy/db/schema.rb
|
451
454
|
- test/dummy/lib/assets/.keep
|
452
455
|
- test/dummy/log/.keep
|
@@ -502,7 +505,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
502
505
|
version: '0'
|
503
506
|
requirements: []
|
504
507
|
rubyforge_project:
|
505
|
-
rubygems_version: 2.
|
508
|
+
rubygems_version: 2.5.2
|
506
509
|
signing_key:
|
507
510
|
specification_version: 4
|
508
511
|
summary: Godmin is an admin framework for Rails 4+
|
@@ -528,6 +531,7 @@ test_files:
|
|
528
531
|
- test/dummy/admin/lib/admin/version.rb
|
529
532
|
- test/dummy/app/assets/javascripts/application.js
|
530
533
|
- test/dummy/app/assets/stylesheets/application.css
|
534
|
+
- test/dummy/app/controllers/another_admin_sessions_controller.rb
|
531
535
|
- test/dummy/app/controllers/application_controller.rb
|
532
536
|
- test/dummy/app/controllers/articles_controller.rb
|
533
537
|
- test/dummy/app/controllers/authenticated_articles_controller.rb
|
@@ -535,6 +539,7 @@ test_files:
|
|
535
539
|
- test/dummy/app/controllers/sessions_controller.rb
|
536
540
|
- test/dummy/app/models/.keep
|
537
541
|
- test/dummy/app/models/admin_user.rb
|
542
|
+
- test/dummy/app/models/another_admin_user.rb
|
538
543
|
- test/dummy/app/models/article.rb
|
539
544
|
- test/dummy/app/policies/article_policy.rb
|
540
545
|
- test/dummy/app/services/article_service.rb
|
@@ -565,6 +570,7 @@ test_files:
|
|
565
570
|
- test/dummy/config/routes.rb
|
566
571
|
- test/dummy/db/migrate/20150717121532_create_articles.rb
|
567
572
|
- test/dummy/db/migrate/20150907133753_create_admin_users.rb
|
573
|
+
- test/dummy/db/migrate/20170207081043_create_another_admin_user.rb
|
568
574
|
- test/dummy/db/schema.rb
|
569
575
|
- test/dummy/lib/assets/.keep
|
570
576
|
- test/dummy/log/.keep
|
@@ -598,4 +604,3 @@ test_files:
|
|
598
604
|
- test/lib/godmin/resources/resource_service/scopes_test.rb
|
599
605
|
- test/lib/godmin/resources/resource_service_test.rb
|
600
606
|
- test/test_helper.rb
|
601
|
-
has_rdoc:
|