arpa 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +17 -0
  3. data/.ruby-version +1 -1
  4. data/.travis.yml +5 -0
  5. data/CHANGELOG.md +4 -0
  6. data/README.md +4 -4
  7. data/Rakefile +1 -2
  8. data/arpa.gemspec +17 -18
  9. data/lib/arpa.rb +65 -67
  10. data/lib/arpa/additions/resource.rb +0 -2
  11. data/lib/arpa/data_mappers/action_mapper.rb +1 -2
  12. data/lib/arpa/data_mappers/base.rb +15 -16
  13. data/lib/arpa/data_mappers/profile_mapper.rb +3 -4
  14. data/lib/arpa/data_mappers/resource_mapper.rb +1 -1
  15. data/lib/arpa/data_mappers/role_mapper.rb +2 -2
  16. data/lib/arpa/entities/action.rb +0 -2
  17. data/lib/arpa/entities/profile.rb +2 -3
  18. data/lib/arpa/entities/resource.rb +4 -6
  19. data/lib/arpa/entities/role.rb +2 -3
  20. data/lib/arpa/exceptions/record_invalid.rb +0 -1
  21. data/lib/arpa/repositories/actions/creator.rb +0 -1
  22. data/lib/arpa/repositories/actions/finder.rb +5 -6
  23. data/lib/arpa/repositories/actions/remover.rb +0 -1
  24. data/lib/arpa/repositories/actions/repository_action.rb +1 -2
  25. data/lib/arpa/repositories/base.rb +0 -2
  26. data/lib/arpa/repositories/profiles/creator.rb +0 -1
  27. data/lib/arpa/repositories/profiles/finder.rb +2 -3
  28. data/lib/arpa/repositories/profiles/remover.rb +0 -1
  29. data/lib/arpa/repositories/profiles/repository_profile.rb +1 -2
  30. data/lib/arpa/repositories/profiles/updater.rb +0 -1
  31. data/lib/arpa/repositories/registrator.rb +5 -10
  32. data/lib/arpa/repositories/resources/creator.rb +0 -1
  33. data/lib/arpa/repositories/resources/finder.rb +0 -1
  34. data/lib/arpa/repositories/resources/remover.rb +0 -1
  35. data/lib/arpa/repositories/resources/repository_resource.rb +1 -2
  36. data/lib/arpa/repositories/roles/creator.rb +0 -1
  37. data/lib/arpa/repositories/roles/finder.rb +0 -1
  38. data/lib/arpa/repositories/roles/remover.rb +0 -1
  39. data/lib/arpa/repositories/roles/repository_role.rb +1 -2
  40. data/lib/arpa/repositories/roles/updater.rb +0 -1
  41. data/lib/arpa/services/actions/create/action_creator.rb +1 -3
  42. data/lib/arpa/services/actions/remove/action_remover.rb +0 -2
  43. data/lib/arpa/services/base.rb +6 -10
  44. data/lib/arpa/services/profiles/create/profile_creator.rb +0 -2
  45. data/lib/arpa/services/profiles/profile_manager_creator.rb +0 -1
  46. data/lib/arpa/services/profiles/profile_manager_remover.rb +0 -1
  47. data/lib/arpa/services/profiles/profile_manager_updater.rb +0 -1
  48. data/lib/arpa/services/profiles/remove/profile_remover.rb +0 -2
  49. data/lib/arpa/services/profiles/update/profile_updater.rb +0 -2
  50. data/lib/arpa/services/resources/create/resource_creator.rb +0 -2
  51. data/lib/arpa/services/resources/remove/resource_remover.rb +1 -4
  52. data/lib/arpa/services/resources/resource_manager_creator.rb +1 -2
  53. data/lib/arpa/services/roles/create/role_creator.rb +0 -3
  54. data/lib/arpa/services/roles/remove/role_remover.rb +0 -2
  55. data/lib/arpa/services/roles/role_manager_creator.rb +0 -2
  56. data/lib/arpa/services/roles/role_manager_remover.rb +0 -1
  57. data/lib/arpa/services/roles/role_manager_updater.rb +0 -1
  58. data/lib/arpa/services/roles/update/role_updater.rb +0 -2
  59. data/lib/arpa/services/verifier.rb +0 -1
  60. data/lib/arpa/validators/action_validator.rb +0 -1
  61. data/lib/arpa/validators/profile_validator.rb +0 -1
  62. data/lib/arpa/validators/resource_validator.rb +0 -1
  63. data/lib/arpa/validators/role_validator.rb +0 -2
  64. data/lib/arpa/version.rb +1 -1
  65. data/lib/generators/arpa/controllers_generator.rb +21 -22
  66. data/lib/generators/arpa/install_generator.rb +5 -6
  67. data/lib/generators/arpa/templates/controllers/profiles_controller.rb +31 -37
  68. data/lib/generators/arpa/templates/controllers/resources_controller.rb +20 -11
  69. data/lib/generators/arpa/templates/controllers/roles_controller.rb +31 -37
  70. data/lib/generators/arpa/templates/migration.rb +1 -1
  71. data/spec/factories/repository_actions.rb +4 -5
  72. data/spec/factories/repository_profiles.rb +4 -5
  73. data/spec/factories/repository_resources.rb +1 -3
  74. data/spec/factories/repository_roles.rb +2 -3
  75. data/spec/factories/repository_test.rb +1 -1
  76. data/spec/lib/arpa/additions/resource_spec.rb +8 -6
  77. data/spec/lib/arpa/data_mappers/action_mapper_spec.rb +1 -3
  78. data/spec/lib/arpa/data_mappers/base_spec.rb +0 -2
  79. data/spec/lib/arpa/data_mappers/profile_mapper_spec.rb +1 -3
  80. data/spec/lib/arpa/data_mappers/resource_mapper_spec.rb +1 -3
  81. data/spec/lib/arpa/data_mappers/role_mapper_spec.rb +1 -3
  82. data/spec/lib/arpa/entities/action_spec.rb +3 -6
  83. data/spec/lib/arpa/entities/profile_spec.rb +1 -7
  84. data/spec/lib/arpa/entities/resource_spec.rb +1 -9
  85. data/spec/lib/arpa/entities/role_spec.rb +1 -7
  86. data/spec/lib/arpa/repositories/actions/finder_spec.rb +1 -8
  87. data/spec/lib/arpa/repositories/base_spec.rb +1 -9
  88. data/spec/lib/arpa/repositories/profiles/finder_spec.rb +0 -6
  89. data/spec/lib/arpa/repositories/profiles/remover_spec.rb +0 -4
  90. data/spec/lib/arpa/repositories/resources/finder_spec.rb +0 -8
  91. data/spec/lib/arpa/repositories/resources/remover_spec.rb +0 -4
  92. data/spec/lib/arpa/repositories/roles/finder_spec.rb +0 -4
  93. data/spec/lib/arpa/repositories/roles/remover_spec.rb +0 -4
  94. data/spec/lib/arpa/requests/profiles/create_request_spec.rb +10 -12
  95. data/spec/lib/arpa/requests/profiles/remove_request_spec.rb +4 -9
  96. data/spec/lib/arpa/requests/resources/create_request_spec.rb +18 -21
  97. data/spec/lib/arpa/requests/roles/create_request_spec.rb +7 -9
  98. data/spec/lib/arpa/requests/roles/remove_request_spec.rb +3 -6
  99. data/spec/lib/arpa/requests/roles/update_request_spec.rb +7 -9
  100. data/spec/lib/arpa/services/actions/create/action_creator_spec.rb +5 -14
  101. data/spec/lib/arpa/services/actions/remove/action_remover_spec.rb +3 -6
  102. data/spec/lib/arpa/services/base_spec.rb +8 -15
  103. data/spec/lib/arpa/services/profiles/create/profile_creator_spec.rb +0 -7
  104. data/spec/lib/arpa/services/profiles/profile_manager_creator_spec.rb +2 -4
  105. data/spec/lib/arpa/services/profiles/profile_manager_remover_spec.rb +3 -6
  106. data/spec/lib/arpa/services/profiles/profile_manager_updater_spec.rb +2 -4
  107. data/spec/lib/arpa/services/profiles/remove/profile_remover_spec.rb +0 -5
  108. data/spec/lib/arpa/services/profiles/update/profile_updater_spec.rb +0 -7
  109. data/spec/lib/arpa/services/resources/create/resource_creator_spec.rb +1 -7
  110. data/spec/lib/arpa/services/resources/remove/resource_remover_spec.rb +2 -6
  111. data/spec/lib/arpa/services/resources/resource_manager_creator_spec.rb +5 -7
  112. data/spec/lib/arpa/services/roles/create/role_creator_spec.rb +0 -7
  113. data/spec/lib/arpa/services/roles/remove/role_remover_spec.rb +1 -8
  114. data/spec/lib/arpa/services/roles/role_manager_creator_spec.rb +2 -4
  115. data/spec/lib/arpa/services/roles/role_manager_remover_spec.rb +2 -4
  116. data/spec/lib/arpa/services/roles/role_manager_updater_spec.rb +2 -4
  117. data/spec/lib/arpa/services/roles/update/role_updater_spec.rb +0 -7
  118. data/spec/lib/arpa/services/verifier_spec.rb +3 -6
  119. data/spec/lib/arpa/validators/action_validator_spec.rb +0 -1
  120. data/spec/lib/arpa/validators/profile_validator_spec.rb +1 -2
  121. data/spec/lib/arpa/validators/resource_validator_spec.rb +0 -1
  122. data/spec/lib/arpa/validators/role_validator_spec.rb +1 -2
  123. data/spec/spec_helper.rb +4 -6
  124. data/spec/support/schema.rb +9 -10
  125. metadata +40 -36
@@ -1,13 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Arpa::Entities::Role, type: :entity, fast: true do
4
-
5
4
  describe 'initializing' do
6
-
7
5
  describe 'setting default values' do
8
-
9
6
  context 'when pass some parameters as nil' do
10
-
11
7
  it 'attribute :action_ids should be an empty Array' do
12
8
  expect(subject.action_ids).to eq []
13
9
  end
@@ -27,7 +23,7 @@ describe Arpa::Entities::Role, type: :entity, fast: true do
27
23
  end
28
24
 
29
25
  context 'when pass some parameters as empty' do
30
- let(:attrs) { {action_ids: '', actions: '', profiles: '', removed: ''} }
26
+ let(:attrs) { { action_ids: '', actions: '', profiles: '', removed: '' } }
31
27
  subject { Arpa::Entities::Role.new attrs }
32
28
 
33
29
  it 'attribute :action_ids should be an empty Array' do
@@ -46,7 +42,5 @@ describe Arpa::Entities::Role, type: :entity, fast: true do
46
42
  expect(subject.removed).to be_falsey
47
43
  end
48
44
  end
49
-
50
45
  end
51
-
52
46
  end
@@ -1,10 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Arpa::Repositories::Actions::Finder, type: :repository, slow: true do
4
-
5
4
  let(:resource_record) { create :repository_resource, :user }
6
5
  let(:action_record_001) { create :repository_action, :index, resource: resource_record }
7
- let(:action_record_002) { create :repository_action, :show, resource: resource_record}
6
+ let(:action_record_002) { create :repository_action, :show, resource: resource_record }
8
7
 
9
8
  before do
10
9
  action_record_001
@@ -12,9 +11,7 @@ describe Arpa::Repositories::Actions::Finder, type: :repository, slow: true do
12
11
  end
13
12
 
14
13
  describe '#by_name_and_resource' do
15
-
16
14
  context 'when exist with the params' do
17
-
18
15
  let(:result) { subject.by_name_and_resource('index', resource_record) }
19
16
 
20
17
  it 'should return a resource with name "index"' do
@@ -27,14 +24,12 @@ describe Arpa::Repositories::Actions::Finder, type: :repository, slow: true do
27
24
  end
28
25
 
29
26
  context 'when nonexist with the params' do
30
-
31
27
  let(:result) { subject.by_name_and_resource('nonexist_action', resource_record) }
32
28
 
33
29
  it 'the result should return nil' do
34
30
  expect(result).to be_nil
35
31
  end
36
32
  end
37
-
38
33
  end
39
34
 
40
35
  describe 'getting permission from action_name, resource_name and profile_ids' do
@@ -71,11 +66,9 @@ describe Arpa::Repositories::Actions::Finder, type: :repository, slow: true do
71
66
  end
