separate isolated and integrated gears specs

pull/14388/head
Gonzalo Riestra 6 years ago
parent 152c75076d
commit 41b4731937

@ -339,6 +339,7 @@ SPEC_HELPER_MIN_SPECS = \
spec/requests/password_resets_controller_spec.rb \
spec/models/carto/feature_flag_spec.rb \
spec/mailers/user_mailer_spec.rb \
spec/gears/cargo_gears_api/users_service_spec.rb \
$(NULL)
# This class must be tested isolated as pollutes namespace
@ -378,14 +379,17 @@ check-carto-db-class:
CHECK_SPEC=51 RAILS_ENV=test bundle exec rspec $(WORKING_SPECS_carto_db_class)
check-integrations:
CHECK_SPEC=52 RAILS_ENV=test bundle exec rspec $(WORKING_SPECS_INTEGRATIONS)
check-gears:
CHECK_SPEC=60 RAILS_ENV=test bundle exec rspec ./gears/carto_gears_api/spec
check-gear/%: %
cd $< && bundle install && RAILS_ENV=test bundle exec rspec
check-gears: $(addprefix check-gear/, $(wildcard gears/*))
check-external: prepare-test-db check-integrations
check-prepared: check-1 check-2 check-4 check-5 check-7 check-9 check-spec-helper-min check-carto-db-class check-gears
check-prepared: check-1 check-2 check-4 check-5 check-7 check-9 check-spec-helper-min check-carto-db-class
check: prepare-test-db check-prepared
check: prepare-test-db check-prepared check-gears
check-frontend:
./node_modules/.bin/grunt test

@ -31,72 +31,4 @@ describe CartoGearsApi::Users::UsersService do
end
end
context "password management" do
before(:all) do
@user = FactoryGirl.create(:user, password: 'my_pass', password_confirmation: 'my_pass')
end
after(:all) do
@user.destroy
end
describe '#valid_password' do
it 'returns true if the password is correct' do
service.valid_password?(@user.id, 'my_pass').should be_true
end
it 'returns false if the password is incorrect' do
service.valid_password?(@user.id, 'wrong').should be_false
end
end
describe '#change_password' do
context 'right parameters' do
before(:each) do
@user = FactoryGirl.create(:user, password: 'my_pass', password_confirmation: 'my_pass')
end
after(:each) do
@user.destroy
end
it 'updates crypted_password' do
expect {
service.change_password(@user.id, 'new_password')
}.to (change { @user.reload.crypted_password })
end
it 'updates last_password_change_date' do
expect {
service.change_password(@user.id, 'new_password')
}.to (change { @user.reload.last_password_change_date })
end
end
it 'raises a validation error if the new password is blank' do
expect {
service.change_password(@user.id, nil)
}.to raise_error(CartoGearsApi::Errors::ValidationFailed, /blank/)
end
it 'raises a validation error if the new password is too short' do
expect {
service.change_password(@user.id, 'a')
}.to raise_error(CartoGearsApi::Errors::ValidationFailed, /at least/)
end
it 'raises a validation error if the new password is too long' do
expect {
service.change_password(@user.id, 'a' * 70)
}.to raise_error(CartoGearsApi::Errors::ValidationFailed, /at most/)
end
it 'raises a validation error if the new password is the same as the old' do
expect {
service.change_password(@user.id, 'my_pass')
}.to raise_error(CartoGearsApi::Errors::ValidationFailed, /the same/)
end
end
end
end

@ -0,0 +1,75 @@
require 'spec_helper_min'
require 'carto_gears_api/users/users_service'
describe CartoGearsApi::Users::UsersService do
let(:service) { CartoGearsApi::Users::UsersService.new }
context "password management" do
before(:all) do
@user = FactoryGirl.create(:user, password: 'my_pass', password_confirmation: 'my_pass')
end
after(:all) do
@user.destroy
end
describe '#valid_password' do
it 'returns true if the password is correct' do
service.valid_password?(@user.id, 'my_pass').should be_true
end
it 'returns false if the password is incorrect' do
service.valid_password?(@user.id, 'wrong').should be_false
end
end
describe '#change_password' do
context 'right parameters' do
before(:each) do
@user = FactoryGirl.create(:user, password: 'my_pass', password_confirmation: 'my_pass')
end
after(:each) do
@user.destroy
end
it 'updates crypted_password' do
expect {
service.change_password(@user.id, 'new_password')
}.to (change { @user.reload.crypted_password })
end
it 'updates last_password_change_date' do
expect {
service.change_password(@user.id, 'new_password')
}.to (change { @user.reload.last_password_change_date })
end
end
it 'raises a validation error if the new password is blank' do
expect {
service.change_password(@user.id, nil)
}.to raise_error(CartoGearsApi::Errors::ValidationFailed, /blank/)
end
it 'raises a validation error if the new password is too short' do
expect {
service.change_password(@user.id, 'a')
}.to raise_error(CartoGearsApi::Errors::ValidationFailed, /at least/)
end
it 'raises a validation error if the new password is too long' do
expect {
service.change_password(@user.id, 'a' * 70)
}.to raise_error(CartoGearsApi::Errors::ValidationFailed, /at most/)
end
it 'raises a validation error if the new password is the same as the old' do
expect {
service.change_password(@user.id, 'my_pass')
}.to raise_error(CartoGearsApi::Errors::ValidationFailed, /the same/)
end
end
end
end
Loading…
Cancel
Save