Skip to content

Commit

Permalink
fixed some things
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenson.jean-pierre@sage.com committed Apr 20, 2014
1 parent 0089f8c commit bea3011
Show file tree
Hide file tree
Showing 23 changed files with 436 additions and 47 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,5 @@ brakeman.html
/config/settings/local.rb

config/database.yml

log/development.log
15 changes: 14 additions & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
module ApplicationHelper
end
def title(page_title)
content_for(:title) { page_title.to_s }
end

def yield_or_default(section, default = '')
content_for?(section) ? content_for(section) : default
end

def active_nav(actionName)
if params[:action] == actionName
'active'
end
end
end
2 changes: 2 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class User < ActiveRecord::Base
end
1 change: 1 addition & 0 deletions app/views/github/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>We are in the github index view</h1>
39 changes: 0 additions & 39 deletions app/views/layouts/_nav.html.erb

This file was deleted.

43 changes: 36 additions & 7 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,14 +1,43 @@
<!DOCTYPE html>
<html>
<html lang='<%= I18n.locale.to_s %>'>
<head>
<title>Recheck</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<meta charset='utf-8'>
<meta content='width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0' name='viewport'>
<title>
<%= yield_or_default :title, controller.action_name.titlecase %>
</title>
<%= csrf_meta_tags %>
<%= yield :head %>


<!-- HTML5 shim, for IE6-8 support of HTML elements -->
<!--[if lt IE 9]>
<script src="https://html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script>
<![endif]-->

<%= stylesheet_link_tag 'https://fonts.googleapis.com/css?family=Ubuntu:400,500,700', 'application', media: 'all' %>

<!-- Touch icons -->
<link href='<%= asset_path 'apple-touch-icon.png' %>' rel='apple-touch-icon'>
<link href='<%= asset_path 'apple-touch-icon-72x72.png' %>' rel='apple-touch-icon' sizes='72x72'>
<link href='<%= asset_path 'apple-touch-icon-114x114.png' %>' rel='apple-touch-icon' sizes='114x114'>
<link href='<%= asset_path 'apple-touch-icon-144x144.png' %>' rel='apple-touch-icon' sizes='144x144'>

<!-- Placed at the top of the document 'cause of turbolinks -->
<%= javascript_include_tag 'application' %>
</head>
<body>
<%= render 'layouts/nav'%>
<%= yield %>

<%= render 'shared/navbar' %>
<div class='container' id='main-container'>
<div class='content push'>
<%= yield %>
</div>
</div>
<div id='footer'>
<div class='container'>
<%= render 'shared/footer' %>
</div>
</div>
</body>
</html>

9 changes: 9 additions & 0 deletions app/views/services/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class="row">
<div class="offset1 span10">
<% @providers.each do |provider| %>
<div class="span2">
<h3><%= provider.capitalize %></h3>
</div>
<% end %>
</div>
</div>
18 changes: 18 additions & 0 deletions app/views/sessions/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<% content_for :title, 'Login' %>
<h1><p class="text-center">Please log in to continue</p></h1>
<div class="panel panel-default">
<div class="panel-body">
<div>
<% if logged_in? %>
<a href="<%= logout_path %>" class="btn"><%= t('auth.logout') %></a>
<% else %>
<div class="text-center">
<!--<a href="/auth/twitter" class="btn btn-primary"><i class="icon-twitter"></i> <span><%= t('auth.twitter_html') %></span></a>-->
<a href="/auth/github" class="btn btn-primary"><i class="icon-github-alt"></i> <span><%= t('auth.github_html') %></span></a>
<!--<% unless Rails.env.production? %><a href="/auth/developer" class="btn btn-primary"><i class="icon-github-alt"></i> <span><%= t('auth.developer_html') %></span></a><% end %>-->
</div>
<% end %>
</div>
</div>
</div>

4 changes: 4 additions & 0 deletions app/views/shared/_footer.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<hr/>
<footer/>


21 changes: 21 additions & 0 deletions app/views/shared/_navbar.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<div class='navbar navbar-default push'>
<div class='container'>
<div class='container'>
<div class="navbar-header pull-right">
<% if logged_in? %>
<div class="navbar-brand">Logged in as, <strong><%= current_user.name %></strong> |</div>
<div class=" pull-right">
<div><%= link_to 'Logout', logout_path, class: 'navbar-brand' %></div>
</div>
<% end %>
</div>
<div class="navbar-header">
<%= link_to Rails.application.class.parent_name.upcase, root_path, class: 'navbar-brand' %>
</div>
<ul class="nav navbar-nav">
<li class="<%= active_nav('index') %>"><%= link_to 'Home', root_path %></li>
<li class="<%= active_nav('report') %>"><%= link_to 'link', '#'%></li>
</ul>
</div>
</div>
</div>
5 changes: 5 additions & 0 deletions app/views/users/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<h1>New user</h1>

<%= render 'form' %>

<%= link_to 'Back', users_path %>
4 changes: 4 additions & 0 deletions config/initializers/omniauth.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Rails.application.config.middleware.use OmniAuth::Builder do
provider :developer unless Rails.env.production?
provider :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET'],scope: 'user'
end
10 changes: 10 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
Rails.application.routes.draw do

resources :users

root 'github#index'

#login logout authentication logic
match '/logout' => 'sessions#destroy', via: %i(get delete), as: :logout
match '/login' => 'sessions#new', via: %i(get), as: :login
match '/auth/:service/callback' => 'services#create', via: %i(get post)
match '/auth/failure' => 'services#failure', via: %i(get post)
resources :services, only: %i(index create destroy)



