Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' into design

Conflicts:
	app/views/pages/home.html.erb
  • Loading branch information...
commit dbcdf31b945ed932ca37d1ffb83a6d5de984a1a2 2 parents 838a399 + 50c47ce
David Lee authored
View
4 .gitignore
@@ -14,5 +14,5 @@
/log/*.log
/tmp
-# Ignore Stripe.rb file with sensitive api info
-stripe.rb
+.swp
+.orig
View
2  Gemfile
@@ -5,9 +5,11 @@ gem 'pg'
gem 'jquery-rails'
gem 'bcrypt-ruby', '~> 3.0.0'
gem 'stripe'
+gem 'haml-rails'
gem "twitter-bootstrap-rails"
group :development, :test do
+ gem 'quiet_assets'
gem 'shoulda-matchers'
gem 'rspec-rails'
gem 'guard-rspec'
View
10 Gemfile.lock
@@ -63,6 +63,12 @@ GEM
guard (>= 1.1)
spork (>= 0.8.4)
sys-proctable
+ haml (3.1.7)
+ haml-rails (0.3.5)
+ actionpack (>= 3.1, < 4.1)
+ activesupport (>= 3.1, < 4.1)
+ haml (~> 3.1)
+ railties (>= 3.1, < 4.1)
hike (1.2.1)
i18n (0.6.1)
journey (1.0.4)
@@ -85,6 +91,8 @@ GEM
multi_json (1.3.6)
pg (0.14.1)
polyglot (0.3.3)
+ quiet_assets (1.0.1)
+ railties (~> 3.1)
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
@@ -170,8 +178,10 @@ DEPENDENCIES
faker
guard-rspec
guard-spork
+ haml-rails
jquery-rails
pg
+ quiet_assets
rails (= 3.2.8)
rb-fsevent
rspec-rails
View
163 Gemfile.lock.orig
@@ -1,163 +0,0 @@
-GEM
- remote: https://rubygems.org/
- specs:
- actionmailer (3.2.8)
- actionpack (= 3.2.8)
- mail (~> 2.4.4)
- actionpack (3.2.8)
- activemodel (= 3.2.8)
- activesupport (= 3.2.8)
- builder (~> 3.0.0)
- erubis (~> 2.7.0)
- journey (~> 1.0.4)
- rack (~> 1.4.0)
- rack-cache (~> 1.2)
- rack-test (~> 0.6.1)
- sprockets (~> 2.1.3)
- activemodel (3.2.8)
- activesupport (= 3.2.8)
- builder (~> 3.0.0)
- activerecord (3.2.8)
- activemodel (= 3.2.8)
- activesupport (= 3.2.8)
- arel (~> 3.0.2)
- tzinfo (~> 0.3.29)
- activeresource (3.2.8)
- activemodel (= 3.2.8)
- activesupport (= 3.2.8)
- activesupport (3.2.8)
- i18n (~> 0.6)
- multi_json (~> 1.0)
- arel (3.0.2)
- bcrypt-ruby (3.0.1)
- builder (3.0.3)
- childprocess (0.3.5)
- ffi (~> 1.0, >= 1.0.6)
- coffee-rails (3.2.2)
- coffee-script (>= 2.2.0)
- railties (~> 3.2.0)
- coffee-script (2.2.0)
- coffee-script-source
- execjs
- coffee-script-source (1.3.3)
- diff-lcs (1.1.3)
- erubis (2.7.0)
- execjs (1.4.0)
- multi_json (~> 1.0)
- ffi (1.1.5)
- guard (1.3.3)
- listen (>= 0.4.2)
- thor (>= 0.14.6)
- guard-rspec (1.2.1)
- guard (>= 1.1)
- guard-spork (1.2.0)
- childprocess
- guard (>= 1.1)
- spork (>= 0.8.4)
- sys-proctable
- hike (1.2.1)
- i18n (0.6.1)
- journey (1.0.4)
- jquery-rails (2.1.2)
- railties (>= 3.1.0, < 5.0)
- thor (~> 0.14)
- json (1.7.5)
- listen (0.5.1)
- mail (2.4.4)
- i18n (>= 0.4.0)
- mime-types (~> 1.16)
- treetop (~> 1.4.8)
- mime-types (1.19)
- multi_json (1.3.6)
- pg (0.14.1)
- polyglot (0.3.3)
- rack (1.4.1)
- rack-cache (1.2)
- rack (>= 0.4)
- rack-ssl (1.3.2)
- rack
- rack-test (0.6.1)
- rack (>= 1.0)
- rails (3.2.8)
- actionmailer (= 3.2.8)
- actionpack (= 3.2.8)
- activerecord (= 3.2.8)
- activeresource (= 3.2.8)
- activesupport (= 3.2.8)
- bundler (~> 1.0)
- railties (= 3.2.8)
- railties (3.2.8)
- actionpack (= 3.2.8)
- activesupport (= 3.2.8)
- rack-ssl (~> 1.3.2)
- rake (>= 0.8.7)
- rdoc (~> 3.4)
- thor (>= 0.14.6, < 2.0)
- rake (0.9.2.2)
- rb-fsevent (0.9.1)
- rdoc (3.12)
- json (~> 1.4)
- rest-client (1.6.7)
- mime-types (>= 1.16)
- rspec (2.11.0)
- rspec-core (~> 2.11.0)
- rspec-expectations (~> 2.11.0)
- rspec-mocks (~> 2.11.0)
- rspec-core (2.11.1)
- rspec-expectations (2.11.3)
- diff-lcs (~> 1.1.3)
- rspec-mocks (2.11.3)
- rspec-rails (2.11.0)
- actionpack (>= 3.0)
- activesupport (>= 3.0)
- railties (>= 3.0)
- rspec (~> 2.11.0)
- sass (3.2.1)
- sass-rails (3.2.5)
- railties (~> 3.2.0)
- sass (>= 3.1.10)
- tilt (~> 1.3)
- shoulda-matchers (1.3.0)
- activesupport (>= 3.0.0)
- spork (0.9.2)
- sprockets (2.1.3)
- hike (~> 1.2)
- rack (~> 1.0)
- tilt (~> 1.1, != 1.3.0)
-<<<<<<< HEAD
- stripe (1.7.3)
- multi_json (~> 1.1)
- rest-client (~> 1.4)
-=======
- sys-proctable (0.9.1)
->>>>>>> 8c96c48353b50733af120b25bc71fe2063fd3d33
- thor (0.16.0)
- tilt (1.3.3)
- treetop (1.4.10)
- polyglot
- polyglot (>= 0.3.1)
- tzinfo (0.3.33)
- uglifier (1.3.0)
- execjs (>= 0.3.0)
- multi_json (~> 1.0, >= 1.0.2)
-
-PLATFORMS
- ruby
-
-DEPENDENCIES
- bcrypt-ruby (~> 3.0.0)
- coffee-rails (~> 3.2.1)
- guard-rspec
- guard-spork
- jquery-rails
- pg
- rails (= 3.2.8)
- rb-fsevent
- rspec-rails
- sass-rails (~> 3.2.3)
- shoulda-matchers
-<<<<<<< HEAD
- stripe
-=======
->>>>>>> 8c96c48353b50733af120b25bc71fe2063fd3d33
- uglifier (>= 1.0.3)
View
38 Gemfile.orig
@@ -1,38 +0,0 @@
-source 'https://rubygems.org'
-
-gem 'rails', '3.2.8'
-<<<<<<< HEAD
-gem 'stripe'
-gem 'pg'
-=======
-gem 'pg'
-gem 'jquery-rails'
-gem 'bcrypt-ruby', '~> 3.0.0'
->>>>>>> 8c96c48353b50733af120b25bc71fe2063fd3d33
-
-group :development, :test do
- gem 'shoulda-matchers'
- gem 'rspec-rails'
- gem 'guard-rspec'
-<<<<<<< HEAD
-=======
- gem 'guard-spork'
- gem 'rb-fsevent'
->>>>>>> 8c96c48353b50733af120b25bc71fe2063fd3d33
-end
-
-group :assets do
- gem 'sass-rails', '~> 3.2.3'
- gem 'coffee-rails', '~> 3.2.1'
- gem 'uglifier', '>= 1.0.3'
-<<<<<<< HEAD
-end
-
-gem 'jquery-rails'
-=======
-
- # See https://github.com/sstephenson/execjs#readme for more supported runtimes
- # gem 'therubyracer', :platforms => :ruby
-
-end
->>>>>>> 8c96c48353b50733af120b25bc71fe2063fd3d33
View
BIN  app/controllers/.organizations_controller.rb.swp
Binary file not shown
View
19 app/controllers/application_controller.rb
@@ -1,3 +1,22 @@
class ApplicationController < ActionController::Base
protect_from_forgery
+ helper_method :current_user
+
+ private
+ def current_user
+ @current_user ||= User.find(session[:user_id]) if session[:user_id]
+ end
+
+ def current_user=(user)
+ session.clear
+ session[:user_id] = user.id
+ end
+
+ def authenticate_user!
+ redirect_to login_path unless current_user
+ end
+
+ def check_current_user
+ redirect_to root_path if current_user
+ end
end
View
22 app/controllers/sessions_controller.rb
@@ -0,0 +1,22 @@
+class SessionsController < ApplicationController
+ before_filter :check_current_user, :only => [ :new, :create ]
+
+ def new
+ end
+
+ def create
+ if user = User.authenticate(params[:email], params[:password])
+ self.current_user = user
+ redirect_to root_path, :notice => "Logged in!"
+ else
+ flash.now[:error] = "Invalid email or password"
+ render "new"
+ end
+ end
+
+ def destroy
+ session.clear
+ redirect_to root_path, :notice => "Logged out!"
+ end
+
+end
View
18 app/controllers/users_controller.rb
@@ -0,0 +1,18 @@
+class UsersController < ApplicationController
+ before_filter :check_current_user
+
+ def new
+ @user = User.new
+ end
+
+ def create
+ @user = User.new(params[:user])
+ if @user.save
+ self.current_user = @user
+ redirect_to root_path, :notice => "Signed up!"
+ else
+ flash.now[:error] = 'There was a problem creating your account'
+ render "new"
+ end
+ end
+end
View
BIN  app/helpers/.pages_helper.rb.swp
Binary file not shown
View
2  app/views/layouts/application.html.erb
@@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><%= content_for?(:title) ? yield(:title) : "Tithe" %></title>
<%= csrf_meta_tags %>
- <%= tag :meta, :name => "stripe-key", :content => STRIPE_PUBLIC_TEST_KEY %>
+ <%= tag :meta, :name => "stripe-key", :content => ENV['STRIPE_PUBLIC_TEST_KEY'] %>
<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script>
View
2  app/views/organizations/_form.html.erb
@@ -6,7 +6,7 @@
<div class="field">
<%= f.label "Organization description:" %>
- <%= f.text_field :description %>
+ <%= f.text_area :description, :rows => 5 %>
</div>
<div class="actions">
View
4 app/views/pages/home.html.erb
@@ -3,5 +3,5 @@
<%= render 'layouts/carousel' %>
</body>
<h2>Welcome to Tithe.</h2>
-<h3>We help citizens support the governmental agencies they care most about.</h3>
-<%= button_to "Join today!", "#", class: "center btn btn-primary btn-large" %>
+<h3>We help citizens support the governmental agencies they care most about. </h3>
+<%= button_to "Join today!", sign_up_path, class: "center btn btn-primary btn-large", :method => :get %> <%= button_to "Log in!", login_path, class: "center btn btn-primary btn-large", :method => :get %>
View
12 app/views/sessions/new.html.haml
@@ -0,0 +1,12 @@
+%h1 Log in
+
+= form_tag sessions_path do
+ %p
+ = label_tag :email
+ %br
+ = text_field_tag :email, params[:email]
+ %p
+ = label_tag :password
+ %br
+ = password_field_tag :password
+ %p.button= submit_tag('Login')
View
23 app/views/users/new.html.haml
@@ -0,0 +1,23 @@
+<h1>Sign Up</h1>
+
+= form_for @user do |f|
+ - if @user.errors.any?
+ .error_messages
+ %h2 Form is invalid
+ %ul
+ - @user.errors.full_messages.each do |message|
+ %li= message
+ %p
+ = f.label :email
+ %br
+ = f.text_field :email
+ %p
+ = f.label :password
+ %br
+ = f.password_field :password
+ %p
+ = f.label :password_confirmation
+ %br
+ = f.password_field :password_confirmation
+ %p.button
+ = f.submit
View
1  config/initializers/stripe.rb
@@ -0,0 +1 @@
+Stripe.api_key = ENV['STRIPE_API_KEY']
View
9 config/routes.rb
@@ -1,8 +1,13 @@
Tithe::Application.routes.draw do
root :to => 'pages#home'
- resources :transactions
- resources :organizations
+ get 'login' => 'sessions#new', :as => 'login'
+ get 'logout' => 'sessions#destroy', :as => 'logout'
+ get 'sign_up' => 'users#new', :as => 'sign_up'
+ resources :transactions
+ resources :organizations
+ resources :users
+ resources :sessions, :only => [ :create ]
end
View
BIN  spec/controllers/.organizations_controller_spec.rb.swp
Binary file not shown
View
4 spec/controllers/organizations_controller_spec.rb
@@ -16,13 +16,13 @@
response.should redirect_to organization_path(assigns(:organization))
end
end
-
+
context "when given invalid parameters" do
before :each do
Organization.any_instance.stub(:save).and_return(false)
post(:create)
end
-
+
it "renders new" do
response.should render_template('new')
end
View
12 spec/controllers/pages_controller_spec.rb
@@ -1,12 +0,0 @@
-require 'spec_helper'
-
-describe PagesController do
-
- describe "GET 'home'" do
- it "returns http success" do
- get 'home'
- response.should be_success
- end
- end
-
-end
View
66 spec/controllers/sessions_controller_spec.rb
@@ -0,0 +1,66 @@
+require 'spec_helper'
+
+describe SessionsController do
+ render_views
+
+ before :each do
+ @user = FactoryGirl.create(:user)
+ end
+
+ describe '#create' do
+ context 'given valid credentials' do
+ before :each do
+ post(:create, :email => @user.email, :password => @user.password)
+ end
+
+ it 'sets the session user_id' do
+ session[:user_id].should == @user.id
+ end
+
+ it 'flashes a success message' do
+ flash[:notice].should == 'Logged in!'
+ end
+
+ it 'redirects to root_path' do
+ response.should redirect_to(root_path)
+ end
+ end
+
+ context 'given invalid credentials' do
+ before :each do
+ post(:create, :email => @user.email, :password => 'wrongpassword')
+ end
+
+ it 'sets the session user_id to nil' do
+ session[:user_id].should be_nil
+ end
+
+ it 'flashes an error message' do
+ flash.now[:error].should == 'Invalid email or password'
+ end
+
+ it 'renders the new template' do
+ response.should render_template('sessions/new')
+ end
+ end
+ end
+
+ describe '#destroy' do
+ before :each do
+ session[:user_id] = @user.id
+ delete(:destroy)
+ end
+
+ it 'sets the session user_id to nil' do
+ session[:user_id].should be_nil
+ end
+
+ it 'flashes a logged out message' do
+ flash[:notice].should == 'Logged out!'
+ end
+
+ it 'redirects to the root url' do
+ response.should redirect_to(root_url)
+ end
+ end
+end
View
77 spec/controllers/users_controller_spec.rb
@@ -0,0 +1,77 @@
+require 'spec_helper'
+
+describe UsersController do
+ render_views
+
+ describe '#new' do
+ before :each do
+ get(:new)
+ @user = assigns(:user)
+ end
+
+ it 'initializes an instance of User' do
+ @user.should be_instance_of User
+ end
+
+ it "doesn't save the user record" do
+ @user.should be_new_record
+ end
+ end
+
+ describe '#create' do
+ before :each do
+ @valid_params = {
+ :email => 'b@b.com',
+ :password => 'b',
+ :password_confirmation => 'b',
+ }
+ end
+
+ context 'given valid params' do
+ before :each do
+ post(:create, :user => @valid_params)
+ end
+
+ it 'flashes a success message' do
+ flash[:notice].should == 'Signed up!'
+ end
+
+ it 'creates a new user' do
+ user = assigns(:user)
+ user.email.should == 'b@b.com'
+ end
+
+ it "logs the user in" do
+ controller.send(:current_user).should == assigns(:user)
+ end
+ end
+
+ context 'without params' do
+ before :each do
+ post(:create)
+ end
+
+ it 'flashes an error' do
+ flash.now[:error].should =~ /problem creating your account/
+ end
+
+ it 'renders the new template' do
+ response.should render_template('users/new')
+ end
+ end
+
+ context 'given an invalid email' do
+ before :each do
+ post(:create, :user => @valid_params.merge(:password => 'c'))
+ end
+
+ it 'flashes an error' do
+ flash.now[:error].should =~ /problem creating your account/
+ end
+
+ it 'renders the new template' do
+ response.should render_template('users/new')
+ end
+ end
+ end
+end
View
15 spec/helpers/pages_helper_spec.rb
@@ -1,15 +0,0 @@
-require 'spec_helper'
-
-# Specs in this file have access to a helper object that includes
-# the PagesHelper. For example:
-#
-# describe PagesHelper do
-# describe "string concat" do
-# it "concats two strings with spaces" do
-# helper.concat_strings("this","that").should == "this that"
-# end
-# end
-# end
-describe PagesHelper do
- pending "add some examples to (or delete) #{__FILE__}"
-end
View
5 spec/models/organization_spec.rb
@@ -1,5 +0,0 @@
-require 'spec_helper'
-
-describe Organization do
- pending "add some examples to (or delete) #{__FILE__}"
-end
View
5 spec/models/transaction_spec.rb
@@ -1,5 +0,0 @@
-require 'spec_helper'
-
-describe Transaction do
- pending "add some examples to (or delete) #{__FILE__}"
-end
Please sign in to comment.
Something went wrong with that request. Please try again.