arpa 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +17 -0
- data/.ruby-version +1 -1
- data/.travis.yml +5 -0
- data/CHANGELOG.md +4 -0
- data/README.md +4 -4
- data/Rakefile +1 -2
- data/arpa.gemspec +17 -18
- data/lib/arpa.rb +65 -67
- data/lib/arpa/additions/resource.rb +0 -2
- data/lib/arpa/data_mappers/action_mapper.rb +1 -2
- data/lib/arpa/data_mappers/base.rb +15 -16
- data/lib/arpa/data_mappers/profile_mapper.rb +3 -4
- data/lib/arpa/data_mappers/resource_mapper.rb +1 -1
- data/lib/arpa/data_mappers/role_mapper.rb +2 -2
- data/lib/arpa/entities/action.rb +0 -2
- data/lib/arpa/entities/profile.rb +2 -3
- data/lib/arpa/entities/resource.rb +4 -6
- data/lib/arpa/entities/role.rb +2 -3
- data/lib/arpa/exceptions/record_invalid.rb +0 -1
- data/lib/arpa/repositories/actions/creator.rb +0 -1
- data/lib/arpa/repositories/actions/finder.rb +5 -6
- data/lib/arpa/repositories/actions/remover.rb +0 -1
- data/lib/arpa/repositories/actions/repository_action.rb +1 -2
- data/lib/arpa/repositories/base.rb +0 -2
- data/lib/arpa/repositories/profiles/creator.rb +0 -1
- data/lib/arpa/repositories/profiles/finder.rb +2 -3
- data/lib/arpa/repositories/profiles/remover.rb +0 -1
- data/lib/arpa/repositories/profiles/repository_profile.rb +1 -2
- data/lib/arpa/repositories/profiles/updater.rb +0 -1
- data/lib/arpa/repositories/registrator.rb +5 -10
- data/lib/arpa/repositories/resources/creator.rb +0 -1
- data/lib/arpa/repositories/resources/finder.rb +0 -1
- data/lib/arpa/repositories/resources/remover.rb +0 -1
- data/lib/arpa/repositories/resources/repository_resource.rb +1 -2
- data/lib/arpa/repositories/roles/creator.rb +0 -1
- data/lib/arpa/repositories/roles/finder.rb +0 -1
- data/lib/arpa/repositories/roles/remover.rb +0 -1
- data/lib/arpa/repositories/roles/repository_role.rb +1 -2
- data/lib/arpa/repositories/roles/updater.rb +0 -1
- data/lib/arpa/services/actions/create/action_creator.rb +1 -3
- data/lib/arpa/services/actions/remove/action_remover.rb +0 -2
- data/lib/arpa/services/base.rb +6 -10
- data/lib/arpa/services/profiles/create/profile_creator.rb +0 -2
- data/lib/arpa/services/profiles/profile_manager_creator.rb +0 -1
- data/lib/arpa/services/profiles/profile_manager_remover.rb +0 -1
- data/lib/arpa/services/profiles/profile_manager_updater.rb +0 -1
- data/lib/arpa/services/profiles/remove/profile_remover.rb +0 -2
- data/lib/arpa/services/profiles/update/profile_updater.rb +0 -2
- data/lib/arpa/services/resources/create/resource_creator.rb +0 -2
- data/lib/arpa/services/resources/remove/resource_remover.rb +1 -4
- data/lib/arpa/services/resources/resource_manager_creator.rb +1 -2
- data/lib/arpa/services/roles/create/role_creator.rb +0 -3
- data/lib/arpa/services/roles/remove/role_remover.rb +0 -2
- data/lib/arpa/services/roles/role_manager_creator.rb +0 -2
- data/lib/arpa/services/roles/role_manager_remover.rb +0 -1
- data/lib/arpa/services/roles/role_manager_updater.rb +0 -1
- data/lib/arpa/services/roles/update/role_updater.rb +0 -2
- data/lib/arpa/services/verifier.rb +0 -1
- data/lib/arpa/validators/action_validator.rb +0 -1
- data/lib/arpa/validators/profile_validator.rb +0 -1
- data/lib/arpa/validators/resource_validator.rb +0 -1
- data/lib/arpa/validators/role_validator.rb +0 -2
- data/lib/arpa/version.rb +1 -1
- data/lib/generators/arpa/controllers_generator.rb +21 -22
- data/lib/generators/arpa/install_generator.rb +5 -6
- data/lib/generators/arpa/templates/controllers/profiles_controller.rb +31 -37
- data/lib/generators/arpa/templates/controllers/resources_controller.rb +20 -11
- data/lib/generators/arpa/templates/controllers/roles_controller.rb +31 -37
- data/lib/generators/arpa/templates/migration.rb +1 -1
- data/spec/factories/repository_actions.rb +4 -5
- data/spec/factories/repository_profiles.rb +4 -5
- data/spec/factories/repository_resources.rb +1 -3
- data/spec/factories/repository_roles.rb +2 -3
- data/spec/factories/repository_test.rb +1 -1
- data/spec/lib/arpa/additions/resource_spec.rb +8 -6
- data/spec/lib/arpa/data_mappers/action_mapper_spec.rb +1 -3
- data/spec/lib/arpa/data_mappers/base_spec.rb +0 -2
- data/spec/lib/arpa/data_mappers/profile_mapper_spec.rb +1 -3
- data/spec/lib/arpa/data_mappers/resource_mapper_spec.rb +1 -3
- data/spec/lib/arpa/data_mappers/role_mapper_spec.rb +1 -3
- data/spec/lib/arpa/entities/action_spec.rb +3 -6
- data/spec/lib/arpa/entities/profile_spec.rb +1 -7
- data/spec/lib/arpa/entities/resource_spec.rb +1 -9
- data/spec/lib/arpa/entities/role_spec.rb +1 -7
- data/spec/lib/arpa/repositories/actions/finder_spec.rb +1 -8
- data/spec/lib/arpa/repositories/base_spec.rb +1 -9
- data/spec/lib/arpa/repositories/profiles/finder_spec.rb +0 -6
- data/spec/lib/arpa/repositories/profiles/remover_spec.rb +0 -4
- data/spec/lib/arpa/repositories/resources/finder_spec.rb +0 -8
- data/spec/lib/arpa/repositories/resources/remover_spec.rb +0 -4
- data/spec/lib/arpa/repositories/roles/finder_spec.rb +0 -4
- data/spec/lib/arpa/repositories/roles/remover_spec.rb +0 -4
- data/spec/lib/arpa/requests/profiles/create_request_spec.rb +10 -12
- data/spec/lib/arpa/requests/profiles/remove_request_spec.rb +4 -9
- data/spec/lib/arpa/requests/resources/create_request_spec.rb +18 -21
- data/spec/lib/arpa/requests/roles/create_request_spec.rb +7 -9
- data/spec/lib/arpa/requests/roles/remove_request_spec.rb +3 -6
- data/spec/lib/arpa/requests/roles/update_request_spec.rb +7 -9
- data/spec/lib/arpa/services/actions/create/action_creator_spec.rb +5 -14
- data/spec/lib/arpa/services/actions/remove/action_remover_spec.rb +3 -6
- data/spec/lib/arpa/services/base_spec.rb +8 -15
- data/spec/lib/arpa/services/profiles/create/profile_creator_spec.rb +0 -7
- data/spec/lib/arpa/services/profiles/profile_manager_creator_spec.rb +2 -4
- data/spec/lib/arpa/services/profiles/profile_manager_remover_spec.rb +3 -6
- data/spec/lib/arpa/services/profiles/profile_manager_updater_spec.rb +2 -4
- data/spec/lib/arpa/services/profiles/remove/profile_remover_spec.rb +0 -5
- data/spec/lib/arpa/services/profiles/update/profile_updater_spec.rb +0 -7
- data/spec/lib/arpa/services/resources/create/resource_creator_spec.rb +1 -7
- data/spec/lib/arpa/services/resources/remove/resource_remover_spec.rb +2 -6
- data/spec/lib/arpa/services/resources/resource_manager_creator_spec.rb +5 -7
- data/spec/lib/arpa/services/roles/create/role_creator_spec.rb +0 -7
- data/spec/lib/arpa/services/roles/remove/role_remover_spec.rb +1 -8
- data/spec/lib/arpa/services/roles/role_manager_creator_spec.rb +2 -4
- data/spec/lib/arpa/services/roles/role_manager_remover_spec.rb +2 -4
- data/spec/lib/arpa/services/roles/role_manager_updater_spec.rb +2 -4
- data/spec/lib/arpa/services/roles/update/role_updater_spec.rb +0 -7
- data/spec/lib/arpa/services/verifier_spec.rb +3 -6
- data/spec/lib/arpa/validators/action_validator_spec.rb +0 -1
- data/spec/lib/arpa/validators/profile_validator_spec.rb +1 -2
- data/spec/lib/arpa/validators/resource_validator_spec.rb +0 -1
- data/spec/lib/arpa/validators/role_validator_spec.rb +1 -2
- data/spec/spec_helper.rb +4 -6
- data/spec/support/schema.rb +9 -10
- metadata +40 -36
@@ -1,24 +1,24 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
RSpec.describe
|
3
|
+
RSpec.describe 'Create Role', type: %i[request role] do
|
4
4
|
let(:finder_role_repo) { Arpa::Repositories::Roles::Finder.new }
|
5
5
|
let(:finder_resource_repo) { Arpa::Repositories::Resources::Finder.new }
|
6
6
|
let(:creator_resource_service) { Arpa::Services::Resources::ResourceManagerCreator.new }
|
7
7
|
let(:creator_role_service) { Arpa::Services::Roles::RoleManagerCreator.new }
|
8
8
|
let(:success_proc) { ->(r) {} }
|
9
|
-
let(:callback) { {success: success_proc, fail: ->(e) {raise e} } }
|
9
|
+
let(:callback) { { success: success_proc, fail: ->(e) { raise e } } }
|
10
10
|
|
11
11
|
context 'when have no created resources or actions' do
|
12
12
|
let(:resourceable_001) { double to_s: 'UsersController', action_methods: [:index, :show, 'edit'] }
|
13
13
|
let(:resourceable_002) { double to_s: 'ContactsController', action_methods: [:index, 'edit'] }
|
14
14
|
let(:resourceables) { [resourceable_001, resourceable_002] }
|
15
|
-
let(:created_resources) { creator_resource_service.create({resourceables: resourceables}, callback) }
|
15
|
+
let(:created_resources) { creator_resource_service.create({ resourceables: resourceables }, callback) }
|
16
16
|
|
17
|
-
let(:action_ids) { finder_resource_repo.all.first.actions.collect
|
17
|
+
let(:action_ids) { finder_resource_repo.all.first.actions.collect(&:id) }
|
18
18
|
|
19
19
|
before do
|
20
20
|
created_resources
|
21
|
-
role_params = {role: {name: 'role_name', description: 'role_description', action_ids: action_ids}}
|
21
|
+
role_params = { role: { name: 'role_name', description: 'role_description', action_ids: action_ids } }
|
22
22
|
creator_role_service.create(role_params, callback)
|
23
23
|
end
|
24
24
|
|
@@ -31,10 +31,8 @@ RSpec.describe "Create Role", type: [:request, :role] do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
context 'names of associated actions' do
|
34
|
-
it {expect(finder_role_repo.all.first.actions.first.name).to eql 'edit'}
|
35
|
-
it {expect(finder_role_repo.all.first.actions.second.name).to eql 'index'}
|
34
|
+
it { expect(finder_role_repo.all.first.actions.first.name).to eql 'edit' }
|
35
|
+
it { expect(finder_role_repo.all.first.actions.second.name).to eql 'index' }
|
36
36
|
end
|
37
|
-
|
38
37
|
end
|
39
|
-
|
40
38
|
end
|
@@ -1,23 +1,20 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
RSpec.describe
|
3
|
+
RSpec.describe 'Remove Role', type: %i[request role] do
|
4
4
|
let(:finder_role_repo) { Arpa::Repositories::Roles::Finder.new }
|
5
5
|
let(:remover_role_service) { Arpa::Services::Roles::RoleManagerRemover.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 Role' do
|
10
|
-
|
11
10
|
before do
|
12
11
|
create :repository_role
|
13
|
-
role_params_to_remove = {role: finder_role_repo.all.first }
|
12
|
+
role_params_to_remove = { role: finder_role_repo.all.first }
|
14
13
|
remover_role_service.remove(role_params_to_remove, callback)
|
15
14
|
end
|
16
15
|
|
17
16
|
it 'record should be removed ' do
|
18
17
|
expect(finder_role_repo.all.size).to be == 0
|
19
18
|
end
|
20
|
-
|
21
19
|
end
|
22
|
-
|
23
20
|
end
|
@@ -1,31 +1,31 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
RSpec.describe
|
3
|
+
RSpec.describe 'Update Role', type: %i[request role] do
|
4
4
|
let(:finder_role_repo) { Arpa::Repositories::Roles::Finder.new }
|
5
5
|
let(:finder_resource_repo) { Arpa::Repositories::Resources::Finder.new }
|
6
6
|
let(:creator_resource_service) { Arpa::Services::Resources::ResourceManagerCreator.new }
|
7
7
|
let(:creator_role_service) { Arpa::Services::Roles::RoleManagerCreator.new }
|
8
8
|
let(:updater_role_service) { Arpa::Services::Roles::RoleManagerUpdater.new }
|
9
9
|
let(:success_proc) { ->(r) {} }
|
10
|
-
let(:callback) { {success: success_proc, fail: ->(e) {raise e} } }
|
10
|
+
let(:callback) { { success: success_proc, fail: ->(e) { raise e } } }
|
11
11
|
|
12
12
|
context 'updating a Role' do
|
13
13
|
let(:resourceable_001) { double to_s: 'UsersController', action_methods: [:index, :show, 'edit'] }
|
14
14
|
let(:resourceable_002) { double to_s: 'ContactsController', action_methods: [:index, 'edit'] }
|
15
15
|
let(:resourceables) { [resourceable_001, resourceable_002] }
|
16
|
-
let(:created_resources) { creator_resource_service.create({resourceables: resourceables}, callback) }
|
17
|
-
let(:action_ids) { finder_resource_repo.all.first.actions.collect
|
16
|
+
let(:created_resources) { creator_resource_service.create({ resourceables: resourceables }, callback) }
|
17
|
+
let(:action_ids) { finder_resource_repo.all.first.actions.collect(&:id) }
|
18
18
|
|
19
19
|
let(:create_resources_and_role) do
|
20
20
|
created_resources
|
21
|
-
role_params = {role: {name: 'role_name', description: 'role_description', action_ids: action_ids}}
|
21
|
+
role_params = { role: { name: 'role_name', description: 'role_description', action_ids: action_ids } }
|
22
22
|
creator_role_service.create(role_params, callback)
|
23
23
|
end
|
24
24
|
|
25
25
|
before do
|
26
26
|
create_resources_and_role
|
27
27
|
found_role = finder_role_repo.all.first
|
28
|
-
role_params_to_update = {role: {id: found_role.id, name: 'updated_role_name', description: 'role_description', action_ids: [action_ids[0]] }}
|
28
|
+
role_params_to_update = { role: { id: found_role.id, name: 'updated_role_name', description: 'role_description', action_ids: [action_ids[0]] } }
|
29
29
|
updater_role_service.update(role_params_to_update, callback)
|
30
30
|
end
|
31
31
|
|
@@ -42,9 +42,7 @@ RSpec.describe "Update Role", type: [:request, :role] do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
context 'names of associated actions' do
|
45
|
-
it {expect(finder_role_repo.all.first.actions.first.name).to eql 'edit'}
|
45
|
+
it { expect(finder_role_repo.all.first.actions.first.name).to eql 'edit' }
|
46
46
|
end
|
47
|
-
|
48
47
|
end
|
49
|
-
|
50
48
|
end
|
@@ -1,19 +1,18 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Arpa::Services::Actions::Create::ActionCreator, type: :service, fast: true do
|
4
|
-
|
5
4
|
let(:action_entity_class) { Arpa::Entities::Action }
|
6
5
|
let(:action) { double }
|
7
6
|
let(:resource) { double id: 1 }
|
8
|
-
let(:actions_names) { [
|
9
|
-
let(:params) { {resource: resource, actions_names: actions_names} }
|
7
|
+
let(:actions_names) { %w[index new] }
|
8
|
+
let(:params) { { resource: resource, actions_names: actions_names } }
|
10
9
|
let(:action_found) { nil }
|
11
10
|
|
12
11
|
let(:actions_created) { subject.create_many(params) }
|
13
12
|
let(:validator_class) { Arpa::Validators::ActionValidator }
|
14
13
|
let(:validator) { instance_double validator_class }
|
15
14
|
|
16
|
-
let(:finder_repo_class) { Arpa::Repositories::Actions::Finder}
|
15
|
+
let(:finder_repo_class) { Arpa::Repositories::Actions::Finder }
|
17
16
|
let(:finder_repo) { instance_double finder_repo_class }
|
18
17
|
|
19
18
|
before do
|
@@ -25,7 +24,6 @@ describe Arpa::Services::Actions::Create::ActionCreator, type: :service, fast: t
|
|
25
24
|
end
|
26
25
|
|
27
26
|
describe 'creating a new action' do
|
28
|
-
|
29
27
|
context 'when resource is invalid' do
|
30
28
|
let(:errors) { instance_double('ActiveModel::Errors') }
|
31
29
|
|
@@ -41,7 +39,6 @@ describe Arpa::Services::Actions::Create::ActionCreator, type: :service, fast: t
|
|
41
39
|
expect(error.errors).not_to be_nil
|
42
40
|
}
|
43
41
|
end
|
44
|
-
|
45
42
|
end
|
46
43
|
|
47
44
|
context 'when actino already exists' do
|
@@ -50,7 +47,6 @@ describe Arpa::Services::Actions::Create::ActionCreator, type: :service, fast: t
|
|
50
47
|
it 'should return the action found' do
|
51
48
|
expect(actions_created).to eq [action_found, action_found]
|
52
49
|
end
|
53
|
-
|
54
50
|
end
|
55
51
|
|
56
52
|
context 'when resource is valid' do
|
@@ -73,16 +69,11 @@ describe Arpa::Services::Actions::Create::ActionCreator, type: :service, fast: t
|
|
73
69
|
end
|
74
70
|
|
75
71
|
context 'when build an instance of action' do
|
76
|
-
|
77
72
|
it 'entity action should call new method' do
|
78
|
-
expect(action_entity_class).to have_received(:new).with(
|
79
|
-
expect(action_entity_class).to have_received(:new).with(
|
73
|
+
expect(action_entity_class).to have_received(:new).with(resource_id: resource.id, name: 'index').once
|
74
|
+
expect(action_entity_class).to have_received(:new).with(resource_id: resource.id, name: 'new').once
|
80
75
|
end
|
81
|
-
|
82
76
|
end
|
83
|
-
|
84
77
|
end
|
85
|
-
|
86
78
|
end
|
87
|
-
|
88
79
|
end
|
@@ -1,15 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Arpa::Services::Actions::Remove::ActionRemover, type: :service, fast: true do
|
4
|
-
|
5
4
|
let(:action_001) { double name: 'index' }
|
6
5
|
let(:action_002) { double name: 'old_index' }
|
7
|
-
let(:actions) { [action_001, action_002]}
|
6
|
+
let(:actions) { [action_001, action_002] }
|
8
7
|
let(:resource) { double actions: actions }
|
9
8
|
|
10
|
-
let(:actions_names) { [
|
9
|
+
let(:actions_names) { %w[index show] }
|
11
10
|
|
12
|
-
let(:params) { {resource: resource, actions_names: actions_names} }
|
11
|
+
let(:params) { { resource: resource, actions_names: actions_names } }
|
13
12
|
|
14
13
|
describe 'removing nonexistent actions' do
|
15
14
|
let(:remover_repo_class) { Arpa::Repositories::Actions::Remover }
|
@@ -30,7 +29,5 @@ describe Arpa::Services::Actions::Remove::ActionRemover, type: :service, fast: t
|
|
30
29
|
expect(remover_repo).to have_received(:destroy).once
|
31
30
|
expect(remover_repo).to have_received(:destroy).with(action_002).once
|
32
31
|
end
|
33
|
-
|
34
32
|
end
|
35
|
-
|
36
33
|
end
|
@@ -9,29 +9,27 @@ end
|
|
9
9
|
class ManagerImplementationTest
|
10
10
|
include Arpa::Services::Base
|
11
11
|
|
12
|
-
def create_raise
|
12
|
+
def create_raise(callback)
|
13
13
|
manager_action callback do
|
14
|
-
raise Exceptions::RecordInvalid
|
14
|
+
raise Exceptions::RecordInvalid, 'some error'
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
def create
|
18
|
+
def create(callback)
|
19
19
|
manager_action callback do
|
20
20
|
'success'
|
21
21
|
end
|
22
22
|
end
|
23
|
-
|
24
23
|
end
|
25
24
|
|
26
25
|
describe Arpa::Services::Base, type: :service, fast: true do
|
27
|
-
|
28
26
|
let(:manager_implementation) { ManagerImplementationTest.new }
|
29
|
-
let(:callback)
|
27
|
+
let(:callback) do
|
30
28
|
{
|
31
|
-
success: ->
|
32
|
-
fail: ->
|
29
|
+
success: ->(result) {},
|
30
|
+
fail: ->(exception) {}
|
33
31
|
}
|
34
|
-
|
32
|
+
end
|
35
33
|
|
36
34
|
describe 'calling .transaction' do
|
37
35
|
before do
|
@@ -47,7 +45,6 @@ describe Arpa::Services::Base, type: :service, fast: true do
|
|
47
45
|
it 'transaction_class should call .transaction' do
|
48
46
|
expect(transaction_class).to have_received(:transaction)
|
49
47
|
end
|
50
|
-
|
51
48
|
end
|
52
49
|
|
53
50
|
context 'when use a custom transaction_class' do
|
@@ -57,7 +54,6 @@ describe Arpa::Services::Base, type: :service, fast: true do
|
|
57
54
|
it 'transaction_class should call .transaction' do
|
58
55
|
expect(transaction_class).to have_received(:transaction)
|
59
56
|
end
|
60
|
-
|
61
57
|
end
|
62
58
|
end
|
63
59
|
|
@@ -83,12 +79,9 @@ describe Arpa::Services::Base, type: :service, fast: true do
|
|
83
79
|
manager_implementation.create_raise callback
|
84
80
|
end
|
85
81
|
|
86
|
-
|
87
82
|
it 'should call the callback[:fail] with Exceptions::RecordInvalid' do
|
88
|
-
expect(callback[:fail]).to have_received(:call).with(kind_of
|
83
|
+
expect(callback[:fail]).to have_received(:call).with(kind_of(StandardError))
|
89
84
|
end
|
90
|
-
|
91
85
|
end
|
92
86
|
end
|
93
|
-
|
94
87
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Arpa::Services::Profiles::Create::ProfileCreator, type: :service, fast: true do
|
4
|
-
|
5
4
|
let(:profile_entity_class) { Arpa::Entities::Profile }
|
6
5
|
let(:profile) { double }
|
7
6
|
let(:params) { double }
|
@@ -16,7 +15,6 @@ describe Arpa::Services::Profiles::Create::ProfileCreator, type: :service, fast:
|
|
16
15
|
end
|
17
16
|
|
18
17
|
describe 'creating a new profile' do
|
19
|
-
|
20
18
|
context 'when profile is invalid' do
|
21
19
|
let(:errors) { instance_double('ActiveModel::Errors') }
|
22
20
|
|
@@ -32,7 +30,6 @@ describe Arpa::Services::Profiles::Create::ProfileCreator, type: :service, fast:
|
|
32
30
|
expect(error.errors).not_to be_nil
|
33
31
|
}
|
34
32
|
end
|
35
|
-
|
36
33
|
end
|
37
34
|
|
38
35
|
context 'when profile is valid' do
|
@@ -55,14 +52,10 @@ describe Arpa::Services::Profiles::Create::ProfileCreator, type: :service, fast:
|
|
55
52
|
end
|
56
53
|
|
57
54
|
context 'when build the profile' do
|
58
|
-
|
59
55
|
it 'entity profile should call new method' do
|
60
56
|
expect(profile_entity_class).to have_received(:new).once
|
61
57
|
end
|
62
|
-
|
63
58
|
end
|
64
|
-
|
65
59
|
end
|
66
|
-
|
67
60
|
end
|
68
61
|
end
|
@@ -1,11 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Arpa::Services::Profiles::ProfileManagerCreator, type: :service, fast: true do
|
4
|
-
|
5
4
|
let(:profile_creator) { double }
|
6
|
-
let(:params) { {profile: {name: 'profile_name', description: 'profile_description', role_ids: [1, 2]}} }
|
5
|
+
let(:params) { { profile: { name: 'profile_name', description: 'profile_description', role_ids: [1, 2] } } }
|
7
6
|
let(:success_proc) { ->(r) {} }
|
8
|
-
let(:callback) { {success: success_proc, fail: ->(e) {raise e} } }
|
7
|
+
let(:callback) { { success: success_proc, fail: ->(e) { raise e } } }
|
9
8
|
|
10
9
|
let(:setup_creators) do
|
11
10
|
allow(Arpa::Services::Profiles::Create::ProfileCreator).to receive(:new).and_return(profile_creator)
|
@@ -27,5 +26,4 @@ describe Arpa::Services::Profiles::ProfileManagerCreator, type: :service, fast:
|
|
27
26
|
it 'profile_creator should call :create with parameters' do
|
28
27
|
expect(profile_creator).to have_received(:create).with(params[:profile]).once
|
29
28
|
end
|
30
|
-
|
31
29
|
end
|
@@ -1,11 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Arpa::Services::Profiles::ProfileManagerRemover, type: :service, fast: true do
|
4
|
-
|
5
4
|
let(:profile_remover) { double }
|
6
5
|
let(:profile) { double }
|
7
6
|
let(:success_proc) { ->(r) {} }
|
8
|
-
let(:callback) { {success: success_proc, fail: ->(e) {raise e} } }
|
7
|
+
let(:callback) { { success: success_proc, fail: ->(e) { raise e } } }
|
9
8
|
|
10
9
|
let(:setup_updaters) do
|
11
10
|
allow(Arpa::Services::Profiles::Remove::ProfileRemover).to receive(:new).and_return(profile_remover)
|
@@ -25,7 +24,7 @@ describe Arpa::Services::Profiles::ProfileManagerRemover, type: :service, fast:
|
|
25
24
|
end
|
26
25
|
|
27
26
|
context 'when is to destroy' do
|
28
|
-
let(:params) { {profile: profile} }
|
27
|
+
let(:params) { { profile: profile } }
|
29
28
|
|
30
29
|
it 'profile_remover should call :remove with profile as parameter' do
|
31
30
|
expect(profile_remover).to have_received(:remove).with(profile, nil).once
|
@@ -33,12 +32,10 @@ describe Arpa::Services::Profiles::ProfileManagerRemover, type: :service, fast:
|
|
33
32
|
end
|
34
33
|
|
35
34
|
context 'when is to disable' do
|
36
|
-
let(:params) { {profile: profile, disable: true} }
|
35
|
+
let(:params) { { profile: profile, disable: true } }
|
37
36
|
|
38
37
|
it 'profile_remover should call :remove with profile and disable: true as parameter' do
|
39
38
|
expect(profile_remover).to have_received(:remove).with(profile, true).once
|
40
39
|
end
|
41
|
-
|
42
40
|
end
|
43
|
-
|
44
41
|
end
|
@@ -1,11 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Arpa::Services::Profiles::ProfileManagerUpdater, type: :service, fast: true do
|
4
|
-
|
5
4
|
let(:profile_updater) { double }
|
6
|
-
let(:params) { {profile: {name: 'profile_name', description: 'profile_description', role_ids: [1, 2]}} }
|
5
|
+
let(:params) { { profile: { name: 'profile_name', description: 'profile_description', role_ids: [1, 2] } } }
|
7
6
|
let(:success_proc) { ->(r) {} }
|
8
|
-
let(:callback) { {success: success_proc, fail: ->(e) {raise e} } }
|
7
|
+
let(:callback) { { success: success_proc, fail: ->(e) { raise e } } }
|
9
8
|
|
10
9
|
let(:setup_updaters) do
|
11
10
|
allow(Arpa::Services::Profiles::Update::ProfileUpdater).to receive(:new).and_return(profile_updater)
|
@@ -27,5 +26,4 @@ describe Arpa::Services::Profiles::ProfileManagerUpdater, type: :service, fast:
|
|
27
26
|
it 'profile_updater should call :update with parameters' do
|
28
27
|
expect(profile_updater).to have_received(:update).with(params[:profile]).once
|
29
28
|
end
|
30
|
-
|
31
29
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Arpa::Services::Profiles::Remove::ProfileRemover, type: :service, fast: true do
|
4
|
-
|
5
4
|
let(:profile) { double }
|
6
5
|
|
7
6
|
describe 'removing profile' do
|
@@ -26,7 +25,6 @@ describe Arpa::Services::Profiles::Remove::ProfileRemover, type: :service, fast:
|
|
26
25
|
it 'remover repository should call :new once' do
|
27
26
|
expect(remover_repo_class).to have_received(:new).once
|
28
27
|
end
|
29
|
-
|
30
28
|
end
|
31
29
|
|
32
30
|
context 'when pass true as disable param' do
|
@@ -37,9 +35,6 @@ describe Arpa::Services::Profiles::Remove::ProfileRemover, type: :service, fast:
|
|
37
35
|
it 'remover repository should call :disable once' do
|
38
36
|
expect(remover_repo).to have_received(:disable).once
|
39
37
|
end
|
40
|
-
|
41
38
|
end
|
42
|
-
|
43
39
|
end
|
44
|
-
|
45
40
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Arpa::Services::Profiles::Update::ProfileUpdater, type: :service, fast: true do
|
4
|
-
|
5
4
|
let(:role_entity_class) { Arpa::Entities::Profile }
|
6
5
|
let(:profile) { double }
|
7
6
|
let(:params) { double }
|
@@ -16,7 +15,6 @@ describe Arpa::Services::Profiles::Update::ProfileUpdater, type: :service, fast:
|
|
16
15
|
end
|
17
16
|
|
18
17
|
describe 'updating a profile' do
|
19
|
-
|
20
18
|
context 'when profile is invalid' do
|
21
19
|
let(:errors) { instance_double('ActiveModel::Errors') }
|
22
20
|
|
@@ -32,7 +30,6 @@ describe Arpa::Services::Profiles::Update::ProfileUpdater, type: :service, fast:
|
|
32
30
|
expect(error.errors).not_to be_nil
|
33
31
|
}
|
34
32
|
end
|
35
|
-
|
36
33
|
end
|
37
34
|
|
38
35
|
context 'when profile is valid' do
|
@@ -55,14 +52,10 @@ describe Arpa::Services::Profiles::Update::ProfileUpdater, type: :service, fast:
|
|
55
52
|
end
|
56
53
|
|
57
54
|
context 'when build the profile' do
|
58
|
-
|
59
55
|
it 'entity profile should call new method' do
|
60
56
|
expect(role_entity_class).to have_received(:new).once
|
61
57
|
end
|
62
|
-
|
63
58
|
end
|
64
|
-
|
65
59
|
end
|
66
|
-
|
67
60
|
end
|
68
61
|
end
|