Expand Down
File renamed without changes.
164 changes: 164 additions & 0 deletions spec/controllers/users_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
require 'spec_helper'

# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to specify the controller code that
# was generated by Rails when you ran the scaffold generator.
#
# It assumes that the implementation code is generated by the rails scaffold
# generator. If you are using any extension libraries to generate different
# controller code, this generated spec may or may not pass.
#
# It only uses APIs available in rails and/or rspec-rails. There are a number
# of tools you can use to make these specs even more expressive, but we're
# sticking to rails and rspec-rails APIs to keep things simple and stable.
#
# Compared to earlier versions of this generator, there is very limited use of
# stubs and message expectations in this spec. Stubs are only used when there
# is no simpler way to get a handle on the object needed for the example.
# Message expectations are only used when there is no simpler way to specify
# that an instance is receiving a specific message.

describe UsersController do

# This should return the minimal set of attributes required to create a valid
# User. As you add validations to User, be sure to
# update the return value of this method accordingly.
def valid_attributes
{ "name" => "MyString" }
end

# This should return the minimal set of values that should be in the session
# in order to pass any filters (e.g. authentication) defined in
# UsersController. Be sure to keep this updated too.
def valid_session
{}
end

describe "GET index" do
it "assigns all users as @users" do
user = User.create! valid_attributes
get :index, {}, valid_session
assigns(:users).should eq([user])
end
end

describe "GET show" do
it "assigns the requested user as @user" do
user = User.create! valid_attributes
get :show, {:id => user.to_param}, valid_session
assigns(:user).should eq(user)
end
end

describe "GET new" do
it "assigns a new user as @user" do
get :new, {}, valid_session
assigns(:user).should be_a_new(User)
end
end

describe "GET edit" do
it "assigns the requested user as @user" do
user = User.create! valid_attributes
get :edit, {:id => user.to_param}, valid_session
assigns(:user).should eq(user)
end
end

describe "POST create" do
describe "with valid params" do
it "creates a new User" do
expect {
post :create, {:user => valid_attributes}, valid_session
}.to change(User, :count).by(1)
end

it "assigns a newly created user as @user" do
post :create, {:user => valid_attributes}, valid_session
assigns(:user).should be_a(User)
assigns(:user).should be_persisted
end

it "redirects to the created user" do
post :create, {:user => valid_attributes}, valid_session
response.should redirect_to(User.last)
end
end

describe "with invalid params" do
it "assigns a newly created but unsaved user as @user" do
# Trigger the behavior that occurs when invalid params are submitted
User.any_instance.stub(:save).and_return(false)
post :create, {:user => { "name" => "invalid value" }}, valid_session
assigns(:user).should be_a_new(User)
end

it "re-renders the 'new' template" do
# Trigger the behavior that occurs when invalid params are submitted
User.any_instance.stub(:save).and_return(false)
post :create, {:user => { "name" => "invalid value" }}, valid_session
response.should render_template("new")
end
end
end

describe "PUT update" do
describe "with valid params" do
it "updates the requested user" do
user = User.create! valid_attributes
# Assuming there are no other users in the database, this
# specifies that the User created on the previous line
# receives the :update_attributes message with whatever params are
# submitted in the request.
User.any_instance.should_receive(:update_attributes).with({ "name" => "MyString" })
put :update, {:id => user.to_param, :user => { "name" => "MyString" }}, valid_session
end

it "assigns the requested user as @user" do
user = User.create! valid_attributes
put :update, {:id => user.to_param, :user => valid_attributes}, valid_session
assigns(:user).should eq(user)
end

it "redirects to the user" do
user = User.create! valid_attributes
put :update, {:id => user.to_param, :user => valid_attributes}, valid_session
response.should redirect_to(user)
end
end

describe "with invalid params" do
it "assigns the user as @user" do
user = User.create! valid_attributes
# Trigger the behavior that occurs when invalid params are submitted
User.any_instance.stub(:save).and_return(false)
put :update, {:id => user.to_param, :user => { "name" => "invalid value" }}, valid_session
assigns(:user).should eq(user)
end

it "re-renders the 'edit' template" do
user = User.create! valid_attributes
# Trigger the behavior that occurs when invalid params are submitted
User.any_instance.stub(:save).and_return(false)
put :update, {:id => user.to_param, :user => { "name" => "invalid value" }}, valid_session
response.should render_template("edit")
end
end
end

describe "DELETE destroy" do
it "destroys the requested user" do
user = User.create! valid_attributes
expect {
delete :destroy, {:id => user.to_param}, valid_session
}.to change(User, :count).by(-1)
end

it "redirects to the users list" do
user = User.create! valid_attributes
delete :destroy, {:id => user.to_param}, valid_session
response.should redirect_to(users_url)
end
end

end
15 changes: 15 additions & 0 deletions spec/helpers/users_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'spec_helper'

# Specs in this file have access to a helper object that includes
# the UsersHelper. For example:
#
# describe UsersHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# helper.concat_strings("this","that").should == "this that"
# end
# end
# end
describe UsersHelper do
pending "add some examples to (or delete) #{__FILE__}"
end
5 changes: 5 additions & 0 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'spec_helper'

describe User do
pending "add some examples to (or delete) #{__FILE__}"
end
Loading

0 comments on commit bea3011

Please sign in to comment.