Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove default Rails page

  • Loading branch information...
commit f82a3e6512a3981feb92525e1db80c1e58ba3590 1 parent e87e4b7
@Bediko authored
View
1  .gitignore
@@ -6,6 +6,7 @@
# Ignore bundler config
/.bundle
+/bundler_stubs
# Ignore the default SQLite database.
/db/*.sqlite3
View
1  .rspec
@@ -1 +1,2 @@
--colour
+--drb
View
10 Gemfile
@@ -1,10 +1,11 @@
-source 'https://rubygems.org'
+source 'http://rubygems.org'
gem 'rails', '3.2.1'
-group :development, :test do
+group :development do
gem 'sqlite3', '1.3.5'
gem 'rspec-rails', '2.8.1'
+ gem 'guard-rspec', '0.5.5'
end
# Gems used only for assets and not required
@@ -18,7 +19,12 @@ end
gem 'jquery-rails', '2.0.0'
group :test do
+ gem 'rspec-rails', '2.8.1'
gem 'capybara', '1.1.2'
+ gem 'rb-inotify'
+ gem 'libnotify'
+ gem 'guard-spork'
+ gem 'spork'
end
group :production do
View
19 Gemfile.lock
@@ -1,5 +1,5 @@
GEM
- remote: https://rubygems.org/
+ remote: http://rubygems.org/
specs:
actionmailer (3.2.1)
actionpack (= 3.2.1)
@@ -51,6 +51,14 @@ GEM
execjs (1.3.0)
multi_json (~> 1.0)
ffi (1.0.11)
+ guard (1.0.0)
+ ffi (>= 0.5.0)
+ thor (~> 0.14.6)
+ guard-rspec (0.5.5)
+ guard (>= 0.8.4)
+ guard-spork (0.5.2)
+ guard (>= 0.10.0)
+ spork (>= 0.8.4)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.3)
@@ -58,6 +66,7 @@ GEM
railties (>= 3.2.0.beta, < 5.0)
thor (~> 0.14)
json (1.6.5)
+ libnotify (0.7.2)
mail (2.4.1)
i18n (>= 0.4.0)
mime-types (~> 1.16)
@@ -90,6 +99,8 @@ GEM
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2.2)
+ rb-inotify (0.8.8)
+ ffi (>= 0.5.0)
rdoc (3.12)
json (~> 1.4)
rspec (2.8.0)
@@ -116,6 +127,7 @@ GEM
ffi (~> 1.0)
multi_json (~> 1.0)
rubyzip
+ spork (0.9.0)
sprockets (2.1.2)
hike (~> 1.2)
rack (~> 1.0)
@@ -139,10 +151,15 @@ PLATFORMS
DEPENDENCIES
capybara (= 1.1.2)
coffee-rails (= 3.2.2)
+ guard-rspec (= 0.5.5)
+ guard-spork
jquery-rails (= 2.0.0)
+ libnotify
pg (= 0.12.2)
rails (= 3.2.1)
+ rb-inotify
rspec-rails (= 2.8.1)
sass-rails (= 3.2.3)
+ spork
sqlite3 (= 1.3.5)
uglifier (= 1.2.3)
View
3  app/controllers/static_pages_controller.rb
@@ -7,4 +7,7 @@ def help
def about
end
+
+ def contact
+ end
end
View
10 app/helpers/application_helper.rb
@@ -1,2 +1,12 @@
module ApplicationHelper
+
+ # Returns the full title on a per-page basis.
+ def full_title(page_title)
+ base_title = "Ruby on Rails Tutorial Sample App"
+ if page_title.empty?
+ base_title
+ else
+ "#{base_title} | #{page_title}"
+ end
+ end
end
View
12 app/views/layouts/application.html.erb
@@ -1,12 +1,18 @@
<!DOCTYPE html>
<html>
<head>
- <title>Ruby on Rails Tutorial Sample App | <%= yield(:title) %></title>
- <%= stylesheet_link_tag "application", :media => "all" %>
+ <title><%= full_title(yield(:title)) %></title>
+ <%= render 'layouts/stylesheets' %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
- <%= yield %>
+ <div class="container">
+ <%= render 'layouts/header' %>
+ <section class="round">
+ <%= yield %>
+ </section>
+ <%= render 'layouts/footer' %>
+ </div>
</body>
</html>
View
3  app/views/static_pages/home.html.erb
@@ -1,7 +1,10 @@
<% 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>
+
+<%= link_to "Sign up now!", '#', class: "signup_button round" %>
View
6 config/routes.rb
@@ -1,9 +1,11 @@
SampleApp::Application.routes.draw do
get "static_pages/home"
- get "static_pages/help"
+ root to: 'static_pages#home'
- get "static_pages/about"
+ match '/help', to: 'static_pages#help'
+ match 'about', to: 'static_pages#about'
+ match '/contact', to: 'static_pages#contact'
# The priority is based upon order of creation:
# first created -> highest priority.
View
241 public/index.html
@@ -1,241 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
- <title>Ruby on Rails: Welcome aboard</title>
- <style type="text/css" media="screen">
- body {
- margin: 0;
- margin-bottom: 25px;
- padding: 0;
- background-color: #f0f0f0;
- font-family: "Lucida Grande", "Bitstream Vera Sans", "Verdana";
- font-size: 13px;
- color: #333;
- }
-
- h1 {
- font-size: 28px;
- color: #000;
- }
-
- a {color: #03c}
- a:hover {
- background-color: #03c;
- color: white;
- text-decoration: none;
- }
-
-
- #page {
- background-color: #f0f0f0;
- width: 750px;
- margin: 0;
- margin-left: auto;
- margin-right: auto;
- }
-
- #content {
- float: left;
- background-color: white;
- border: 3px solid #aaa;
- border-top: none;
- padding: 25px;
- width: 500px;
- }
-
- #sidebar {
- float: right;
- width: 175px;
- }
-
- #footer {
- clear: both;
- }
-
- #header, #about, #getting-started {
- padding-left: 75px;
- padding-right: 30px;
- }
-
-
- #header {
- background-image: url("assets/rails.png");
- background-repeat: no-repeat;
- background-position: top left;
- height: 64px;
- }
- #header h1, #header h2 {margin: 0}
- #header h2 {
- color: #888;
- font-weight: normal;
- font-size: 16px;
- }
-
-
- #about h3 {
- margin: 0;
- margin-bottom: 10px;
- font-size: 14px;
- }
-
- #about-content {
- background-color: #ffd;
- border: 1px solid #fc0;
- margin-left: -55px;
- margin-right: -10px;
- }
- #about-content table {
- margin-top: 10px;
- margin-bottom: 10px;
- font-size: 11px;
- border-collapse: collapse;
- }
- #about-content td {
- padding: 10px;
- padding-top: 3px;
- padding-bottom: 3px;
- }
- #about-content td.name {color: #555}
- #about-content td.value {color: #000}
-
- #about-content ul {
- padding: 0;
- list-style-type: none;
- }
-
- #about-content.failure {
- background-color: #fcc;
- border: 1px solid #f00;
- }
- #about-content.failure p {
- margin: 0;
- padding: 10px;
- }
-
-
- #getting-started {
- border-top: 1px solid #ccc;
- margin-top: 25px;
- padding-top: 15px;
- }
- #getting-started h1 {
- margin: 0;
- font-size: 20px;
- }
- #getting-started h2 {
- margin: 0;
- font-size: 14px;
- font-weight: normal;
- color: #333;
- margin-bottom: 25px;
- }
- #getting-started ol {
- margin-left: 0;
- padding-left: 0;
- }
- #getting-started li {
- font-size: 18px;
- color: #888;
- margin-bottom: 25px;
- }
- #getting-started li h2 {
- margin: 0;
- font-weight: normal;
- font-size: 18px;
- color: #333;
- }
- #getting-started li p {
- color: #555;
- font-size: 13px;
- }
-
-
- #sidebar ul {
- margin-left: 0;
- padding-left: 0;
- }
- #sidebar ul h3 {
- margin-top: 25px;
- font-size: 16px;
- padding-bottom: 10px;
- border-bottom: 1px solid #ccc;
- }
- #sidebar li {
- list-style-type: none;
- }
- #sidebar ul.links li {
- margin-bottom: 5px;
- }
-
- .filename {
- font-style: italic;
- }
- </style>
- <script type="text/javascript">
- function about() {
- info = document.getElementById('about-content');
- if (window.XMLHttpRequest)
- { xhr = new XMLHttpRequest(); }
- else
- { xhr = new ActiveXObject("Microsoft.XMLHTTP"); }
- xhr.open("GET","rails/info/properties",false);
- xhr.send("");
- info.innerHTML = xhr.responseText;
- info.style.display = 'block'
- }
- </script>
- </head>
- <body>
- <div id="page">
- <div id="sidebar">
- <ul id="sidebar-items">
- <li>
- <h3>Browse the documentation</h3>
- <ul class="links">
- <li><a href="http://guides.rubyonrails.org/">Rails Guides</a></li>
- <li><a href="http://api.rubyonrails.org/">Rails API</a></li>
- <li><a href="http://www.ruby-doc.org/core/">Ruby core</a></li>
- <li><a href="http://www.ruby-doc.org/stdlib/">Ruby standard library</a></li>
- </ul>
- </li>
- </ul>
- </div>
-
- <div id="content">
- <div id="header">
- <h1>Welcome aboard</h1>
- <h2>You&rsquo;re riding Ruby on Rails!</h2>
- </div>
-
- <div id="about">
- <h3><a href="rails/info/properties" onclick="about(); return false">About your application&rsquo;s environment</a></h3>
- <div id="about-content" style="display: none"></div>
- </div>
-
- <div id="getting-started">
- <h1>Getting started</h1>
- <h2>Here&rsquo;s how to get rolling:</h2>
-
- <ol>
- <li>
- <h2>Use <code>rails generate</code> to create your models and controllers</h2>
- <p>To see all available options, run it without parameters.</p>
- </li>
-
- <li>
- <h2>Set up a default route and remove <span class="filename">public/index.html</span></h2>
- <p>Routes are set up in <span class="filename">config/routes.rb</span>.</p>
- </li>
-
- <li>
- <h2>Create your database</h2>
- <p>Run <code>rake db:create</code> to create your database. If you're not using SQLite (the default), edit <span class="filename">config/database.yml</span> with your username and password.</p>
- </li>
- </ol>
- </div>
- </div>
-
- <div id="footer">&nbsp;</div>
- </div>
- </body>
-</html>
View
36 spec/requests/static_pages_spec.rb
@@ -2,45 +2,57 @@
describe "Static pages" do
+ let(:base_title) { "Ruby on Rails Tutorial Sample App" }
+
describe "Home page" do
it "should have the h1 'Sample App'" do
- visit '/static_pages/home'
+ visit root_path
page.should have_selector('h1', :text => 'Sample App')
end
it "should have the title 'Home'" do
- visit '/static_pages/home'
- page.should have_selector('title',
- :text => "Ruby on Rails Tutorial Sample App | Home")
+ visit root_path
+ page.should have_selector('title', :text => "#{base_title} | Home")
end
end
describe "Help page" do
it "should have the h1 'Help'" do
- visit '/static_pages/help'
+ visit help_path
page.should have_selector('h1', :text => 'Help')
end
it "should have the title 'Help'" do
- visit '/static_pages/help'
- page.should have_selector('title',
- :text => "Ruby on Rails Tutorial Sample App | Help")
+ visit help_path
+ page.should have_selector('title', :text => "#{base_title} | Help")
end
end
describe "About page" do
it "should have the h1 'About'" do
- visit '/static_pages/about'
+ visit about_path
page.should have_selector('h1', :text => 'About Us')
end
it "should have the title 'About Us'" do
- visit '/static_pages/about'
- page.should have_selector('title',
- :text => "Ruby on Rails Tutorial Sample App | About Us")
+ visit about_path
+ page.should have_selector('title', :text => "#{base_title} | About Us")
+ end
+ end
+
+ describe "Contact page" do
+
+ it "should have the h1 'Contact'" do
+ visit contact_path
+ page.should have_selector('h1', :text => 'Contact')
+ end
+
+ it "should have the title 'Contact'" do
+ visit contact_path
+ page.should have_selector('title', :text => "#{base_title} | Contact")
end
end
end
View
76 spec/spec_helper.rb
@@ -1,32 +1,46 @@
-# This file is copied to spec/ when you run 'rails generate rspec:install'
-ENV["RAILS_ENV"] ||= 'test'
-require File.expand_path("../../config/environment", __FILE__)
-require 'rspec/rails'
-require 'rspec/autorun'
-
-# Requires supporting ruby files with custom matchers and macros, etc,
-# in spec/support/ and its subdirectories.
-Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
-
-RSpec.configure do |config|
- # ## Mock Framework
- #
- # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
- #
- # config.mock_with :mocha
- # config.mock_with :flexmock
- # config.mock_with :rr
-
- # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
- config.fixture_path = "#{::Rails.root}/spec/fixtures"
-
- # 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.
- config.use_transactional_fixtures = true
-
- # If true, the base class of anonymous controllers will be inferred
- # automatically. This will be the default behavior in future versions of
- # rspec-rails.
- config.infer_base_class_for_anonymous_controllers = false
+require 'rubygems'
+require 'spork'
+
+Spork.prefork do
+ # Loading more in this block will cause your tests to run faster. However,
+ # if you change any configuration or code from libraries loaded here, you'll
+ # need to restart spork for it take effect.
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
+ ENV["RAILS_ENV"] ||= 'test'
+ require File.expand_path("../../config/environment", __FILE__)
+ require 'rspec/rails'
+ require 'rspec/autorun'
+
+ # Requires supporting ruby files with custom matchers and macros, etc,
+ # in spec/support/ and its subdirectories.
+ Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
+
+ RSpec.configure do |config|
+ # == Mock Framework
+ #
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
+ #
+ # config.mock_with :mocha
+ # config.mock_with :flexmock
+ # config.mock_with :rr
+ config.mock_with :rspec
+
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
+
+ # 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.
+ config.use_transactional_fixtures = true
+
+ # If true, the base class of anonymous controllers will be inferred
+ # automatically. This will be the default behavior in future versions of
+ # rspec-rails.
+ config.infer_base_class_for_anonymous_controllers = false
+ end
+end
+
+Spork.each_run do
+ # This code will be run each time you run your specs.
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.