Commit 60205d57 by Quang Vinh Nguyen

Finish layout and routes

parent 459d819b
......@@ -57,6 +57,7 @@
source 'https://rubygems.org'
gem 'rails', '5.1.4'
gem 'bootstrap-sass', '3.3.7'
gem 'puma', '3.9.1'
gem 'sass-rails', '5.0.6'
gem 'uglifier', '3.2.0'
......
......@@ -40,7 +40,12 @@ GEM
tzinfo (~> 1.1)
ansi (1.5.0)
arel (8.0.0)
autoprefixer-rails (8.5.1)
execjs
bindex (0.5.0)
bootstrap-sass (3.3.7)
autoprefixer-rails (>= 5.2.1)
sass (>= 3.3.4)
builder (3.2.3)
byebug (9.0.6)
coderay (1.1.2)
......@@ -197,6 +202,7 @@ PLATFORMS
ruby
DEPENDENCIES
bootstrap-sass (= 3.3.7)
byebug (= 9.0.6)
coffee-rails (= 4.2.2)
guard (= 2.13.0)
......
# 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/
@import "bootstrap-sprockets";
@import "bootstrap";
/* universal */
body {
padding-top: 60px;
}
section {
overflow: auto;
}
textarea {
resize: vertical;
}
.center {
text-align: center;
h1 {
margin-bottom: 10px;
}
}
/* typography */
h1,h2,h3,h4,h5,h6 {
line-height: 1;
}
h1 {
font-size: 3em;
letter-spacing: -2px;
margin-bottom: 30px;
text-align: center;
}
h2 {
font-size: 1.2em;
letter-spacing: -1px;
margin-bottom: 30px;
text-align: center;
font-weight: normal;
color: #777;
}
p {
font-size: 1.1em;
line-height: 1.7em;
}
/* header */
#logo {
float: left;
margin-right: 10px;
font-size: 1.7em;
color: #fff;
text-transform: uppercase;
letter-spacing: -1px;
padding-top: 9px;
font-weight: bold;
&hover {
color: #000;
text-decoration: none;
}
}
/* image */
#kitten {
display: none;
}
/* footer */
footer {
margin-top: 45px;
padding-top: 5px;
border-top: 1px solid #eaeaea;
color: #777;
a {
color: #555;
&hover {
color: #222;
}
}
small {
float: left;
}
ul {
float: right;
list-style: none;
li {
float: left;
margin-left: 15px;
}
}
}
\ No newline at end of file
// 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/
# This is user controller
class UsersController < ApplicationController
def new; end
end
module UsersHelper
end
<footer class="footer">
<small>
The <a href="http://www.railstutorial.org/">Ruby on Rails Tutorial</a>
by <a href="http://www.michaelhartl.com/">Michael Hartl</a>
</small>
<nav>
<ul>
<li><%= link_to "About", about_path %></li>
<li><%= link_to "Contact", contact_path %></li>
<li><a href="http://news.railstutorial.org/">News</a></li>
</ul>
</nav>
</footer>
\ No newline at end of file
<header class="navbar navbar-fixed-top navbar-inverse">
<div class="container">
<%= link_to "sample_app", root_path, id: "logo" %>
<nav>
<ul class="nav navbar-nav navbar-right">
<li><%= link_to "Home", root_path %></li>
<li><%= link_to "Help", help_path %></li>
<li><%= link_to "Login", '#' %></li>
</ul>
</nav>
</div>
</header>
\ No newline at end of file
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/r29/html5.min.js">
</script>
<![endif]-->
\ No newline at end of file
......@@ -2,14 +2,15 @@
<html>
<head>
<title><%= full_title(yield(:title)) %></title>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
<%= render 'layouts/rails_default' %>
<%= render 'layouts/shim' %>
</head>
<body>
<%= render 'layouts/header' %>
<div class="container">
<%= yield %>
</div>
<%= render 'layouts/footer' %>
</body>
</html>
<%# provide(:title, "Home") %>
<body>
<h1>Sample App</h1>
<p>
<div class="center jumbotron">
<h1>Welcome to the Sample App</h1>
<h2>
This is the home page for the
<a href="http://www.railstutorial.org/">Ruby on Rails Tutorial</a>
sample application.
</p>
</h2>
<%= link_to "Sign up now!", signup_path , class: "btn btn-lg btn-primary" %>
</div>
<%= link_to image_tag("rails.png", alt: "Rails logo"),
'http://rubyonrails.org/' %>
<%= image_tag("kitten.jpg",alt: "Kitten", id: "kitten" ) %>
\ No newline at end of file
<% provide(:title, 'Sign up') %>
<h1>Users#new</h1>
<p>Find me in app/views/users/new.html.erb</p>
Rails.application.routes.draw do
root 'static_pages#home'
get 'static_pages/home'
get 'static_pages/help'
get 'static_pages/about'
get 'static_pages/contact'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
# root 'application#hello'
get '/signup', to: 'users#new'
get '/help', to: 'static_pages#help'
get '/about', to: 'static_pages#about'
get '/contact', to: 'static_pages#contact'
end
......@@ -2,39 +2,36 @@ require 'test_helper'
class StaticPagesControllerTest < ActionDispatch::IntegrationTest
def setup
@base_title = "Ruby on Rails Tutorial Sample App"
@base_title = 'Ruby on Rails Tutorial Sample App'
end
test "should get root" do
test 'should get root' do
get root_url
assert_response :success
end
test "should get home" do
get static_pages_home_url
test 'should get home' do
get root_path
assert_response :success
# assert_select "title", "Home | #{@base_title}"
assert_select "title", "Ruby on Rails Tutorial Sample App"
assert_select 'title', 'Ruby on Rails Tutorial Sample App'
end
test "should get help" do
get static_pages_help_url
test 'should get help' do
get help_path
assert_response :success
assert_select "title", "Help | #{@base_title}"
assert_select 'title', "Help | #{@base_title}"
end
test "should get about" do
get static_pages_about_url
test 'should get about' do
get about_path
assert_response :success
assert_select "title", "About | #{@base_title}"
assert_select 'title', "About | #{@base_title}"
end
test "should get contact" do
get static_pages_contact_url
test 'should get contact' do
get contact_path
assert_response :success
assert_select "title", "Contact | #{@base_title}"
assert_select 'title', "Contact | #{@base_title}"
end
end
require 'test_helper'
class UsersControllerTest < ActionDispatch::IntegrationTest
test 'should get new' do
get signup_path
assert_response :success
end
end
require 'test_helper'
class ApplicationHelperTest < ActionView::TestCase
test 'full title helper' do
assert_equal full_title, 'Ruby on Rails Tutorial Sample App'
assert_equal full_title('Help'), 'Help | Ruby on Rails Tutorial Sample App'
end
end
require 'test_helper'
class SiteLayoutTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
test 'layout links' do
get root_path
assert_template 'static_pages/home'
assert_select 'a[href=?]', root_path, count: 2
assert_select 'a[href=?]', help_path
assert_select 'a[href=?]', about_path
assert_select 'a[href=?]', contact_path
get contact_path
assert_select 'title', full_title('Contact')
get signup_path
assert_select 'title', full_title('Sign up')
end
end
......@@ -13,5 +13,6 @@ class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
# Add more helper methods to be used by all tests here...
include ApplicationHelper
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment