Skip to content

Commit

Permalink
Rails 5 style
Browse files Browse the repository at this point in the history
  • Loading branch information
CloCkWeRX committed Jul 17, 2017
1 parent e5affe2 commit 9f69bcd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
14 changes: 8 additions & 6 deletions app/controllers/entities/contacts_controller.rb
Expand Up @@ -65,14 +65,16 @@ def create
@contact.add_comment_by_user(@comment_body, current_user)
@contacts = get_contacts if called_from_index_page?
else
if params[:account][:id].blank?
if request.referer =~ /\/accounts\/(\d+)\z/
@account = Account.find(Regexp.last_match[1]) # related account
if params[:account]
if params[:account][:id].blank?
if request.referer =~ /\/accounts\/(\d+)\z/
@account = Account.find(Regexp.last_match[1]) # related account
else
@account = Account.new(user: current_user)
end
else
@account = Account.new(user: current_user)
@account = Account.find(params[:account][:id])
end
else
@account = Account.find(params[:account][:id])
end
@opportunity = Opportunity.my.find(params[:opportunity]) unless params[:opportunity].blank?
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/entities_controller.rb
Expand Up @@ -87,7 +87,7 @@ def field_group
render('fields/group') && return
end
end
render text: ''
render plain: ''
end

protected
Expand Down
6 changes: 3 additions & 3 deletions spec/controllers/entities/contacts_controller_spec.rb
Expand Up @@ -47,7 +47,7 @@
it "should pick up saved page number from session" do
session[:contacts_current_page] = 42
@contacts = [FactoryGirl.create(:contact, user: current_user)]
xhr :get, :index
get :index, xhr: true

expect(assigns[:current_page]).to eq(42)
expect(assigns[:contacts]).to eq([])
Expand All @@ -58,7 +58,7 @@
session[:contacts_current_page] = 42
session[:contacts_current_query] = "bill"
@contacts = [FactoryGirl.create(:contact, user: current_user)]
xhr :get, :index
get :index, xhr: true

expect(assigns[:current_page]).to eq(1)
expect(assigns[:contacts]).to eq(@contacts)
Expand Down Expand Up @@ -177,7 +177,7 @@
@account = Account.new(user: current_user)
@accounts = [FactoryGirl.create(:account, user: current_user)]

xhr :get, :new
get :new, xhr: true
expect(assigns[:contact].attributes).to eq(@contact.attributes)
expect(assigns[:account].attributes).to eq(@account.attributes)
expect(assigns[:accounts]).to eq(@accounts)
Expand Down

0 comments on commit 9f69bcd

Please sign in to comment.