72
67
 
73
68
  context 'when action and resource not belogns to any profile' do
74
-
75
69
  it 'should not return any permission' do
76
70
  expect(result).to be_nil
77
71
  end
78
72
  end
79
73
  end
80
-
81
74
  end
@@ -5,33 +5,25 @@ class BaseImplementationTest
5
5
  end
6
6
 
7
7
  describe Arpa::Repositories::Base, type: :repository, fast: true do
8
-
9
8
  let(:base_implementation) { BaseImplementationTest.new }
10
9
 
11
10
  context 'when Implementation class do not override methods from Base' do
12
-
13
11
  context 'when call :mapper_instance' do
14
-
15
12
  it 'should raise NotImplementedError' do
16
13
  expect { base_implementation.mapper_instance }.to raise_error do |error|
17
14
  expect(error).to be_a NotImplementedError
18
15
  expect(error.message).to eql 'This BaseImplementationTest cannot respond :mapper_instance'
19
16
  end
20
17
  end
21
-
22
18
  end
23
19
 
24
20
  context 'when call :repository_class' do
25
-
26
21
  it 'should raise NotImplementedError' do
27
- expect { base_implementation.repository_class}.to raise_error do |error|
22
+ expect { base_implementation.repository_class }.to raise_error do |error|
28
23
  expect(error).to be_a NotImplementedError
29
24
  expect(error.message).to eql 'This BaseImplementationTest cannot respond :repository_class'
30
25
  end
31
26
  end
32
-
33
27
  end
34
-
35
28
  end
36
-
37
29
  end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Arpa::Repositories::Profiles::Finder, type: :repository, slow: true do
4
-
5
4
  let(:record_001) { create :repository_profile, name: 'profile_01' }
6
5
  let(:record_002) { create :repository_profile, name: 'profile_02' }
7
6
 
@@ -20,7 +19,6 @@ describe Arpa::Repositories::Profiles::Finder, type: :repository, slow: true do
20
19
  it 'the result should be an Arpa::Entities::Profile' do
21
20
  expect(result).to be_an Arpa::Entities::Profile
22
21
  end
23
-
24
22
  end
25
23
 
26
24
  describe '#all' do
@@ -37,11 +35,9 @@ describe Arpa::Repositories::Profiles::Finder, type: :repository, slow: true do
37
35
  it 'the result should be an Array of Arpa::Entities::Profile' do
38
36
  expect(result.first).to be_an Arpa::Entities::Profile
39
37
  end
40
-
41
38
  end
42
39
 
43
40
  describe '#all_by_entity' do
44
-
45
41
  context 'when have profiles with differents entities' do
46
42
  let(:entity_001) { create :entity }
47
43
  let(:record_003) { create :repository_profile, name: 'profile_03', entity_id: entity_001.id, entity_class: entity_001.class }
@@ -72,8 +68,6 @@ describe Arpa::Repositories::Profiles::Finder, type: :repository, slow: true do
72
68
  expect(third.entity_id).to be == entity_001.id
73
69
  expect(third.entity_class).to eql entity_001.class.to_s
74
70
  end
75
-
76
71
  end
77
72
  end
78
-
79
73
  end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Arpa::Repositories::Profiles::Remover, type: :repository, slow: true do
4
-
5
4
  let(:created_profile) { create :repository_profile }
6
5
 
7
6
  before { created_profile }
