miau 1.1.6 → 1.1.8

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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -0
  3. data/lib/miau/error.rb +4 -8
  4. data/lib/miau/run.rb +2 -2
  5. data/lib/miau/storage.rb.bak +63 -0
  6. data/lib/miau/version.rb +3 -1
  7. data/lib/miau/version.rb.bak +17 -0
  8. data/lib/miau.rb +5 -0
  9. data/lib/miau.rb.bak +72 -0
  10. metadata +16 -44
  11. data/.github/workflows/rake.yml +0 -27
  12. data/.gitignore +0 -10
  13. data/.ruby-gemset +0 -1
  14. data/.ruby-version +0 -1
  15. data/Appraisals +0 -13
  16. data/Gemfile +0 -12
  17. data/Gemfile.lock +0 -279
  18. data/Rakefile +0 -10
  19. data/gemfiles/rails_6.1.gemfile +0 -16
  20. data/gemfiles/rails_7.0.gemfile +0 -16
  21. data/gemfiles/rails_7.1.gemfile +0 -15
  22. data/miau.gemspec +0 -27
  23. data/test/authorization_test.rb +0 -28
  24. data/test/benchmark_test.rb +0 -34
  25. data/test/controller_test.rb +0 -58
  26. data/test/controllers/orders_controller_test.rb +0 -47
  27. data/test/internal/app/controllers/application_controller.rb +0 -7
  28. data/test/internal/app/controllers/orders_controller.rb +0 -61
  29. data/test/internal/app/controllers/posts_controller.rb +0 -10
  30. data/test/internal/app/models/application_record.rb +0 -3
  31. data/test/internal/app/models/order.rb +0 -2
  32. data/test/internal/app/models/post.rb +0 -2
  33. data/test/internal/app/policies/orders_policy.rb +0 -16
  34. data/test/internal/app/policies/posts_policy.rb +0 -18
  35. data/test/internal/app/views/orders/new.html.erb +0 -5
  36. data/test/internal/config/database.yml +0 -3
  37. data/test/internal/config/routes.rb +0 -3
  38. data/test/internal/db/migrate/20141016161801_create_orders.rb +0 -10
  39. data/test/internal/db/schema.rb +0 -8
  40. data/test/miau_test.rb +0 -46
  41. data/test/run_test.rb +0 -69
  42. data/test/storage_test.rb +0 -51
  43. data/test/test_helper.rb +0 -17
  44. /data/{LICENSE → MIT-LICENSE} +0 -0
