Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Finish layout and routes

  • Loading branch information...
commit 96572a4b8bdbc4f33ba67c320c0ae82fd7f1f780 1 parent a8c0d62
@jholton authored
View
2  app/assets/stylesheets/custom.css.scss
@@ -99,4 +99,4 @@ footer {
margin-left: 10px;
}
}
-}
+}
View
18 app/views/static_pages/home.html.erb
@@ -1,13 +1,13 @@
<div class="center hero-unit">
- <h1>Welcome to the Sample App</h1>
+ <h1>Welcome to the Sample App</h1>
- <h2>
- This is the home page for the
- <a href="http://railstutorial.org/">Ruby on Rails Tutorial</a>
- sample application.
- </h2>
+ <h2>
+ This is the home page for the
+ <a href="http://railstutorial.org/">Ruby on Rails Tutorial</a>
+ sample application.
+ </h2>
- <%= link_to "Sign up now!", signup_path, class: "btn btn-large btn-primary" %>
- </div>
+ <%= link_to "Sign up now!", signup_path, class: "btn btn-large btn-primary" %>
+</div>
- <%= link_to image_tag("rails.png", alt: "Rails"), 'http://rubyonrails.org/' %>
+<%= link_to image_tag("rails.png", alt: "Rails"), 'http://rubyonrails.org/' %>
View
5 app/views/users/new.html.erb
@@ -1,2 +1,3 @@
-<h1>Users#new</h1>
-<p>Find me in app/views/users/new.html.erb</p>
+<% provide(:title, 'Sign up') %>
+<h1>Sign up</h1>
+<p>Find me in app/views/users/new.html.erb</p>
View
67 config/application.rb
@@ -1,11 +1,74 @@
+# require File.expand_path('../boot', __FILE__)
+
+# require 'rails/all'
+# Bundler.require(:default, Rails.env) if defined?(Bundler)
+
+# module SampleApp
+# class Application < Rails::Application
+# config.encoding = "utf-8"
+# config.filter_parameters += [:password]
+# end
+# end
+
require File.expand_path('../boot', __FILE__)
require 'rails/all'
-Bundler.require(:default, Rails.env) if defined?(Bundler)
+
+if defined?(Bundler)
+ # If you precompile assets before deploying to production, use this line
+ Bundler.require(*Rails.groups(:assets => %w(development test)))
+ # If you want your assets lazily compiled in production, use this line
+ # Bundler.require(:default, :assets, Rails.env)
+end
module SampleApp
class Application < Rails::Application
+ # Settings in config/environments/* take precedence over those specified here.
+ # Application configuration should go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded.
+
+ # Custom directories with classes and modules you want to be autoloadable.
+ # config.autoload_paths += %W(#{config.root}/extras)
+
+ # Only load the plugins named here, in the order given (default is alphabetical).
+ # :all can be used as a placeholder for all plugins not explicitly named.
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
+
+ # Activate observers that should always be running.
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
+
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
+ # config.time_zone = 'Central Time (US & Canada)'
+
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
+ # config.i18n.default_locale = :de
+
+ # Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"
+
+ # Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]
+
+ # Enable escaping HTML in JSON.
+ config.active_support.escape_html_entities_in_json = true
+
+ # Use SQL instead of Active Record's schema dumper when creating the database.
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
+ # like if you have constraints or database-specific column types
+ # config.active_record.schema_format = :sql
+
+ # Enforce whitelist mode for mass assignment.
+ # This will create an empty whitelist of attributes available for mass-assignment for all models
+ # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
+ # parameters by using an attr_accessible or attr_protected declaration.
+ config.active_record.whitelist_attributes = true
+
+ # Enable the asset pipeline
+ config.assets.enabled = true
+
+ # Version of your assets, change this if you want to expire all your assets
+ config.assets.version = '1.0'
end
-end
+end
View
1  config/environments/development.rb
@@ -34,4 +34,5 @@
# Expands the lines which load the assets
config.assets.debug = true
+ config.serve_static_assets = true
end
View
2  config/routes.rb
@@ -2,11 +2,11 @@
get "users/new"
root to: 'static_pages#home'
+ match '/signup', to: 'users#new'
match '/help', to: 'static_pages#help'
match '/about', to: 'static_pages#about'
match '/contact', to: 'static_pages#contact'
- match '/', to: 'static_pages#home'
# The priority is based upon order of creation:
# first created -> highest priority.
View
18 spec/helpers/application_helper_spec.rb
@@ -0,0 +1,18 @@
+require 'spec_helper'
+
+describe ApplicationHelper do
+
+ describe "full_title" do
+ it "should include the page title" do
+ full_title("foo").should =~ /foo/
+ end
+
+ it "should include the base title" do
+ full_title("foo").should =~ /^Ruby on Rails Tutorial Sample App/
+ end
+
+ it "should not include a bar for the home page" do
+ full_title("").should_not =~ /\|/
+ end
+ end
+end
View
15 spec/requests/static_pages_spec.rb
@@ -32,4 +32,19 @@
it { should have_selector('h1', text: 'Contact') }
it { should have_selector('title', text: full_title('Contact')) }
end
+
+ it "should have the right links on the layout" do
+ visit root_path
+ click_link "About"
+ page.should have_selector 'title', text: full_title('About Us')
+ click_link "Help"
+ page.should # fill in
+ click_link "Contact"
+ page.should # fill in
+ click_link "Home"
+ click_link "Sign up now!"
+ page.should # fill in
+ click_link "sample app"
+ page.should # fill in
+ end
end
View
18 spec/requests/user_pages_spec.rb
@@ -1,11 +1,13 @@
require 'spec_helper'
-describe "UserPages" do
- describe "GET /user_pages" do
- it "works! (now write some real specs)" do
- # Run the generator again with the --webrat flag if you want to use webrat methods/matchers
- get user_pages_index_path
- response.status.should be(200)
- end
+describe "User pages" do
+
+ subject { page }
+
+ describe "signup page" do
+ before { visit signup_path }
+
+ it { should have_selector('h1', text: 'Sign up') }
+ it { should have_selector('title', text: full_title('Sign up')) }
end
-end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.