@@ -12,7 +11,6 @@ describe Arpa::Repositories::Profiles::Remover, type: :repository, slow: true do
12
11
  it 'should destroy the role' do
13
12
  expect { destroy_profile }.to change(Arpa::Repositories::Profiles::RepositoryProfile, :count).by(-1)
14
13
  end
15
-
16
14
  end
17
15
 
18
16
  describe '#disable' do
@@ -25,7 +23,5 @@ describe Arpa::Repositories::Profiles::Remover, type: :repository, slow: true do
25
23
  it 'role should be setted to removed: true' do
26
24
  expect(disable_profile.removed).to be_truthy
27
25
  end
28
-
29
26
  end
30
-
31
27
  end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Arpa::Repositories::Resources::Finder, type: :repository, slow: true do
4
-
5
4
  let(:record_001) { create :repository_resource, :user }
6
5
  let(:record_002) { create :repository_resource, :contact }
7
6
 
@@ -15,7 +14,6 @@ describe Arpa::Repositories::Resources::Finder, type: :repository, slow: true do
15
14
  it 'the result should be an Arpa::Entities::Resource' do
16
15
  expect(result).to be_an Arpa::Entities::Resource
17
16
  end
18
-
19
17
  end
20
18
 
21
19
  describe '#all' do
@@ -26,7 +24,6 @@ describe Arpa::Repositories::Resources::Finder, type: :repository, slow: true do
26
24
  record_002
27
25
  end
28
26
 
29
-
30
27
  it 'should return size 2' do
31
28
  expect(result.size).to be == 2
32
29
  end
@@ -38,18 +35,15 @@ describe Arpa::Repositories::Resources::Finder, type: :repository, slow: true do
38
35
  it 'the result should be an Array of Arpa::Entities::Resource' do
39
36
  expect(result.first).to be_an Arpa::Entities::Resource
40
37
  end
41
-
42
38
  end
43
39
 
44
40
  describe '#by_full_name' do
45
-
46
41
  before do
47
42
  record_001
48
43
  record_002
49
44
  end
50
45
 
51
46
  context 'when exist with the full_name' do
52
-
53
47
  let(:result) { subject.by_full_name('UsersController') }
54
48
 
55
49
  it 'should return a resource with name "users"' do
@@ -62,13 +56,11 @@ describe Arpa::Repositories::Resources::Finder, type: :repository, slow: true do
62
56
  end
63
57
 
64
58
  context 'when nonexist with the full_name' do
65
-
66
59
  let(:result) { subject.by_full_name('NonessController') }
67
60
 
68
61
  it 'the result should return nil' do
69
62
  expect(result).to be_nil
70
63
  end
71
64
  end
72
-
73
65
  end
74
66
  end
@@ -1,12 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Arpa::Repositories::Resources::Remover, type: :repository, slow: true do
4
-
5
4
  let(:resource_001) { create :repository_resource, :user }
6
5
  let(:destroy_resource) { subject.destroy(resource_001) }
7
6
 
8
7
  describe '#destroy' do
9
-
10
8
  context 'when resource has no actions associate' do
11
9
  let(:actions) { [] }
12
10
 
@@ -31,8 +29,6 @@ describe Arpa::Repositories::Resources::Remover, type: :repository, slow: true d
31
29
  it 'should destroy all actions associate with resource' do
32
30
  expect { destroy_resource }.to change(Arpa::Repositories::Actions::RepositoryAction, :count).by(-2)
33
31
  end
34
-
35
32
  end
36
-
37
33
  end
38
34
  end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Arpa::Repositories::Roles::Finder, type: :repository, slow: true do
4
-
5
4
  let(:record_001) { create :repository_role, name: 'role_01' }
6
5
  let(:record_002) { create :repository_role, name: 'role_02' }
7
6
 
@@ -20,7 +19,6 @@ describe Arpa::Repositories::Roles::Finder, type: :repository, slow: true do
20
19
  it 'the result should be an Arpa::Entities::Role' do
21
20
  expect(result).to be_an Arpa::Entities::Role
22
21
  end
23
-
24
22
  end
