diff options
author | HombreLaser <sebastian-440@live.com> | 2023-03-11 12:10:57 -0600 |
---|---|---|
committer | HombreLaser <sebastian-440@live.com> | 2023-03-11 12:10:57 -0600 |
commit | 3dae1ce143d006cc75940b746a8eb74982e6e861 (patch) | |
tree | 5bfa59dfd11bbfc9b8ef2a38da067e0c2ca0da42 /spec/requests | |
parent | 6b3cc5c3a33643c0e42396142a2d3204ada2bb82 (diff) |
Añade test de scoping
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/companies_controller/create_companies_controller_spec.rb | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/spec/requests/companies_controller/create_companies_controller_spec.rb b/spec/requests/companies_controller/create_companies_controller_spec.rb index 53677f2..219868b 100644 --- a/spec/requests/companies_controller/create_companies_controller_spec.rb +++ b/spec/requests/companies_controller/create_companies_controller_spec.rb @@ -3,12 +3,12 @@ require 'rails_helper' RSpec.describe 'POST /api/companies', type: :request do - let(:user) { create(:user_account, role: 'master') } let(:company) { build(:company) } let(:logo) { fixture_file_upload('tres castillos-2.png', 'image/png') } - let(:token) { jwt(user) } it_behaves_like 'a POST request' do + let(:user) { create(:user_account, role: 'master') } + let(:token) { jwt(user) } let(:headers) { { 'CONTENT_TYPE' => 'application/json', 'Authorization' => "Bearer #{token['token']}" } } let(:route) { '/api/companies' } let(:expected_error_messages) do @@ -17,8 +17,18 @@ RSpec.describe 'POST /api/companies', type: :request do let(:desired_error_status) { 422 } let(:expected_text) { [company.name, company.short_name, company.country, 'logo', 'http'] } let(:params) do - { name: company.name, short_name: company.short_name, country: company.country, logo: logo } + { name: company.name, short_name: company.short_name, country: company.country, logo: } end let(:wrong_params) { JSON.generate({ name: '', short_name: '', country: '' }) } end + + it_behaves_like 'a POST request that requires a master user' do + let(:user) { create(:user_account, role: 'regular') } + let(:token) { jwt(user) } + let(:headers) { { 'CONTENT_TYPE' => 'application/json', 'Authorization' => "Bearer #{token['token']}" } } + let(:route) { '/api/companies' } + let(:params) do + JSON.generate({ name: company.name, short_name: company.short_name, country: company.country }) + end + end end |