Commit 17e8f59b by phuctmZigexn

Finish layout and routes

parent 0401a2d3
...@@ -56,6 +56,7 @@ group :test do ...@@ -56,6 +56,7 @@ group :test do
gem 'selenium-webdriver' gem 'selenium-webdriver'
# Easy installation and use of chromedriver to run system tests with Chrome # Easy installation and use of chromedriver to run system tests with Chrome
gem 'chromedriver-helper' gem 'chromedriver-helper'
gem 'rails-controller-testing', '~> 1.0', '>= 1.0.2'
end end
group :production do group :production do
gem 'pg', '~> 1.0' gem 'pg', '~> 1.0'
...@@ -63,3 +64,4 @@ end ...@@ -63,3 +64,4 @@ end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'bootstrap-sass', '~> 3.3', '>= 3.3.7'
\ No newline at end of file
...@@ -47,9 +47,14 @@ GEM ...@@ -47,9 +47,14 @@ GEM
archive-zip (0.11.0) archive-zip (0.11.0)
io-like (~> 0.3.0) io-like (~> 0.3.0)
arel (9.0.0) arel (9.0.0)
autoprefixer-rails (9.0.2)
execjs
bindex (0.5.0) bindex (0.5.0)
bootsnap (1.3.1) bootsnap (1.3.1)
msgpack (~> 1.0) msgpack (~> 1.0)
bootstrap-sass (3.3.7)
autoprefixer-rails (>= 5.2.1)
sass (>= 3.3.4)
builder (3.2.3) builder (3.2.3)
byebug (10.0.2) byebug (10.0.2)
capybara (3.4.2) capybara (3.4.2)
...@@ -124,6 +129,10 @@ GEM ...@@ -124,6 +129,10 @@ GEM
bundler (>= 1.3.0) bundler (>= 1.3.0)
railties (= 5.2.0) railties (= 5.2.0)
sprockets-rails (>= 2.0.0) sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.2)
actionpack (~> 5.x, >= 5.0.1)
actionview (~> 5.x, >= 5.0.1)
activesupport (~> 5.x)
rails-dom-testing (2.0.3) rails-dom-testing (2.0.3)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
nokogiri (>= 1.6) nokogiri (>= 1.6)
...@@ -194,6 +203,7 @@ PLATFORMS ...@@ -194,6 +203,7 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
bootsnap (>= 1.1.0) bootsnap (>= 1.1.0)
bootstrap-sass (~> 3.3, >= 3.3.7)
byebug byebug
capybara (>= 2.15, < 4.0) capybara (>= 2.15, < 4.0)
chromedriver-helper chromedriver-helper
...@@ -203,6 +213,7 @@ DEPENDENCIES ...@@ -203,6 +213,7 @@ DEPENDENCIES
pg (~> 1.0) pg (~> 1.0)
puma (~> 3.11) puma (~> 3.11)
rails (~> 5.2.0) rails (~> 5.2.0)
rails-controller-testing (~> 1.0, >= 1.0.2)
sass-rails (~> 5.0) sass-rails (~> 5.0)
selenium-webdriver selenium-webdriver
spring spring
......
# 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/
/* /*
* This is a manifest file that'll be compiled into application.css, which will include all the files = require_self
* listed below. = require 'custom'
* */
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's \ No newline at end of file
* vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
* files in this directory. Styles in this file should be added after the last require_* statement.
* It is generally better to create a new file per style scope.
*
*= require_tree .
*= require_self
*/
@import "bootstrap-sprockets";
@import "bootstrap";
/* mixins, variables, etc */
$gray-medium-light: #eaeaea;
body {
padding-top: 60px;
}
section {
overflow: auto;
}
textarea {
resize: vertical;
}
.center {
text-align: center;
h1 {
margin-bottom: 10px;
}
}
h1, h2, h3, h4, h5, h6 {
line-height: 1;
}
h1 {
font-size: 3em;
letter-spacing: -2px;
margin-bottom: 30px;
text-align-last: center;
}
h2 {
font-size: 1.2em;
letter-spacing: -1px;
margin-bottom: 30px;
text-align-last: center;
font-weight: normal;
color: $gray-light;
}
p {
font-size: 1.1em;
line-height: 1.7em;
}
#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: #fff;
text-decoration: none;
}
}
/* footer */
footer {
margin-top: 45px;
padding-top: 5px;
border-top: 1px solid $gray-medium-light;
color: $gray-light;
a {
color: $gray;
&:hover {
color: $gray-darker;
}
}
small {
float: left;
}
ul {
float: right;
list-style: none;
li {
float: left;
margin-left: 15px;
}
}
}
// 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/
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.michaelhart.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 'Log in', '#' %></li>
</ul>
</nav>
</div>
</header>
\ No newline at end of file
...@@ -10,6 +10,10 @@ ...@@ -10,6 +10,10 @@
</head> </head>
<body> <body>
<%= render 'layouts/header' %>
<div class="container">
<%= yield %> <%= yield %>
<%= render 'layouts/footer' %>
</div>
</body> </body>
</html> </html>
<h1>Sample App</h1> <div class="center jumbotron">
<p> <h1>Welcome to the Sample App</h1>
<h2>
This is the home page for the This is the home page for the
<a href="http://www.railstutorial.org/">Ruby on Rails Tutorial</a> <a href="http://www.rails tutorial.org">Ruby on Rails Tutorial</a>
sample application. 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/" %>
\ No newline at end of file
<% provide(:title, 'Sign up') %>
<h1>Sign up</h1>
<p>This will be a signup page for new users.</p>
\ No newline at end of file
Rails.application.routes.draw do Rails.application.routes.draw do
root 'static_pages#home' root 'static_pages#home'
get 'static_pages/home' get '/help', to: 'static_pages#help'
get 'static_pages/help' get '/about', to: 'static_pages#about'
get 'static_pages/about' get '/contact', to: 'static_pages#contact'
get 'static_pages/contact' get '/signup', to: 'users#new'
end end
...@@ -2,25 +2,25 @@ require 'test_helper' ...@@ -2,25 +2,25 @@ require 'test_helper'
class StaticPagesControllerTest < ActionDispatch::IntegrationTest class StaticPagesControllerTest < ActionDispatch::IntegrationTest
test "should get home" do test "should get home" do
get static_pages_home_url get root_path
assert_response :success assert_response :success
assert_select "title", "Ruby on Rails Tutorial Sample App" assert_select "title", "Ruby on Rails Tutorial Sample App"
end end
test "should get help" do test "should get help" do
get static_pages_help_url get help_path
assert_response :success assert_response :success
assert_select "title", "Help | Ruby on Rails Tutorial Sample App" assert_select "title", "Help | Ruby on Rails Tutorial Sample App"
end end
test "should get about" do test "should get about" do
get static_pages_about_url get about_path
assert_response :success assert_response :success
assert_select "title", "About | Ruby on Rails Tutorial Sample App" assert_select "title", "About | Ruby on Rails Tutorial Sample App"
end end
test "should get contact" do test "should get contact" do
get static_pages_contact_url get contact_path
assert_response :success assert_response :success
assert_select "title", "Contact | Ruby on Rails Tutorial Sample App" assert_select "title", "Contact | Ruby on Rails Tutorial Sample App"
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 SiteLayoutTest < ActionDispatch::IntegrationTest
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
end
end
...@@ -5,6 +5,5 @@ require 'rails/test_help' ...@@ -5,6 +5,5 @@ require 'rails/test_help'
class ActiveSupport::TestCase class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all fixtures :all
# Add more helper methods to be used by all tests here... # Add more helper methods to be used by all tests here...
end 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