Last active
August 29, 2015 14:12
-
-
Save johnrees/567c0e025c86ae243101 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /coverage | |
| *.todo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| *= require_tree . | |
| *= require normalize-rails | |
| *= require_self | |
| */ | |
| * { | |
| box-sizing: border-box; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| doctype html | |
| html | |
| head | |
| title = raw(content_for?(:title) ? "#{yield(:title)} | Site" : "Site") | |
| = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true | |
| = javascript_include_tag 'application', 'data-turbolinks-track' => true | |
| = csrf_meta_tags | |
| meta content="width=device-width, initial-scale=1" name="viewport" | |
| body | |
| .container | |
| header | |
| - if current_user | |
| .user-nav= link_to 'Logout', logout_path | |
| - else | |
| .user-nav | |
| = link_to "Sign up", new_user_path | |
| = link_to "Log in", new_session_path | |
| #main | |
| - flash.each do |key, msg| | |
| = content_tag :div, msg, id: key | |
| == yield | |
| footer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| config.generators do |g| | |
| g.helper false | |
| g.assets false | |
| g.test_framework :rspec, | |
| helper: false, | |
| assets: false, | |
| fixtures: true, | |
| view_specs: false, | |
| helper_specs: false, | |
| routing_specs: false, | |
| controller_specs: true, | |
| request_specs: false | |
| g.fixture_replacement :factory_girl, dir: "spec/factories" | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private | |
| def current_user | |
| @current_user ||= User.find(session[:user_id]) if session[:user_id] | |
| end | |
| helper_method :current_user | |
| def authenticate_user! | |
| redirect_to login_url, alert: "Please sign in" if current_user.nil? | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module ApplicationHelper | |
| def title(page_title, options={}) | |
| content_for(:title, page_title.to_s) | |
| return content_tag(:h1, page_title, options.merge(itemprop: "name")) | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ApplicationMailer < ActionMailer::Base | |
| default from: "address" | |
| include Roadie::Rails::Automatic | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| config.action_mailer.delivery_method = :letter_opener | |
| config.action_mailer.default_url_options = { host: 'iaac.dev' } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| gem 'figaro' | |
| gem 'pundit' | |
| gem "slim-rails" | |
| gem 'responders' | |
| gem "workflow" | |
| group :test do | |
| gem "ffaker" | |
| gem "capybara" | |
| gem "database_cleaner" | |
| gem "launchy" | |
| end | |
| group :development do | |
| gem "quiet_assets" | |
| gem "spring-commands-rspec" | |
| gem "letter_opener" | |
| end | |
| group :development, :test do | |
| gem "rspec-rails" | |
| gem "factory_girl_rails" | |
| gem "shoulda-matchers", require: false | |
| gem "guard-rspec" | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rails generate rspec:install && bundle exec figaro install | |
| mkdir -p bin | |
| curl -o bin/test https://gist.githubusercontent.com/johnrees/b0abd440eb1f8bc1b6e9/raw/4f82ff34435fbe8d5d68755b193f60285843e494/test | |
| chmod +x bin/test | |
| spring binstub --all | |
| guard init rspec |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'shoulda-matchers' | |
| RSpec.configure do |config| | |
| config.include Devise::TestHelpers, type: :controller |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SessionsController < ApplicationController | |
| def new | |
| redirect_to root_url if current_user | |
| end | |
| def create | |
| user = User.where(email: params[:email].downcase.strip).first | |
| if user && user.authenticate(params[:password]) | |
| session[:user_id] = user.id | |
| user.update_attributes(sign_in_count: user.sign_in_count + 1, last_sign_in_at: Time.now) | |
| redirect_to root_url#, notice: "Logged in!" | |
| else | |
| flash.now.alert = "Invalid email or password" | |
| render "new" | |
| end | |
| end | |
| def destroy | |
| session[:user_id] = nil | |
| redirect_to root_url, notice: "Logged out!" | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class UsersController < ApplicationController | |
| before_action :authenticate_user!, only: :update | |
| def update | |
| @user = current_user | |
| @user.update_attributes user_params | |
| if @user.save | |
| @user.update_attribute :invitation_code, nil | |
| redirect_to root_path, notice: 'Details updated successfully' | |
| else | |
| render :edit | |
| end | |
| end | |
| private | |
| def user_params | |
| params.require(:user).permit( | |
| :first_name, | |
| :last_name, | |
| :email, | |
| :password, | |
| :password_confirmation, | |
| :country_code, | |
| :photo, | |
| :description, | |
| :dob, | |
| :gender | |
| ) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment