OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
replace legacy specs
ulferts15f5c2159460
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rbindex 9e5dd2dd470..3452de600ba 100644--- a/spec/models/user_spec.rb+++ b/spec/models/user_spec.rb@@ -108,56 +108,78 @@ describe User, type: :model doendend- describe 'login whitespace' do- before do- user.login = login+ describe '#mail' do+ it 'is stripped' do+ user.mail = ' [email protected] '+ expect(user.mail)+ .to eql '[email protected]'end+ end- context 'simple spaces' do- let(:login) { 'a b c' }-- it 'is valid' do- expect(user).to be_valid+ describe '#login' do+ context 'with whitespace' do+ before do+ user.login = loginend- it 'may be stored in the database' do- expect(user.save).to be_truthy- end- end+ context 'simple spaces' do+ let(:login) { 'a b c' }- context 'line breaks' do- let(:login) { 'ab\nc' }+ it 'is valid' do+ expect(user).to be_valid+ end- it 'is invalid' do- expect(user).not_to be_valid+ it 'may be stored in the database' do+ expect(user.save).to be_truthy+ endend- it 'may not be stored in the database' do- expect(user.save).to be_falsey- end- end+ context 'line breaks' do+ let(:login) { 'ab\nc' }- context 'tabs' do- let(:login) { 'ab\tc' }+ it 'is invalid' do+ expect(user).not_to be_valid+ end- it 'is invalid' do- expect(user).not_to be_valid+ it 'may not be stored in the database' do+ expect(user.save).to be_falsey+ endend- it 'may not be stored in the database' do- expect(user.save).to be_falsey+ context 'tabs' do+ let(:login) { 'ab\tc' }++ it 'is invalid' do+ expect(user).not_to be_valid+ end++ it 'may not be stored in the database' do+ expect(user.save).to be_falsey+ endendend- end- describe 'login symbols' do- before do- user.login = login- end+ context 'with symbols' do+ before do+ user.login = login+ end++ %w[+ _ . - @].each do |symbol|+ context symbol do+ let(:login) { "foo#{symbol}bar" }++ it 'is valid' do+ expect(user).to be_valid+ end++ it 'may be stored in the database' do+ expect(user.save).to be_truthy+ end+ end+ end- %w[+ _ . - @].each do |symbol|- context symbol do- let(:login) { "foo#{symbol}bar" }+ context 'combination thereof' do+ let(:login) { 'the+boss-is@the_house.' }it 'is valid' doexpect(user).to be_valid@@ -167,29 +189,17 @@ describe User, type: :model doexpect(user.save).to be_truthyendend- end-- context 'combination thereof' do- let(:login) { 'the+boss-is@the_house.' }-- it 'is valid' do- expect(user).to be_valid- end-- it 'may be stored in the database' do- expect(user.save).to be_truthy- end- end- context 'with invalid symbol' do- let(:login) { 'invalid!name' }+ context 'with invalid symbol' do+ let(:login) { 'invalid!name' }- it 'is invalid' do- expect(user).not_to be_valid- end+ it 'is invalid' do+ expect(user).not_to be_valid+ end- it 'may not be stored in the database' do- expect(user.save).to be_falsey+ it 'may not be stored in the database' do+ expect(user.save).to be_falsey+ endendendenddiff --git a/spec_legacy/unit/user_spec.rb b/spec_legacy/unit/user_spec.rbindex f69af09b5ae..33ddc0f7418 100644--- a/spec_legacy/unit/user_spec.rb+++ b/spec_legacy/unit/user_spec.rb@@ -40,22 +40,6 @@ describe User, type: :model do@dlopper = User.find(3)end- specify 'object_daddy creation' do- FactoryBot.create(:user, firstname: 'Testing connection')- FactoryBot.create(:user, firstname: 'Testing connection')- assert_equal 2, User.where(firstname: 'Testing connection').count- end-- it 'should truth' do- assert_kind_of User, @jsmith- end-- it 'should mail should be stripped' do- u = User.new- u.mail = ' [email protected] '- assert_equal '[email protected]', u.mail- end-it 'should create' douser = User.new(firstname: 'new', lastname: 'user', mail: '[email protected]')@@ -121,20 +105,6 @@ describe User, type: :model doassert_includes u.errors[:mail], I18n.translate('activerecord.errors.messages.taken')end- it 'should update' do- assert_equal 'admin', @admin.login- @admin.login = 'john'- assert @admin.save, @admin.errors.full_messages.join('; ')- @admin.reload- assert_equal 'john', @admin.login- end-- it 'should destroy' do- User.find(2).destroy- assert_nil User.find_by(id: 2)- assert Member.where(user_id: 2).empty?- end-it 'should validate login presence' do@admin.login = ''assert [email protected]