@@ -1,8 +0,0 @@
1
- ActiveRecord::Schema.define(version: 20141016161801) do
2
- create_table "orders", force: true do |t|
3
- t.string "name"
4
- t.string "qty"
5
- t.datetime "created_at", null: false
6
- t.datetime "updated_at", null: false
7
- end
8
- end
data/test/miau_test.rb DELETED
@@ -1,46 +0,0 @@
1
- require "test_helper"
2
-
3
- describe Miau do
4
- let(:user) { "User" }
5
- let(:post) { Post.new(user, 1) }
6
- let(:params) { {action: "si", controller: "posts"} }
7
- let(:posts_controller) { PostsController.new(user, params) }
8
-
9
- describe "#authorize!" do
10
- def test_ok_no_raise
11
- posts_controller.authorize!(post)
12
- end
13
-
14
- def test_return_false
15
- posts_controller.params[:action] = "no"
16
- assert_raises(Miau::NotAuthorizedError) {
17
- posts_controller.authorize!(post)
18
- }
19
- end
20
-
21
- def test_NotDefinedError
22
- posts_controller.params[:controller] = "articles"
23
- assert_raises(Miau::NotDefinedError) {
24
- posts_controller.authorize!(post)
25
- }
26
- end
27
-
28
- def test_NoMethodError
29
- posts_controller.params[:action] = "unknown"
30
- assert_raises(Miau::NotDefinedError) {
31
- posts_controller.authorize!(post)
32
- }
33
- end
34
- end
35
-
36
- describe "#authorized?" do
37
- def test_return_true
38
- assert posts_controller.authorized?(post)
39
- end
40
-
41
- def test_return_false
42
- posts_controller.params[:action] = "no"
43
- refute posts_controller.authorized?(post)
44
- end
45
- end
46
- end
data/test/run_test.rb DELETED
@@ -1,69 +0,0 @@
1
- require "test_helper"
2
-
3
- class ApplicationPolicy
4
- miau :nein, :ja
5
-
6
- def ja
7
- true
8
- end
9
- end
10
-
11
- class SiiPolicy < ApplicationPolicy
12
- miau :no, :si
13
-
14
- def si
15
- true
16
- end
17
-
18
- def run
19
- puts :run # use by capture_io
20
- true
21
- end
22
- end
23
-
24
- describe Miau, "run2" do
25
- let(:storage) { Miau::PolicyStorage.instance }
26
- let(:miau_run) { Miau::PolicyRun.instance }
27
- let(:policy) { SiiPolicy.new }
28
- let(:user) { "User" }
29
-
30
- def test_find_methods_si
31
- assert_equal :si, miau_run.find_methods(policy, :sii, :si)
32
- end
33
-
34
- def test_find_methods_no
35
- assert_equal :si, miau_run.find_methods(policy, :sii, :no)
36
- end
37
-
38
- def test_find_methods_unknown
39
- refute miau_run.find_methods(policy, :sii, :unknown)
40
- end
41
-
42
- def test_find_methods_ja
43
- assert_equal :ja, miau_run.find_methods(policy, :sii, :ja)
44
- end
45
-
46
- def test_find_methods_nein
47
- assert_equal :ja, miau_run.find_methods(policy, :sii, :ja)
48
- end
49
-
50
- def test_runs
51
- out, _err = capture_io do
52
- miau_run.runs(policy, :run)
53
- end
54
-
55
- assert_equal "run\n", out
56
- end
57
-
58
- def test_raise_undef
59
- assert_raises(Miau::NotDefinedError) {
60
- miau_run.raise_undef(:sii, :ja)
61
- }
62
- end
63
-
64
- def test_raise_authorize
65
- assert_raises(Miau::NotAuthorizedError) {
66
- miau_run.raise_authorize(:sii, :ja)
67
- }
68
- end
69
- end
data/test/storage_test.rb DELETED
@@ -1,51 +0,0 @@
1
- require "test_helper"
2
- require "yaml"
3
-
4
- class MyPolicy < ApplicationPolicy
5
- miau %i[appli2], :appli1
6
- miau %i[appli3], %i[fail ok]
7
-
8
- def appli1
9
- true
10
- end
11
-
12
- def fail
13
- false
14
- end
15
-
16
- def ok
17
- true
18
- end
19
- end
20
-
21
- describe Miau, "storage" do
22
- let(:storage) { Miau::PolicyStorage.instance }
23
-
24
- def test_add_policy_method
25
- storage.add_policy "my", "fail", "ok"
26
-
27
- str = storage.to_yaml
28
- assert_match(/:my/, str)
29
- assert_match(/:fail: :ok/, str)
30
- end
31
-
32
- def test_find_or_create_policy
33
- storage.find_or_create_policy "application"
34
-
35
- assert ApplicationPolicy, storage.instances[:application]
36
- end
37
-
38
- def test_overwrite
39
- storage.add_policy "my", "first", "ok"
40
- assert_raises(Miau::OverwriteError) {
41
- storage.add_policy "my", "first", "ok"
42
- }
43
- end
44
-
45
- def test_coverage_to_yaml
46
- str = storage.to_yaml
47
-
48
- assert str
49
- # puts str
50
- end
51
- end
data/test/test_helper.rb DELETED
@@ -1,17 +0,0 @@
1
- if ENV["COVERAGE"]
2
- require "simplecov"
3
- SimpleCov.start do
4
- add_filter "/test/"
5
- end
6
- end
7
-
8
- ENV["RAILS_ENV"] ||= "test"
9
-
10
- require "miau"
11
-
12
- require "combustion"
13
- Combustion.path = "test/internal"
14
- Combustion.initialize! :active_record
15
-
16
- require "minitest/autorun"
17
- require "rails/test_help"
File without changes