25
23
 
26
24
  describe '#all' do
@@ -37,7 +35,5 @@ describe Arpa::Repositories::Roles::Finder, type: :repository, slow: true do
37
35
  it 'the result should be an Array of Arpa::Entities::Role' do
38
36
  expect(result.first).to be_an Arpa::Entities::Role
39
37
  end
40
-
41
38
  end
42
-
43
39
  end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Arpa::Repositories::Roles::Remover, type: :repository, slow: true do
4
-
5
4
  let(:created_role) { create :repository_role }
6
5
 
7
6
  before { created_role }
@@ -12,7 +11,6 @@ describe Arpa::Repositories::Roles::Remover, type: :repository, slow: true do
12
11
  it 'should destroy the role' do
13
12
  expect { destroy_role }.to change(Arpa::Repositories::Roles::RepositoryRole, :count).by(-1)
14
13
  end
15
-
16
14
  end
17
15
 
18
16
  describe '#disable' do
@@ -25,7 +23,5 @@ describe Arpa::Repositories::Roles::Remover, type: :repository, slow: true do
25
23
  it 'role should be setted to removed: true' do
26
24
  expect(disable_role.removed).to be_truthy
27
25
  end
28
-
29
26
  end
30
-
31
27
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- RSpec.describe "Create Profile", type: [:request, :profile] do
3
+ RSpec.describe 'Create Profile', type: %i[request profile] do
4
4
  let(:finder_profile_repo) { Arpa::Repositories::Profiles::Finder.new }
5
5
  let(:finder_resource_repo) { Arpa::Repositories::Resources::Finder.new }
6
6
  let(:finder_role_repo) { Arpa::Repositories::Roles::Finder.new }
@@ -8,28 +8,28 @@ RSpec.describe "Create Profile", type: [:request, :profile] do
8
8
  let(:creator_role_service) { Arpa::Services::Roles::RoleManagerCreator.new }
9
9
  let(:creator_profile_service) { Arpa::Services::Profiles::ProfileManagerCreator.new }
10
10
  let(:success_proc) { ->(r) {} }
11
- let(:callback) { {success: success_proc, fail: ->(e) {raise e} } }
11
+ let(:callback) { { success: success_proc, fail: ->(e) { raise e } } }
12
12
 
13
13
  context 'when have no created resources or actions' do
14
14
  let(:resourceable_001) { double to_s: 'UsersController', action_methods: [:index, :show, 'edit'] }
15
15
  let(:resourceable_002) { double to_s: 'ContactsController', action_methods: [:index, 'edit'] }
16
16
  let(:resourceables) { [resourceable_001, resourceable_002] }
17
- let(:created_resources) { creator_resource_service.create({resourceables: resourceables}, callback) }
17
+ let(:created_resources) { creator_resource_service.create({ resourceables: resourceables }, callback) }
18
18
 
19
- let(:action_ids) { finder_resource_repo.all.first.actions.collect{ |action| action.id} }
20
- let(:role_001_params) { {role: {name: 'role_name_001', description: 'role_description_001', action_ids: action_ids}} }
21
- let(:role_002_params) { {role: {name: 'role_name_002', description: 'role_description_002', action_ids: action_ids}} }
19
+ let(:action_ids) { finder_resource_repo.all.first.actions.collect(&:id) }
20
+ let(:role_001_params) { { role: { name: 'role_name_001', description: 'role_description_001', action_ids: action_ids } } }
21
+ let(:role_002_params) { { role: { name: 'role_name_002', description: 'role_description_002', action_ids: action_ids } } }
22
22
  let(:created_roles) do
23
23
  creator_role_service.create(role_001_params, callback)
24
24
  creator_role_service.create(role_002_params, callback)
25
25
  end
26
26
 
27
- let(:role_ids) { finder_role_repo.all.map { |r| r.id } }
27
+ let(:role_ids) { finder_role_repo.all.map(&:id) }
28
28
 
29
29
  before do
30
30
  created_resources
31
31
  created_roles
32
- profile_params = {profile: {name: 'profile_name', description: 'profile_description', role_ids: role_ids}}
32
+ profile_params = { profile: { name: 'profile_name', description: 'profile_description', role_ids: role_ids } }
33
33
  creator_profile_service.create(profile_params, callback)
34
34
  end
35
35
 
@@ -42,10 +42,8 @@ RSpec.describe "Create Profile", type: [:request, :profile] do
42
42
  end
43
43
 
44
44
  context 'names of associated roles' do
45
- it {expect(finder_profile_repo.all.first.roles.first.name).to eql 'role_name_001'}
46
- it {expect(finder_profile_repo.all.first.roles.second.name).to eql 'role_name_002'}
45
+ it { expect(finder_profile_repo.all.first.roles.first.name).to eql 'role_name_001' }
46
+ it { expect(finder_profile_repo.all.first.roles.second.name).to eql 'role_name_002' }
47
47
  end
48
-
49
48
  end
50
-
51
49
  end
@@ -1,36 +1,31 @@
1
1
  require 'spec_helper'
2
2
 
3
- RSpec.describe "Remove Profile", type: [:request, :profile] do
3
+ RSpec.describe 'Remove Profile', type: %i[request profile] do
4
4
  let(:finder_profile_repo) { Arpa::Repositories::Profiles::Finder.new }
5
5
  let(:remover_profile_service) { Arpa::Services::Profiles::ProfileManagerRemover.new }
6
6
  let(:success_proc) { ->(r) {} }
7
- let(:callback) { {success: success_proc, fail: ->(e) {raise e} } }
7
+ let(:callback) { { success: success_proc, fail: ->(e) { raise e } } }
8
8
 
9
9
  describe 'removing a Profile' do
10
-
11
10
  before do
12
11
  create :repository_profile
13
12
  remover_profile_service.remove(profile_params_to_remove, callback)
14
13
  end
15
14
 
16
15
  context 'when need destroy a Profile' do
17
- let(:profile_params_to_remove) { {profile: finder_profile_repo.all.first } }
16
+ let(:profile_params_to_remove) { { profile: finder_profile_repo.all.first } }
18
17
 
19
18
  it 'record should be removed ' do
20
19
  expect(finder_profile_repo.all.size).to be == 0
21
20
  end
22
-
23
21
  end
24
22
 
25
23
  context 'when need disable a Profile' do
26
- let(:profile_params_to_remove) { {profile: finder_profile_repo.all.first, disable: true } }
24
+ let(:profile_params_to_remove) { { profile: finder_profile_repo.all.first, disable: true } }
27
25
 
28
26
  it 'record should be removed ' do
29
27
  expect(finder_profile_repo.all.size).to be == 0
30
28
  end
31
-
32
29
  end
33
-
34
30
  end
35
-
36
31
  end
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- RSpec.describe "Create Resource", type: [:request, :resource] do
3
+ RSpec.describe 'Create Resource', type: %i[request resource] do
4
4
  let(:finder_repo) { Arpa::Repositories::Resources::Finder.new }
5
5
  let(:creator_service) { Arpa::Services::Resources::ResourceManagerCreator.new }
6
6
  let(:success_proc) { ->(r) {} }
7
- let(:callback) { {success: success_proc, fail: ->(e) {raise e} } }
7
+ let(:callback) { { success: success_proc, fail: ->(e) { raise e } } }
8
8
 
9
9
  context 'when have no created resources or actions' do
10
10
  let(:resourceable_001) { double to_s: 'UsersController', action_methods: [:index, :show, 'edit'] }
@@ -12,7 +12,7 @@ RSpec.describe "Create Resource", type: [:request, :resource] do
12
12
  let(:resourceables) { [resourceable_001, resourceable_002] }
13
13
 
14
14
  before do
15
- creator_service.create({resourceables: resourceables}, callback)
15
+ creator_service.create({ resourceables: resourceables }, callback)
16
16
  end
17
17
 
18
18
  it 'should be recorded two resources' do
@@ -20,8 +20,8 @@ RSpec.describe "Create Resource", type: [:request, :resource] do
20
20
  end
21
21
 
22
22
  context 'names of resources' do
23
- it {expect(finder_repo.all.first.name).to eql('contacts') }
24
- it {expect(finder_repo.all.second.name).to eql('users') }
23
+ it { expect(finder_repo.all.first.name).to eql('contacts') }
24
+ it { expect(finder_repo.all.second.name).to eql('users') }
25
25
  end
26
26
 
27
27
  context 'Contacts resource' do
@@ -32,8 +32,8 @@ RSpec.describe "Create Resource", type: [:request, :resource] do
32
32
  end
33
33
 
34
34
  context 'names of actions' do
35
- it {expect(contacts_resource.actions.first.name).to eql('edit') }
36
- it {expect(contacts_resource.actions.second.name).to eql('index') }
35
+ it { expect(contacts_resource.actions.first.name).to eql('edit') }
36
+ it { expect(contacts_resource.actions.second.name).to eql('index') }
37
37
  end
38
38
  end
39
39
 
@@ -45,11 +45,10 @@ RSpec.describe "Create Resource", type: [:request, :resource] do
45
45
  end
46
46
 
47
47
  context 'names of actions' do
48
- it {expect(users_resource.actions.first.name).to eql('edit') }
49
- it {expect(users_resource.actions.second.name).to eql('index') }
50
- it {expect(users_resource.actions.third.name).to eql('show') }
48
+ it { expect(users_resource.actions.first.name).to eql('edit') }
49
+ it { expect(users_resource.actions.second.name).to eql('index') }
50
+ it { expect(users_resource.actions.third.name).to eql('show') }
51
51
  end
52
-
53
52
  end
54
53
  end
55
54
 
@@ -63,8 +62,8 @@ RSpec.describe "Create Resource", type: [:request, :resource] do
63
62
  let(:new_resourceables) { [resourceable_003, resourceable_004] }
64
63
 
65
64
  before do
66
- creator_service.create({resourceables: created_resourceables}, callback)
67
- creator_service.create({resourceables: new_resourceables}, callback)
65
+ creator_service.create({ resourceables: created_resourceables }, callback)
66
+ creator_service.create({ resourceables: new_resourceables }, callback)
68
67
  end
69
68
 
70
69
  it 'should be recorded two resources' do
@@ -72,8 +71,8 @@ RSpec.describe "Create Resource", type: [:request, :resource] do
72
71
  end
73
72
 
74
73
  context 'names of resources' do
75
- it {expect(finder_repo.all.first.name).to eql('arpa/new_users') }
76
- it {expect(finder_repo.all.second.name).to eql('contacts') }
74
+ it { expect(finder_repo.all.first.name).to eql('arpa/new_users') }
75
+ it { expect(finder_repo.all.second.name).to eql('contacts') }
77
76
  end
78
77
 
79
78
  context 'Contacts resource' do
@@ -84,8 +83,8 @@ RSpec.describe "Create Resource", type: [:request, :resource] do
84
83
  end
85
84
 
86
85
  context 'names of actions' do
87
- it {expect(contacts_resource.actions.first.name).to eql('index') }
88
- it {expect(contacts_resource.actions.second.name).to eql('new_edit') }
86
+ it { expect(contacts_resource.actions.first.name).to eql('index') }
87
+ it { expect(contacts_resource.actions.second.name).to eql('new_edit') }
89
88
  end
90
89
  end
91
90
 
@@ -97,11 +96,9 @@ RSpec.describe "Create Resource", type: [:request, :resource] do
97
96
  end
98
97
 
99
98
  context 'names of actions' do
100
- it {expect(users_resource.actions.first.name).to eql('edit') }
101
- it {expect(users_resource.actions.second.name).to eql('show') }
99
+ it { expect(users_resource.actions.first.name).to eql('edit') }
100
+ it { expect(users_resource.actions.second.name).to eql('show') }
102
101
  end
103
-
104
102
  end
105
103
  end
106
-
107
104
  end