Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
rails-tutorials
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tô Ngọc Ánh
rails-tutorials
Commits
13dadb1d
Commit
13dadb1d
authored
Jun 23, 2020
by
Tô Ngọc Ánh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finish static pages
parent
4bcf8b09
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
85 additions
and
5 deletions
+85
-5
sample_app/app/controllers/static_pages_controller.rb
+3
-0
sample_app/app/views/layouts/application.html.erb
+2
-0
sample_app/app/views/static_pages/about.html.erb
+9
-0
sample_app/app/views/static_pages/help.html.erb
+9
-2
sample_app/app/views/static_pages/home.html.erb
+8
-2
sample_app/config/routes.rb
+1
-0
sample_app/spec/rails_helper.rb
+2
-1
sample_app/spec/requests/static_pages_spec.rb
+51
-0
No files found.
sample_app/app/controllers/static_pages_controller.rb
View file @
13dadb1d
...
...
@@ -4,4 +4,7 @@ class StaticPagesController < ApplicationController
def
help
end
def
about
end
end
sample_app/app/views/layouts/application.html.erb
View file @
13dadb1d
<!DOCTYPE html>
<html>
<head>
<title>
Ruby on Rails Tutorial Sample App |
<%=
yield
(
:title
)
%>
</title>
<title>
SampleApp
</title>
<%=
csrf_meta_tags
%>
<%=
csp_meta_tag
%>
...
...
sample_app/app/views/static_pages/about.html.erb
0 → 100644
View file @
13dadb1d
<%
provide
(
:title
,
'About Us'
)
%>
<h1>
About Us
</h1>
<p>
The
<a
href=
"http://railstutorial.org/"
>
Ruby on Rails Tutorial
</a>
is a project to make a book and screencasts to teach web development
with
<a
href=
"http://rubyonrails.org/"
>
Ruby on Rails
</a>
. This
is the sample application for the tutorial.
</p>
\ No newline at end of file
sample_app/app/views/static_pages/help.html.erb
View file @
13dadb1d
<h1>
StaticPages#help
</h1>
<p>
Find me in app/views/static_pages/help.html.erb
</p>
<%
provide
(
:title
,
'Help'
)
%>
<h1>
Help
</h1>
<p>
Get help on the Ruby on Rails Tutorial at the
<a
href=
"http://railstutorial.org/help"
>
Rails Tutorial help page
</a>
.
To get help on this sample app, see the
<a
href=
"http://railstutorial.org/book"
>
Rails Tutorial book
</a>
.
</p>
\ No newline at end of file
sample_app/app/views/static_pages/home.html.erb
View file @
13dadb1d
<h1>
StaticPages#home
</h1>
<p>
Find me in app/views/static_pages/home.html.erb
</p>
<%
provide
(
:title
,
'Home'
)
%>
<h1>
Sample App
</h1>
<p>
This is the home page for the
<a
href=
"http://railstutorial.org/"
>
Ruby on Rails Tutorial
</a>
sample application.
</p>
\ No newline at end of file
sample_app/config/routes.rb
View file @
13dadb1d
Rails
.
application
.
routes
.
draw
do
get
'static_pages/home'
get
'static_pages/help'
get
'static_pages/about'
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
end
sample_app/spec/rails_helper.rb
View file @
13dadb1d
...
...
@@ -5,6 +5,7 @@ require File.expand_path('../config/environment', __dir__)
# Prevent database truncation if the environment is production
abort
(
"The Rails environment is running in production mode!"
)
if
Rails
.
env
.
production?
require
'rspec/rails'
require
'capybara'
# Add additional requires below this line. Rails is not loaded until this point!
# Requires supporting ruby files with custom matchers and macros, etc, in
...
...
@@ -33,7 +34,7 @@ end
RSpec
.
configure
do
|
config
|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config
.
fixture_path
=
"
#{
::
Rails
.
root
}
/spec/fixtures"
config
.
include
Capybara
::
DSL
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
...
...
sample_app/spec/requests/static_pages_spec.rb
0 → 100644
View file @
13dadb1d
# require 'rails_helper'
# RSpec.describe "StaticPages", type: :request do
# describe "GET /static_pages/home" do
# it "works! (now write some real specs)" do
# get static_pages_home_path
# expect(response).to have_http_status(200)
# end
# end
# end
require
'rails_helper'
describe
"Static pages"
do
describe
"Home page"
do
it
"should have the content 'Sample App'"
do
visit
'/static_pages/home'
expect
(
page
).
to
have_content
(
'Sample App'
)
end
it
"should have the right title"
do
visit
'/static_pages/home'
expect
(
page
).
to
have_title
(
"Ruby on Rails Tutorial Sample App | Home"
)
end
end
describe
"Help page"
do
it
"should have the content 'Help'"
do
visit
'/static_pages/help'
expect
(
page
).
to
have_content
(
'Help'
)
end
it
"should have the title 'Help'"
do
visit
'/static_pages/help'
expect
(
page
).
to
have_title
(
"Ruby on Rails Tutorial Sample App | Help"
)
end
end
describe
"About page"
do
it
"should have the content 'About Us'"
do
visit
'/static_pages/about'
expect
(
page
).
to
have_content
(
'About Us'
)
end
it
"should have the title 'About Us'"
do
visit
'/static_pages/about'
expect
(
page
).
to
have_title
(
"Ruby on Rails Tutorial Sample App | About Us"
)
end
end
end
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment