godmin 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/README.md +31 -12
  4. data/lib/godmin/helpers/forms.rb +4 -2
  5. data/lib/godmin/helpers/tables.rb +3 -1
  6. data/lib/godmin/resolver.rb +2 -2
  7. data/lib/godmin/resources/resource_service/ordering.rb +16 -2
  8. data/lib/godmin/version.rb +1 -1
  9. data/test/dummy/app/controllers/authenticated_articles_controller.rb +11 -0
  10. data/test/dummy/app/controllers/authorized_articles_controller.rb +11 -0
  11. data/test/dummy/app/controllers/sessions_controller.rb +6 -1
  12. data/test/dummy/app/models/article.rb +9 -0
  13. data/test/dummy/app/policies/article_policy.rb +13 -0
  14. data/test/dummy/app/services/article_service.rb +7 -3
  15. data/test/dummy/config/routes.rb +2 -1
  16. data/test/dummy/db/migrate/20150717121532_create_articles.rb +1 -0
  17. data/test/dummy/db/schema.rb +4 -3
  18. data/test/fakes/article.rb +7 -0
  19. data/test/fakes/article_service.rb +6 -1
  20. data/test/integration/authentication_test.rb +17 -0
  21. data/test/integration/authorization_test.rb +32 -0
  22. data/test/integration/column_ordering_test.rb +12 -0
  23. data/test/integration/crud_test.rb +67 -0
  24. data/test/integration/{column_overriding_test.rb → view_overriding/column_overriding_test.rb} +0 -0
  25. data/test/integration/{filter_overriding_test.rb → view_overriding/filter_overriding_test.rb} +0 -0
  26. data/test/integration/{partial_overriding_test.rb → view_overriding/partial_overriding_test.rb} +0 -0
  27. data/test/integration/{template_overriding_test.rb → view_overriding/template_overriding_test.rb} +0 -0
  28. data/test/lib/godmin/resources/resource_service/ordering_test.rb +7 -7
  29. metadata +22 -20
  30. data/test/dummy/app/controllers/secret_articles_controller.rb +0 -3
  31. data/test/dummy/app/controllers/secret_controller.rb +0 -7
  32. data/test/dummy/app/models/secret_article.rb +0 -2
  33. data/test/dummy/app/services/secret_article_service.rb +0 -2
  34. data/test/integration/sign_in_test.rb +0 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 19ea145e85a221046da2c5f9bac8653bf16fa24f
4
- data.tar.gz: 9fa954f22350d6891ba27cbc999f6f54572fbbb8
3
+ metadata.gz: 5485225c54b1b8d9dec2a7d5d01aafe12f6109fa
4
+ data.tar.gz: f9ccde13580100c1134bc45701bd4e06cd4222f7
5
5
  SHA512:
6
- metadata.gz: 8468f4af31b9a57d6cf81429294e7d97140cd9609c607af195c792d9971b84138ec3fddab1259115de77b38a0404bf4538d368e023ba07ef350d22c802cc6dc7
7
- data.tar.gz: c4d0f3a0f7dd3e76a7909682d0e40aa6f3b97a61746e72673ab1a724def65863cf2905a59c8d646b62f9ba823e456c2ccec2cf070573c54bf16d485210c74e9f
6
+ metadata.gz: f2312da3947f533300714a819f812d1d2bfbffafe20d93fbf6a74c8aff1262e3587218e3116d7edf64d16248ff78022f7fe2addf103adfe6e26c863aada8e297
7
+ data.tar.gz: 34df58f5528358d065426c1ffae18619b1f431ec341ab9bfc5de4344b2bfdfbd2c3590702674ddb8d3b76d9ccc20742ba71c1b0a4317644a99e955d0adc7205c
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ### 1.2.0 - 2016-02-02
4
+ Features
5
+ - Adds support for custom ordering of columns (https://github.com/varvet/godmin/pull/168)
6
+ - Adds passing of html options to association helper (https://github.com/varvet/godmin/pull/176)
7
+
8
+ Bug fixes:
9
+ - Fixes an issue with the template resolver and Rails 4.2.5.1 (https://github.com/varvet/godmin/pull/175)
10
+
3
11
  ### 1.1.0 - 2015-12-08
4
12
  Features
5
13
  - Adds locale for pt-BR (Brazilian Portuguese) (https://github.com/varvet/godmin/pull/141)
data/README.md CHANGED
@@ -12,24 +12,25 @@ Godmin differs from tools like [ActiveAdmin](http://activeadmin.info/) and [Rail
12
12
  ![Screenshot](https://raw.githubusercontent.com/varvet/godmin/master/screenshot.png)
13
13
 
14
14
  - [Installation](#installation)
15
- - [Standalone installation](#standalone-installation)
16
- - [Engine installation](#engine-installation)
17
- - [Installation artefacts](#installation-artefacts)
15
+ - [Standalone installation](#standalone-installation)
16
+ - [Engine installation](#engine-installation)
17
+ - [Installation artefacts](#installation-artefacts)
18
18
  - [Getting started](#getting-started)
19
19
  - [Resources](#resources)
20
- - [Scopes](#scopes)
21
- - [Filters](#filters)
22
- - [Batch actions](#batch-actions)
23
- - [Resource fetching, building and saving](#resource-fetching-building-and-saving)
24
- - [Redirecting](#redirecting)
25
- - [Pagination](#pagination)
26
- - [Exporting](#exporting)
20
+ - [Scopes](#scopes)
21
+ - [Filters](#filters)
22
+ - [Batch actions](#batch-actions)
23
+ - [Custom ordering](#custom-ordering)
24
+ - [Resource fetching, building and saving](#resource-fetching-building-and-saving)
25
+ - [Redirecting](#redirecting)
26
+ - [Pagination](#pagination)
27
+ - [Exporting](#exporting)
27
28
  - [Views](#views)
28
29
  - [Forms](#forms)
29
30
  - [Navigation](#navigation)
30
31
  - [Authentication](#authentication)
31
- - [Built in authentication](#built-in-authentication)
32
- - [Shared authentication](#shared-authentication)
32
+ - [Built in authentication](#built-in-authentication)
33
+ - [Shared authentication](#shared-authentication)
33
34
  - [Authorization](#authorization)
34
35
  - [Localization](#localization)
35
36
  - [JavaScript](#javascript)
@@ -273,6 +274,24 @@ end
273
274
 
274
275
  If you are using Godmin's built in authorization functionality you must [authorize your batch actions in your policy](#batch-action-authorization).
275
276
 
277
+ ### Custom ordering
278
+
279
+ By default, Godmin supports ordering of database columns in the index view table. However, it cannot automatically sort associations, custom attributes and so on.
280
+ If you want to order something that Godmin doesn't support out of the box, or you just want to customize how a columns is ordered, you can implement your own ordering functionality in the service object by creating a `order_by_<attribute>` method.
281
+
282
+ ```ruby
283
+ class ArticleService
284
+ include Godmin::Resources::ResourceService
285
+ attrs_for_index :title, :author
286
+
287
+ # resources is an ActiveRecord::Relation object
288
+ # direction is the order direction ("asc" or "desc")
289
+ def order_by_author(resources, direction)
290
+ resources.joins(:authors).order("authors.name #{direction}")
291
+ end
292
+ end
293
+ ```
294
+
276
295
  ### Resource fetching, building and saving
277
296
 
278
297
  Resources are made available to the views through instance variables. The index view can access the resources using `@resources` while show, new and edit can access the single resource using `@resource`. In addition, the resource class is available as `@resource_class` and the service object is available as `@resource_service`.
@@ -24,10 +24,12 @@ module Godmin
24
24
  end
25
25
  end
26
26
 
27
- def association(attribute, options = {})
27
+ def association(attribute, options = {}, html_options = {})
28
28
  case association_type(attribute)
29
29
  when :belongs_to
30
- select "#{attribute}_id", association_collection_for_select(attribute), {}, data: { behavior: "select-box" }
30
+ select("#{attribute}_id", association_collection_for_select(attribute), options, html_options.deep_merge(
31
+ data: { behavior: "select-box" }
32
+ ))
31
33
  else
32
34
  input(attribute, options)
33
35
  end
@@ -2,13 +2,15 @@ module Godmin
2
2
  module Helpers
3
3
  module Tables
4
4
  def column_header(attribute)
5
- if @resource_class.column_names.include?(attribute.to_s)
5
+ if @resource_service.orderable_column?(attribute.to_s)
6
6
  direction =
7
7
  if params[:order].present?
8
8
  if params[:order].match(/\A#{attribute.to_s}_(asc|desc)\z/)
9
9
  $1 == "desc" ? "asc" : "desc"
10
10
  elsif params[:order].match(/\A\w+_(asc|desc)\z/)
11
11
  $1
12
+ else
13
+ "desc"
12
14
  end
13
15
  else
14
16
  "desc"
@@ -13,14 +13,14 @@ module Godmin
13
13
  @engine_wrapper = engine_wrapper
14
14
  end
15
15
 
16
- def find_templates(name, prefix, partial, details)
16
+ def find_templates(name, prefix, *args)
17
17
  templates = []
18
18
 
19
19
  template_paths(prefix).each do |path|
20
20
  if templates.present?
21
21
  break
22
22
  else
23
- templates = super(name, path, partial, details)
23
+ templates = super(name, path, *args)
24
24
  end
25
25
  end
26
26
 
@@ -5,21 +5,35 @@ module Godmin
5
5
  extend ActiveSupport::Concern
6
6
 
7
7
  def apply_order(order_param, resources)
8
- if order_param.present?
8
+ if order_param.present? && order_column_method?(order_column(order_param))
9
+ send("order_by_#{order_column(order_param)}", resources, order_direction(order_param))
10
+ elsif order_param.present? && order_column_column?(order_column(order_param))
9
11
  resources.order("#{resource_class.table_name}.#{order_column(order_param)} #{order_direction(order_param)}")
10
12
  else
11
13
  resources
12
14
  end
13
15
  end
14
16
 
17
+ def orderable_column?(column)
18
+ order_column_method?(column) || order_column_column?(column)
19
+ end
20
+
15
21
  protected
16
22
 
23
+ def order_column_method?(column)
24
+ respond_to?("order_by_#{column}")
25
+ end
26
+
27
+ def order_column_column?(column)
28
+ resource_class.column_names.include?(column)
29
+ end
30
+
17
31
  def order_column(order_param)
18
32
  order_param.rpartition("_").first
19
33
  end
20
34
 
21
35
  def order_direction(order_param)
22
- order_param.rpartition("_").last
36
+ order_param.rpartition("_").last == "asc" ? "asc" : "desc"
23
37
  end
24
38
  end
25
39
  end
@@ -1,3 +1,3 @@
1
1
  module Godmin
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -0,0 +1,11 @@
1
+ class AuthenticatedArticlesController < ArticlesController
2
+ include Godmin::Authentication
3
+
4
+ def admin_user_class
5
+ AdminUser
6
+ end
7
+
8
+ def resource_service_class
9
+ ArticleService
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class AuthorizedArticlesController < ArticlesController
2
+ include Godmin::Authorization
3
+
4
+ def admin_user
5
+ "admin"
6
+ end
7
+
8
+ def resource_service_class
9
+ ArticleService
10
+ end
11
+ end
@@ -1,3 +1,8 @@
1
- class SessionsController < SecretController
1
+ class SessionsController < ApplicationController
2
2
  include Godmin::Authentication::SessionsController
3
+ include Godmin::Authentication
4
+
5
+ def admin_user_class
6
+ AdminUser
7
+ end
3
8
  end
@@ -1,2 +1,11 @@
1
1
  class Article < ActiveRecord::Base
2
+ belongs_to :admin_user
3
+
4
+ def non_orderable_column
5
+ "Not orderable"
6
+ end
7
+
8
+ def to_s
9
+ title
10
+ end
2
11
  end
@@ -0,0 +1,13 @@
1
+ class ArticlePolicy < Godmin::Authorization::Policy
2
+ def index?
3
+ true
4
+ end
5
+
6
+ def show?
7
+ user == "admin"
8
+ end
9
+
10
+ def destroy?
11
+ false
12
+ end
13
+ end
@@ -1,9 +1,13 @@
1
1
  class ArticleService
2
2
  include Godmin::Resources::ResourceService
3
3
 
4
- attrs_for_index :id, :title, :published, :created_at
5
- attrs_for_show :id, :title, :body, :published
6
- attrs_for_form :title, :body, :published
4
+ attrs_for_index :id, :title, :non_orderable_column, :admin_user, :published, :created_at
5
+ attrs_for_show :id, :title, :body, :admin_user, :published
6
+ attrs_for_form :title, :body, :admin_user, :published
7
+
8
+ def order_by_admin_user(resources, direction)
9
+ resources.joins(:admin_users).order("admin_users.email #{direction}")
10
+ end
7
11
 
8
12
  scope :unpublished
9
13
  scope :published
@@ -1,6 +1,7 @@
1
1
  Rails.application.routes.draw do
2
2
  resources :articles
3
- resources :secret_articles
3
+ resources :authenticated_articles
4
+ resources :authorized_articles
4
5
  resource :session, only: [:new, :create, :destroy]
5
6
  root to: "application#welcome"
6
7
  mount Admin::Engine, at: "admin"
@@ -4,6 +4,7 @@ class CreateArticles < ActiveRecord::Migration
4
4
  t.string :title
5
5
  t.text :body
6
6
  t.boolean :published, default: false
7
+ t.references :admin_user
7
8
 
8
9
  t.timestamps null: false
9
10
  end
@@ -23,9 +23,10 @@ ActiveRecord::Schema.define(version: 20150907133753) do
23
23
  create_table "articles", force: :cascade do |t|
24
24
  t.string "title"
25
25
  t.text "body"
26
- t.boolean "published", default: false
27
- t.datetime "created_at", null: false
28
- t.datetime "updated_at", null: false
26
+ t.boolean "published", default: false
27
+ t.integer "admin_user_id"
28
+ t.datetime "created_at", null: false
29
+ t.datetime "updated_at", null: false
29
30
  end
30
31
 
31
32
  end
@@ -1,4 +1,11 @@
1
1
  module Fakes
2
2
  class Article
3
+ def self.table_name
4
+ "articles"
5
+ end
6
+
7
+ def self.column_names
8
+ ["id", "title"]
9
+ end
3
10
  end
4
11
  end
@@ -21,7 +21,7 @@ module Fakes
21
21
 
22
22
  def initialize(*)
23
23
  super
24
- @called_methods = { scopes: {}, filters: {}, batch_actions: {} }
24
+ @called_methods = { scopes: {}, filters: {}, batch_actions: {}, ordering: {} }
25
25
  end
26
26
 
27
27
  def resource_class
@@ -32,6 +32,11 @@ module Fakes
32
32
  [:foo, :bar, :baz]
33
33
  end
34
34
 
35
+ def order_by_foobar(resources, direction)
36
+ called_methods[:ordering][:by_foobar] = [resources, direction]
37
+ resources
38
+ end
39
+
35
40
  def scope_unpublished(resources)
36
41
  called_methods[:scopes][:unpublished] = resources
37
42
  resources.slice(1, 3)
@@ -0,0 +1,17 @@
1
+ require "test_helper"
2
+
3
+ class AuthenticationTest < ActionDispatch::IntegrationTest
4
+ def test_sign_in_and_out
5
+ AdminUser.create!(email: "admin@example.com", password: "password")
6
+ visit authenticated_articles_path
7
+ assert_not_equal authenticated_articles_path, current_path
8
+ fill_in "Email", with: "admin@example.com"
9
+ fill_in "Password", with: "password"
10
+ click_button "Sign in"
11
+ visit authenticated_articles_path
12
+ assert_equal authenticated_articles_path, current_path
13
+ click_link "Sign out"
14
+ visit authenticated_articles_path
15
+ assert_not_equal authenticated_articles_path, current_path
16
+ end
17
+ end
@@ -0,0 +1,32 @@
1
+ require "test_helper"
2
+
3
+ class AuthorizationTest < ActionDispatch::IntegrationTest
4
+ def test_can_index?
5
+ visit authorized_articles_path
6
+ assert_equal 200, page.status_code
7
+ end
8
+
9
+ def test_can_show?
10
+ article = Article.create! title: "foo"
11
+
12
+ visit authorized_articles_path
13
+ within "[data-resource-id='#{article.id}']" do
14
+ click_link "Show"
15
+ end
16
+
17
+ assert_equal article_path(article), current_path
18
+ assert_equal 200, page.status_code
19
+ end
20
+
21
+ def test_cannot_destroy?
22
+ article = Article.create! title: "foo"
23
+
24
+ visit authorized_articles_path
25
+ within "[data-resource-id='#{article.id}']" do
26
+ assert page.has_no_content? "Destroy"
27
+ end
28
+
29
+ page.driver.delete authorized_article_path(article)
30
+ assert_equal 403, page.status_code
31
+ end
32
+ end
@@ -20,4 +20,16 @@ class ColumnOrderingTest < ActionDispatch::IntegrationTest
20
20
  link = find("#table th.column-created_at a")
21
21
  assert_equal "/articles?order=created_at_desc", link[:href]
22
22
  end
23
+
24
+ def test_order_links_when_not_orderable
25
+ visit articles_path
26
+ assert has_selector?("#table th.column-non_orderable_column")
27
+ assert has_no_link?("#table th.column-non_orderable_column a")
28
+ end
29
+
30
+ def test_order_links_when_custom_orderable
31
+ visit articles_path
32
+ link = find("#table th.column-admin_user a")
33
+ assert_equal "/articles?order=admin_user_desc", link[:href]
34
+ end
23
35
  end
@@ -0,0 +1,67 @@
1
+ require "test_helper"
2
+
3
+ class CrudTest < ActionDispatch::IntegrationTest
4
+ def test_list_resources
5
+ Article.create! title: "foo"
6
+ Article.create! title: "bar"
7
+
8
+ visit articles_path
9
+
10
+ assert page.has_content? "foo"
11
+ assert page.has_content? "bar"
12
+ end
13
+
14
+ def test_show_resource
15
+ article = Article.create! title: "foo", body: "bar"
16
+
17
+ visit articles_path
18
+ within "[data-resource-id='#{article.id}']" do
19
+ click_link "Show"
20
+ end
21
+
22
+ assert_equal article_path(article), current_path
23
+ assert page.has_content? "Title foo"
24
+ assert page.has_content? "Body bar"
25
+ end
26
+
27
+ def test_create_resource
28
+ visit articles_path
29
+ click_link "Create Article"
30
+ fill_in "Title", with: "foo"
31
+ fill_in "Body", with: "bar"
32
+ click_button "Create Article"
33
+
34
+ assert_equal article_path(Article.last), current_path
35
+ assert page.has_content? "Title foo"
36
+ assert page.has_content? "Body bar"
37
+ end
38
+
39
+ def test_update_resource
40
+ article = Article.create! title: "foo", body: "bar"
41
+
42
+ visit articles_path
43
+ within "[data-resource-id='#{article.id}']" do
44
+ click_link "Edit"
45
+ end
46
+ fill_in "Title", with: "baz"
47
+ click_button "Update Article"
48
+
49
+ assert_equal article_path(article), current_path
50
+ assert page.has_content? "Title baz"
51
+ assert page.has_content? "Body bar"
52
+ end
53
+
54
+ def test_destroy_resource
55
+ article_1 = Article.create! title: "foo"
56
+ article_2 = Article.create! title: "bar"
57
+
58
+ visit articles_path
59
+ within "[data-resource-id='#{article_1.id}']" do
60
+ click_link "Destroy"
61
+ end
62
+
63
+ assert_equal articles_path, current_path
64
+ assert page.has_no_content? "foo"
65
+ assert page.has_content? "bar"
66
+ end
67
+ end
@@ -4,12 +4,6 @@ module Godmin
4
4
  module ResourceService
5
5
  class OrderingTest < ActiveSupport::TestCase
6
6
  def setup
7
- resource_class = Class.new do
8
- def self.table_name
9
- "articles"
10
- end
11
- end
12
-
13
7
  @resources_class = Class.new do
14
8
  attr_reader :order_param
15
9
 
@@ -18,7 +12,8 @@ module Godmin
18
12
  end
19
13
  end
20
14
 
21
- @article_service = ArticleService.new(resource_class: resource_class)
15
+ @resources = @resources_class.new
16
+ @article_service = Fakes::ArticleService.new(resources: @resources)
22
17
  end
23
18
 
24
19
  def test_apply_order
@@ -32,6 +27,11 @@ module Godmin
32
27
  @article_service.apply_order("", resources)
33
28
  assert_equal nil, resources.order_param
34
29
  end
30
+
31
+ def test_apply_order_with_custom_ordering_method
32
+ @article_service.apply_order("foobar_desc", @resources)
33
+ assert_equal [@resources, "desc"], @article_service.called_methods[:ordering][:by_foobar]
34
+ end
35
35
  end
36
36
  end
37
37
  end
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.1.0
4
+ version: 1.2.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: 2015-12-08 00:00:00.000000000 Z
13
+ date: 2016-02-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bcrypt
@@ -378,18 +378,17 @@ files:
378
378
  - test/dummy/app/assets/stylesheets/application.css
379
379
  - test/dummy/app/controllers/application_controller.rb
380
380
  - test/dummy/app/controllers/articles_controller.rb
381
+ - test/dummy/app/controllers/authenticated_articles_controller.rb
382
+ - test/dummy/app/controllers/authorized_articles_controller.rb
381
383
  - test/dummy/app/controllers/concerns/.keep
382
- - test/dummy/app/controllers/secret_articles_controller.rb
383
- - test/dummy/app/controllers/secret_controller.rb
384
384
  - test/dummy/app/controllers/sessions_controller.rb
385
385
  - test/dummy/app/helpers/application_helper.rb
386
386
  - test/dummy/app/models/.keep
387
387
  - test/dummy/app/models/admin_user.rb
388
388
  - test/dummy/app/models/article.rb
389
389
  - test/dummy/app/models/concerns/.keep
390
- - test/dummy/app/models/secret_article.rb
390
+ - test/dummy/app/policies/article_policy.rb
391
391
  - test/dummy/app/services/article_service.rb
392
- - test/dummy/app/services/secret_article_service.rb
393
392
  - test/dummy/app/views/articles/.keep
394
393
  - test/dummy/app/views/articles/columns/.keep
395
394
  - test/dummy/app/views/articles/filters/.keep
@@ -426,15 +425,17 @@ files:
426
425
  - test/dummy/public/favicon.ico
427
426
  - test/fakes/article.rb
428
427
  - test/fakes/article_service.rb
428
+ - test/integration/authentication_test.rb
429
+ - test/integration/authorization_test.rb
429
430
  - test/integration/batch_actions_test.rb
430
431
  - test/integration/column_ordering_test.rb
431
- - test/integration/column_overriding_test.rb
432
- - test/integration/filter_overriding_test.rb
432
+ - test/integration/crud_test.rb
433
433
  - test/integration/filters_test.rb
434
- - test/integration/partial_overriding_test.rb
435
434
  - test/integration/scopes_test.rb
436
- - test/integration/sign_in_test.rb
437
- - test/integration/template_overriding_test.rb
435
+ - test/integration/view_overriding/column_overriding_test.rb
436
+ - test/integration/view_overriding/filter_overriding_test.rb
437
+ - test/integration/view_overriding/partial_overriding_test.rb
438
+ - test/integration/view_overriding/template_overriding_test.rb
438
439
  - test/integration/welcome_test.rb
439
440
  - test/lib/godmin/engine_wrapper_test.rb
440
441
  - test/lib/godmin/helpers/filters_test.rb
@@ -500,18 +501,17 @@ test_files:
500
501
  - test/dummy/app/assets/stylesheets/application.css
501
502
  - test/dummy/app/controllers/application_controller.rb
502
503
  - test/dummy/app/controllers/articles_controller.rb
504
+ - test/dummy/app/controllers/authenticated_articles_controller.rb
505
+ - test/dummy/app/controllers/authorized_articles_controller.rb
503
506
  - test/dummy/app/controllers/concerns/.keep
504
- - test/dummy/app/controllers/secret_articles_controller.rb
505
- - test/dummy/app/controllers/secret_controller.rb
506
507
  - test/dummy/app/controllers/sessions_controller.rb
507
508
  - test/dummy/app/helpers/application_helper.rb
508
509
  - test/dummy/app/models/.keep
509
510
  - test/dummy/app/models/admin_user.rb
510
511
  - test/dummy/app/models/article.rb
511
512
  - test/dummy/app/models/concerns/.keep
512
- - test/dummy/app/models/secret_article.rb
513
+ - test/dummy/app/policies/article_policy.rb
513
514
  - test/dummy/app/services/article_service.rb
514
- - test/dummy/app/services/secret_article_service.rb
515
515
  - test/dummy/app/views/articles/.keep
516
516
  - test/dummy/app/views/articles/columns/.keep
517
517
  - test/dummy/app/views/articles/filters/.keep
@@ -548,15 +548,17 @@ test_files:
548
548
  - test/dummy/public/favicon.ico
549
549
  - test/fakes/article.rb
550
550
  - test/fakes/article_service.rb
551
+ - test/integration/authentication_test.rb
552
+ - test/integration/authorization_test.rb
551
553
  - test/integration/batch_actions_test.rb
552
554
  - test/integration/column_ordering_test.rb
553
- - test/integration/column_overriding_test.rb
554
- - test/integration/filter_overriding_test.rb
555
+ - test/integration/crud_test.rb
555
556
  - test/integration/filters_test.rb
556
- - test/integration/partial_overriding_test.rb
557
557
  - test/integration/scopes_test.rb
558
- - test/integration/sign_in_test.rb
559
- - test/integration/template_overriding_test.rb
558
+ - test/integration/view_overriding/column_overriding_test.rb
559
+ - test/integration/view_overriding/filter_overriding_test.rb
560
+ - test/integration/view_overriding/partial_overriding_test.rb
561
+ - test/integration/view_overriding/template_overriding_test.rb
560
562
  - test/integration/welcome_test.rb
561
563
  - test/lib/godmin/engine_wrapper_test.rb
562
564
  - test/lib/godmin/helpers/filters_test.rb
@@ -1,3 +0,0 @@
1
- class SecretArticlesController < SecretController
2
- include Godmin::Resources::ResourceController
3
- end
@@ -1,7 +0,0 @@
1
- class SecretController < ApplicationController
2
- include Godmin::Authentication
3
-
4
- def admin_user_class
5
- AdminUser
6
- end
7
- end
@@ -1,2 +0,0 @@
1
- class SecretArticle < Article
2
- end
@@ -1,2 +0,0 @@
1
- class SecretArticleService < ArticleService
2
- end
@@ -1,17 +0,0 @@
1
- require "test_helper"
2
-
3
- class SignInTest < ActionDispatch::IntegrationTest
4
- def test_sign_in_and_out
5
- AdminUser.create!(email: "admin@example.com", password: "password")
6
- visit secret_articles_path
7
- assert_not_equal secret_articles_path, current_path
8
- fill_in "Email", with: "admin@example.com"
9
- fill_in "Password", with: "password"
10
- click_button "Sign in"
11
- visit secret_articles_path
12
- assert_equal secret_articles_path, current_path
13
- click_link "Sign out"
14
- visit secret_articles_path
15
- assert_not_equal secret_articles_path, current_path
16
- end
17
- end