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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 472fc51b8367e7692370d5cdf7b73277474d9995
4
- data.tar.gz: 808d3cbaaa03ceea6bc8678ea5ce8686e53cb4f7
3
+ metadata.gz: ec0d4e9f977de0473f9c482b30fe336208e58adb
4
+ data.tar.gz: f266d7bfba24bdc6947934bf1df1a970dbfe433b
5
5
  SHA512:
6
- metadata.gz: 7b8b7888056a7e6a1382115adda0dd4ce19010b661ddfa3e8e165fa0291f3de6f17c533a62c7416d63d824672d8facf9cbf5dd8376950c13d09516aa00554100
7
- data.tar.gz: ab1ebe74ff2f8764d73dd73b95f3fc7f43bef777761fd6fa4cbb2cfc70a536325f8d711c3abbfe081c965d812e6ee70d75cd7b1d644250dde9c5a1cdb3babfd5
6
+ metadata.gz: 3fe30fb7f586871bea01de9696db6a9f40c5b6ce516388844f0de96a04c8f51a05444b7c178ea0176ff38bac6c9d260614be81a952f31b144f67b46496f6550a
7
+ data.tar.gz: 9581339c532af064381e0a56bae194919d9cfe8b52ba65e642ee309e3e7413c291eede9c2dcc0465050d967b99416bc79cc0243e2391ff0ac0fa256be746683e
@@ -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:
@@ -1,5 +1,8 @@
1
1
  <div id="table" class="table-responsive">
2
2
  <table class="table table-bordered table-hover">
3
+ <caption class="hide">
4
+ <%= @resource_class.model_name.human(count: 2) %>
5
+ </caption>
3
6
  <thead>
4
7
  <tr>
5
8
  <% if @resource_service.include_batch_actions? %>
@@ -20,7 +20,7 @@
20
20
  translate_scoped("actions.destroy"),
21
21
  resource,
22
22
  method: :delete,
23
- class: "btn btn-danger",
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
  ) %>
@@ -14,7 +14,7 @@ module Godmin
14
14
 
15
15
  def authenticate_admin_user
16
16
  unless admin_user_signed_in? || controller_name == "sessions"
17
- redirect_to new_session_path, alert: "Authentication needed"
17
+ redirect_to new_session_path
18
18
  end
19
19
  end
20
20
 
@@ -34,7 +34,7 @@ module Godmin
34
34
  end
35
35
 
36
36
  def admin_user_params
37
- params.require(:admin_user).permit(
37
+ params.require(admin_user_class.model_name.param_key.to_sym).permit(
38
38
  admin_user_class.login_column,
39
39
  :password,
40
40
  :password_confirm
@@ -1,12 +1,12 @@
1
1
  module Godmin
2
2
  class Paginator
3
- WINDOW_SIZE = 7.freeze
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 = resources
9
- @per_page = 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 ||= @resources.count
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
@@ -1,3 +1,3 @@
1
1
  module Godmin
2
- VERSION = "1.3.1"
2
+ VERSION = "1.4.0"
3
3
  end
@@ -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.0"
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.0"
39
+ s.add_dependency "godmin", "~> 1.3.1"
40
40
  END
41
41
  end
42
42
 
@@ -0,0 +1,10 @@
1
+ class AnotherAdminSessionsController < ApplicationController
2
+ include Godmin::Authentication::SessionsController
3
+ include Godmin::Authentication
4
+
5
+ skip_before_action :authenticate_admin_user
6
+
7
+ def admin_user_class
8
+ AnotherAdminUser
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ class AnotherAdminUser < ActiveRecord::Base
2
+ include Godmin::Authentication::User
3
+
4
+ def self.login_column
5
+ :email
6
+ end
7
+ end
@@ -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
@@ -0,0 +1,10 @@
1
+ class CreateAnotherAdminUser < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :another_admin_users do |t|
4
+ t.string :email
5
+ t.text :password_digest
6
+
7
+ t.timestamps null: false
8
+ end
9
+ end
10
+ end
@@ -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: 20150907133753) do
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
@@ -22,7 +22,7 @@ module Godmin
22
22
 
23
23
  def test_default_namespace
24
24
  engine_wrapper = EngineWrapper.new(Controller)
25
- assert_equal nil, engine_wrapper.namespace
25
+ assert_nil engine_wrapper.namespace
26
26
  end
27
27
 
28
28
  def test_default_namespaced?
@@ -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
- assert_equal nil, @article_service.called_methods[:batch_actions][:foobar]
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
- assert_equal nil, @article_service.called_methods[:filters][:tags]
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
- assert_equal nil, resources.order_param
28
+ assert_nil resources.order_param
29
29
  end
30
30
 
31
31
  def test_apply_order_with_custom_ordering_method
@@ -1,5 +1,8 @@
1
- require "codeclimate-test-reporter"
2
- CodeClimate::TestReporter.start
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.3.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: 2016-09-27 00:00:00.000000000 Z
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.4.5
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: