Skip to content

Commit

Permalink
[Sandeep] Changed the User flow when he is already part of cabpool an…
Browse files Browse the repository at this point in the history
…d tries to create a cabpool
  • Loading branch information
dsandeephegde committed Feb 3, 2016
1 parent 13db3cd commit 58ea38e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions app/controllers/cabpools_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ class CabpoolsController < ApplicationController
before_action :registered? , except: [:show, :approve_reject_handler]
before_action :has_cabpool, only: [:leave]
before_action :has_cabpool_or_request, only: [:your_cabpools]
before_action :has_cabpool_or_request, only: [:your_cabpools]
before_action :user_should_not_have_cabpool, only: :new

def user_should_not_have_cabpool
user = User.find_by_email(session[:Email])
if !user.nil?
if user.cabpool
flash[:danger] = "You are already part of a Cab pool. Please leave the cabpool to create a new cab pool."
redirect_to(root_path)
redirect_to your_cabpools_path
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/cabpools_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,6 @@
get :new

expect(flash[:danger]).to eq "You are already part of a Cab pool. Please leave the cabpool to create a new cab pool."
expect(response).to redirect_to root_path
expect(response).to redirect_to your_cabpools_path
end
end

0 comments on commit 58ea38e

Please sign in to comment.