mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Create Rails testing environment
This commit is contained in:
parent
5153f10094
commit
686fb3d5b3
18 changed files with 260 additions and 104 deletions
|
@ -1,45 +1,20 @@
|
|||
source 'https://rubygems.org'
|
||||
|
||||
|
||||
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
||||
gem 'rails', '4.2.4'
|
||||
# Use sqlite3 as the database for Active Record
|
||||
gem 'sqlite3'
|
||||
# Use SCSS for stylesheets
|
||||
gem 'sass-rails', '~> 5.0'
|
||||
# Use Uglifier as compressor for JavaScript assets
|
||||
gem 'uglifier', '>= 1.3.0'
|
||||
# Use CoffeeScript for .coffee assets and views
|
||||
|
||||
gem 'coffee-rails', '~> 4.1.0'
|
||||
# See https://github.com/rails/execjs#readme for more supported runtimes
|
||||
# gem 'therubyracer', platforms: :ruby
|
||||
|
||||
# Use jquery as the JavaScript library
|
||||
gem 'jquery-rails'
|
||||
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
|
||||
gem 'hamlit', path: '../../'
|
||||
gem 'jbuilder', '~> 2.0'
|
||||
# bundle exec rake doc:rails generates the API under doc/api.
|
||||
gem 'sdoc', '~> 0.4.0', group: :doc
|
||||
|
||||
# Use ActiveModel has_secure_password
|
||||
# gem 'bcrypt', '~> 3.1.7'
|
||||
|
||||
# Use Unicorn as the app server
|
||||
# gem 'unicorn'
|
||||
|
||||
# Use Capistrano for deployment
|
||||
# gem 'capistrano-rails', group: :development
|
||||
gem 'jquery-rails'
|
||||
gem 'sass-rails', '~> 5.0'
|
||||
gem 'sqlite3'
|
||||
gem 'uglifier', '>= 1.3.0'
|
||||
|
||||
group :development, :test do
|
||||
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
||||
gem 'byebug'
|
||||
end
|
||||
|
||||
group :development do
|
||||
# Access an IRB console on exception pages or by using <%= console %> in views
|
||||
gem 'web-console', '~> 2.0'
|
||||
|
||||
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
|
||||
gem 'spring'
|
||||
end
|
||||
|
||||
|
|
|
@ -1,3 +1,12 @@
|
|||
PATH
|
||||
remote: ../../
|
||||
specs:
|
||||
hamlit (0.1.0)
|
||||
escape_utils
|
||||
haml (>= 4.0.7, < 5.0)
|
||||
temple (~> 0.7.6)
|
||||
tilt
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
|
@ -50,9 +59,12 @@ GEM
|
|||
coffee-script-source (1.10.0)
|
||||
debug_inspector (0.0.2)
|
||||
erubis (2.7.0)
|
||||
escape_utils (1.1.0)
|
||||
execjs (2.6.0)
|
||||
globalid (0.3.6)
|
||||
activesupport (>= 4.1.0)
|
||||
haml (4.0.7)
|
||||
tilt
|
||||
i18n (0.7.0)
|
||||
jbuilder (2.3.2)
|
||||
activesupport (>= 3.0.0, < 5)
|
||||
|
@ -100,7 +112,6 @@ GEM
|
|||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
rake (10.4.2)
|
||||
rdoc (4.2.0)
|
||||
sass (3.4.19)
|
||||
sass-rails (5.0.4)
|
||||
railties (>= 4.0.0, < 5.0)
|
||||
|
@ -108,9 +119,6 @@ GEM
|
|||
sprockets (>= 2.8, < 4.0)
|
||||
sprockets-rails (>= 2.0, < 4.0)
|
||||
tilt (>= 1.1, < 3)
|
||||
sdoc (0.4.1)
|
||||
json (~> 1.7, >= 1.7.7)
|
||||
rdoc (~> 4.0)
|
||||
spring (1.4.3)
|
||||
sprockets (3.4.0)
|
||||
rack (> 1, < 3)
|
||||
|
@ -119,6 +127,7 @@ GEM
|
|||
activesupport (>= 3.0)
|
||||
sprockets (>= 2.8, < 4.0)
|
||||
sqlite3 (1.3.11)
|
||||
temple (0.7.6)
|
||||
thor (0.19.1)
|
||||
thread_safe (0.3.5)
|
||||
tilt (2.0.1)
|
||||
|
@ -139,11 +148,11 @@ PLATFORMS
|
|||
DEPENDENCIES
|
||||
byebug
|
||||
coffee-rails (~> 4.1.0)
|
||||
hamlit!
|
||||
jbuilder (~> 2.0)
|
||||
jquery-rails
|
||||
rails (= 4.2.4)
|
||||
sass-rails (~> 5.0)
|
||||
sdoc (~> 0.4.0)
|
||||
spring
|
||||
sqlite3
|
||||
uglifier (>= 1.3.0)
|
||||
|
|
3
sample/rails/app/assets/javascripts/users.coffee
Normal file
3
sample/rails/app/assets/javascripts/users.coffee
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
73
sample/rails/app/assets/stylesheets/scaffolds.scss
Normal file
73
sample/rails/app/assets/stylesheets/scaffolds.scss
Normal file
|
@ -0,0 +1,73 @@
|
|||
body {
|
||||
background-color: #fff;
|
||||
color: #333;
|
||||
font-family: verdana, arial, helvetica, sans-serif;
|
||||
font-size: 13px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
p, ol, ul, td {
|
||||
font-family: verdana, arial, helvetica, sans-serif;
|
||||
font-size: 13px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
pre {
|
||||
background-color: #eee;
|
||||
padding: 10px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #000;
|
||||
|
||||
&:visited {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
color: #fff;
|
||||
background-color: #000;
|
||||
}
|
||||
}
|
||||
|
||||
div {
|
||||
&.field, &.actions {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
#notice {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.field_with_errors {
|
||||
padding: 2px;
|
||||
background-color: red;
|
||||
display: table;
|
||||
}
|
||||
|
||||
#error_explanation {
|
||||
width: 450px;
|
||||
border: 2px solid red;
|
||||
padding: 7px;
|
||||
padding-bottom: 0;
|
||||
margin-bottom: 20px;
|
||||
background-color: #f0f0f0;
|
||||
|
||||
h2 {
|
||||
text-align: left;
|
||||
font-weight: bold;
|
||||
padding: 5px 5px 5px 15px;
|
||||
font-size: 12px;
|
||||
margin: -7px;
|
||||
margin-bottom: 0px;
|
||||
background-color: #c00;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
ul li {
|
||||
font-size: 12px;
|
||||
list-style: square;
|
||||
}
|
||||
}
|
3
sample/rails/app/assets/stylesheets/users.scss
Normal file
3
sample/rails/app/assets/stylesheets/users.scss
Normal file
|
@ -0,0 +1,3 @@
|
|||
// Place all the styles related to the users controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
74
sample/rails/app/controllers/users_controller.rb
Normal file
74
sample/rails/app/controllers/users_controller.rb
Normal file
|
@ -0,0 +1,74 @@
|
|||
class UsersController < ApplicationController
|
||||
before_action :set_user, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
# GET /users
|
||||
# GET /users.json
|
||||
def index
|
||||
@users = User.all
|
||||
end
|
||||
|
||||
# GET /users/1
|
||||
# GET /users/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /users/new
|
||||
def new
|
||||
@user = User.new
|
||||
end
|
||||
|
||||
# GET /users/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /users
|
||||
# POST /users.json
|
||||
def create
|
||||
@user = User.new(user_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @user.save
|
||||
format.html { redirect_to @user, notice: 'User was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @user }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @user.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /users/1
|
||||
# PATCH/PUT /users/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @user.update(user_params)
|
||||
format.html { redirect_to @user, notice: 'User was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @user }
|
||||
else
|
||||
format.html { render :edit }
|
||||
format.json { render json: @user.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /users/1
|
||||
# DELETE /users/1.json
|
||||
def destroy
|
||||
@user.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to users_url, notice: 'User was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_user
|
||||
@user = User.find(params[:id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def user_params
|
||||
params[:user]
|
||||
end
|
||||
end
|
2
sample/rails/app/helpers/users_helper.rb
Normal file
2
sample/rails/app/helpers/users_helper.rb
Normal file
|
@ -0,0 +1,2 @@
|
|||
module UsersHelper
|
||||
end
|
2
sample/rails/app/models/user.rb
Normal file
2
sample/rails/app/models/user.rb
Normal file
|
@ -0,0 +1,2 @@
|
|||
class User < ActiveRecord::Base
|
||||
end
|
|
@ -1,14 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Dummy</title>
|
||||
<%= stylesheet_link_tag 'application', media: 'all' %>
|
||||
<%= javascript_include_tag 'application' %>
|
||||
<%= csrf_meta_tags %>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<%= yield %>
|
||||
|
||||
</body>
|
||||
</html>
|
9
sample/rails/app/views/layouts/application.html.haml
Normal file
9
sample/rails/app/views/layouts/application.html.haml
Normal file
|
@ -0,0 +1,9 @@
|
|||
!!!
|
||||
%html
|
||||
%head
|
||||
%title Dummy
|
||||
= stylesheet_link_tag 'application', media: 'all'
|
||||
= javascript_include_tag 'application'
|
||||
= csrf_meta_tags
|
||||
%body
|
||||
= yield
|
11
sample/rails/app/views/users/_form.html.haml
Normal file
11
sample/rails/app/views/users/_form.html.haml
Normal file
|
@ -0,0 +1,11 @@
|
|||
= form_for(@user) do |f|
|
||||
- if @user.errors.any?
|
||||
#error_explanation
|
||||
%h2 #{pluralize(@user.errors.count, "error")} prohibited this user from being saved:
|
||||
|
||||
%ul
|
||||
- @user.errors.full_messages.each do |message|
|
||||
%li= message
|
||||
|
||||
.actions
|
||||
= f.submit
|
5
sample/rails/app/views/users/edit.html.haml
Normal file
5
sample/rails/app/views/users/edit.html.haml
Normal file
|
@ -0,0 +1,5 @@
|
|||
%h1 Editing User
|
||||
|
||||
= render 'form'
|
||||
|
||||
#{link_to 'Show', @user} | #{link_to 'Back', users_path}
|
19
sample/rails/app/views/users/index.html.haml
Normal file
19
sample/rails/app/views/users/index.html.haml
Normal file
|
@ -0,0 +1,19 @@
|
|||
%p#notice= notice
|
||||
|
||||
%h1 Listing Users
|
||||
|
||||
%table
|
||||
%thead
|
||||
%tr
|
||||
%th{ colspan: "3" }
|
||||
|
||||
%tbody
|
||||
- @users.each do |user|
|
||||
%tr
|
||||
%td= link_to 'Show', user
|
||||
%td= link_to 'Edit', edit_user_path(user)
|
||||
%td= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' }
|
||||
|
||||
%br
|
||||
|
||||
= link_to 'New User', new_user_path
|
5
sample/rails/app/views/users/new.html.haml
Normal file
5
sample/rails/app/views/users/new.html.haml
Normal file
|
@ -0,0 +1,5 @@
|
|||
%h1 New User
|
||||
|
||||
= render 'form'
|
||||
|
||||
= link_to 'Back', users_path
|
3
sample/rails/app/views/users/show.html.haml
Normal file
3
sample/rails/app/views/users/show.html.haml
Normal file
|
@ -0,0 +1,3 @@
|
|||
#notice= notice
|
||||
|
||||
#{link_to 'Edit', edit_user_path(@user)} | #{link_to 'Back', users_path}
|
|
@ -1,56 +1,4 @@
|
|||
Rails.application.routes.draw do
|
||||
# The priority is based upon order of creation: first created -> highest priority.
|
||||
# See how all your routes lay out with "rake routes".
|
||||
|
||||
# You can have the root of your site routed with "root"
|
||||
# root 'welcome#index'
|
||||
|
||||
# Example of regular route:
|
||||
# get 'products/:id' => 'catalog#view'
|
||||
|
||||
# Example of named route that can be invoked with purchase_url(id: product.id)
|
||||
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
|
||||
|
||||
# Example resource route (maps HTTP verbs to controller actions automatically):
|
||||
# resources :products
|
||||
|
||||
# Example resource route with options:
|
||||
# resources :products do
|
||||
# member do
|
||||
# get 'short'
|
||||
# post 'toggle'
|
||||
# end
|
||||
#
|
||||
# collection do
|
||||
# get 'sold'
|
||||
# end
|
||||
# end
|
||||
|
||||
# Example resource route with sub-resources:
|
||||
# resources :products do
|
||||
# resources :comments, :sales
|
||||
# resource :seller
|
||||
# end
|
||||
|
||||
# Example resource route with more complex sub-resources:
|
||||
# resources :products do
|
||||
# resources :comments
|
||||
# resources :sales do
|
||||
# get 'recent', on: :collection
|
||||
# end
|
||||
# end
|
||||
|
||||
# Example resource route with concerns:
|
||||
# concern :toggleable do
|
||||
# post 'toggle'
|
||||
# end
|
||||
# resources :posts, concerns: :toggleable
|
||||
# resources :photos, concerns: :toggleable
|
||||
|
||||
# Example resource route within a namespace:
|
||||
# namespace :admin do
|
||||
# # Directs /admin/products/* to Admin::ProductsController
|
||||
# # (app/controllers/admin/products_controller.rb)
|
||||
# resources :products
|
||||
# end
|
||||
resources :users
|
||||
root to: 'users#index'
|
||||
end
|
||||
|
|
8
sample/rails/db/migrate/20151119022746_create_users.rb
Normal file
8
sample/rails/db/migrate/20151119022746_create_users.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
class CreateUsers < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :users do |t|
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
end
|
21
sample/rails/db/schema.rb
Normal file
21
sample/rails/db/schema.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
# encoding: UTF-8
|
||||
# This file is auto-generated from the current state of the database. Instead
|
||||
# of editing this file, please use the migrations feature of Active Record to
|
||||
# incrementally modify your database, and then regenerate this schema definition.
|
||||
#
|
||||
# Note that this schema.rb definition is the authoritative source for your
|
||||
# database schema. If you need to create the application database on another
|
||||
# system, you should be using db:schema:load, not running all the migrations
|
||||
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
||||
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20151119022746) do
|
||||
|
||||
create_table "users", force: :cascade do |t|
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in a new issue