Skip to content

Commit

Permalink
[Varsha/Thejas] Added cabpool controller and spec for it
Browse files Browse the repository at this point in the history
  • Loading branch information
thejasbabu committed Dec 1, 2015
1 parent 6590491 commit 1a175b4
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 27 deletions.
4 changes: 0 additions & 4 deletions app/controllers/cabpool_controller.rb

This file was deleted.

10 changes: 10 additions & 0 deletions app/controllers/cabpools_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CabpoolsController < ApplicationController
attr_reader :locality

def new
@cabpool = Cabpool.new
user = User.find_by_email(session[:userid])
@locality = Locality.find(user.locality_id).name
debugger
end
end
2 changes: 0 additions & 2 deletions app/helpers/cabpool_helper.rb

This file was deleted.

2 changes: 2 additions & 0 deletions app/helpers/cabpools_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module CabpoolsHelper
end
Empty file removed app/views/cabpool/new.html.erb
Empty file.
28 changes: 28 additions & 0 deletions app/views/cabpools/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<% provide(:title, 'Create a new cabpools') %>
<% if FEATURES.active?('user_feature') %>
<h1>Create a new cabpool to find your soulmate <3</h1>
<div class="row">
<div class="col-md-4 col-md-offset-4">
<%= form_for(@cabpool) do |c| %>

<%= c.label :number_of_people, "Number of people to travel with" %>
<%= c.text_field :number_of_people, class: 'form-control' %>

<%= c.label :timein, "Pick-up time to office" %>
<%= c.text_field :timein, class: 'form-control' %>

<%= c.label :timeout, "Pick-up time from office" %>
<%= c.text_field :timeout, class: 'form-control' %>

<%= c.label :route, "Via" %>
<%= c.text_field :route, class: 'form-control' %>

<%= c.label :locality, "Locality" %>
<%= @locality %>

<%= c.submit "Create a pool", class: "btn btn-primary form-control", style: 'align: center' %>
<% end %>
</div>
</div>
<% end %>

2 changes: 1 addition & 1 deletion app/views/layouts/_header.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<header class="navbar navbar-fixed-top navbar-inverse" id="header">
<div class="container">
<%= link_to "DANGLAY", root_path, id: "logo" %>
<%= link_to "! DANGLAY", root_path, id: "logo" %>
<nav>
<ul class="nav navbar-nav pull-right">
<li><%= link_to "Home", root_path %></li>
Expand Down
3 changes: 1 addition & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
get 'saml/init'
post 'saml/consume'
delete 'logout' => 'sessions#destroy'
get '/create_cabpool' => 'cabpool#new'
#If Feature toggle is to be used for a specific action
# if FEATURES.active?('user_feature')
# get 'users/new', to: 'users#new'
# end

resources :cabpools
resources :users
end
13 changes: 0 additions & 13 deletions spec/controllers/cabpool_controller_spec.rb

This file was deleted.

25 changes: 25 additions & 0 deletions spec/controllers/cabpools_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require 'rails_helper'

RSpec.describe CabpoolsController, type: :controller do

before(:each) do
session[:userid] = "thejasb@thoughtworks.com"
stub_user = User.new(:name => "Thejas", :email => "thejasb@thoughtworks.com", :locality_id => 1)
allow(User).to receive(:find_by_email).and_return(stub_user)
allow(stub_user).to receive(:locality_id).and_return(1)
stub_locality = Locality.new(:name =>"Blah")
allow(Locality).to receive(:find).and_return(stub_locality)
allow(stub_locality).to receive(:name).and_return("Blah")

end

it 'should render create cabpools page' do
get :new
expect(response).to render_template('new')
end

it 'should return the locality of user' do
get :new
expect(assigns(:locality)).to eq "Blah"
end
end
2 changes: 1 addition & 1 deletion spec/factories/cabpools.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FactoryGirl.define do
factory :cabpool do
factory :cabpools do
route "MyString"
number_of_people 1
timein "MyString"
Expand Down
4 changes: 0 additions & 4 deletions spec/helpers/cabpool_helper_spec.rb

This file was deleted.

4 changes: 4 additions & 0 deletions spec/helpers/cabpools_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require 'rails_helper'

RSpec.describe CabpoolsHelper, type: :helper do
end

0 comments on commit 1a175b4

Please sign in to comment.