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
Fix and add a missing email spec
Oliver Güntherdd4ebb5bf7c7
diff --git a/spec/controllers/account_controller_spec.rb b/spec/controllers/account_controller_spec.rbindex fb4eeafa596..158603d6e34 100644--- a/spec/controllers/account_controller_spec.rb+++ b/spec/controllers/account_controller_spec.rb@@ -972,14 +972,15 @@ describe AccountController, type: :controller dolet(:failure) do{- user: user,- login: user.login,+ login: login,back_url: '/my/account',ttl: 1}end- let(:user) { FactoryBot.create :user, status: 2 }+ let(:auth_source) { FactoryBot.create :ldap_auth_source }+ let(:user) { FactoryBot.create :user, status: 2, auth_source: auth_source }+ let(:login) { user.login }before dosession[:auth_source_sso_failure] = failure@@ -1000,8 +1001,13 @@ describe AccountController, type: :controller docontext "with an invalid user" dolet!(:duplicate) { FactoryBot.create :user, mail: "[email protected]" }- let(:user) do- FactoryBot.build(:user, mail: duplicate.mail).tap(&:valid?)+ let(:login) { 'foo' }+ let(:attrs) do+ { mail: duplicate.mail, login: login, firstname: 'bla', lastname: 'bar' }+ end++ before do+ allow(AuthSource).to receive(:find_user).and_return attrsendit "should show the account creation form with an error" do@@ -1013,6 +1019,27 @@ describe AccountController, type: :controller doexpect(response.body).to have_text "This field is invalid: Email has already been taken."endend++ context "with a missing email" do+ let!(:duplicate) { FactoryBot.create :user, mail: "[email protected]" }+ let(:login) { 'foo' }+ let(:attrs) do+ { login: login, firstname: 'bla', lastname: 'bar' }+ end++ before do+ allow(AuthSource).to receive(:find_user).and_return attrs+ end++ it "should show the account creation form with an error" do+ get :auth_source_sso_failed++ expect(session[:auth_source_sso_failure]).not_to be_present++ expect(response.body).to have_text "Create a new account"+ expect(response.body).to have_text "This field is invalid: Email can't be blank."+ end+ endenddescribe 'POST #activate' dodiff --git a/spec/controllers/concerns/auth_source_sso_spec.rb b/spec/controllers/concerns/auth_source_sso_spec.rbindex 2da7a268d94..722ac2f3ff2 100644--- a/spec/controllers/concerns/auth_source_sso_spec.rb+++ b/spec/controllers/concerns/auth_source_sso_spec.rb@@ -56,18 +56,12 @@ describe MyController, type: :controller doendshared_examples "auth source sso failure" do- def attrs(user)- user.attributes.slice(:login, :mail, :auth_source_id)- end-it "redirects to AccountController#sso to show the error" doexpect(response).to redirect_to "/sso"failure = session[:auth_source_sso_failure]expect(failure).to be_present- expect(attrs(failure[:user])).to eq attrs(user)-expect(failure[:login]).to eq loginexpect(failure[:back_url]).to eq "http://test.host/my/account"expect(failure[:ttl]).to eq 1