├── .gitignore
├── .rspec
├── CHANGELOG
├── Gemfile
├── README.md
├── Rakefile
├── bootstrap_helper.gemspec
├── config
└── initializers
│ ├── simple_form.rb
│ └── will_paginate.rb
├── example
└── application.html.erb
├── lib
├── bootstrap_helper.rb
└── bootstrap_helper
│ ├── breadcrumb.rb
│ ├── engine.rb
│ ├── helper.rb
│ ├── railtie.rb
│ └── version.rb
└── spec
├── dummy
├── .rspec
├── README.rdoc
├── Rakefile
├── app
│ ├── assets
│ │ ├── javascripts
│ │ │ └── application.js
│ │ └── stylesheets
│ │ │ └── application.css
│ ├── controllers
│ │ ├── application_controller.rb
│ │ └── welcome_controller.rb
│ ├── helpers
│ │ └── application_helper.rb
│ ├── mailers
│ │ └── .gitkeep
│ ├── models
│ │ └── .gitkeep
│ └── views
│ │ ├── layouts
│ │ └── application.html.erb
│ │ └── welcome
│ │ └── index.html.erb
├── config.ru
├── config
│ ├── application.rb
│ ├── boot.rb
│ ├── database.yml
│ ├── environment.rb
│ ├── environments
│ │ ├── development.rb
│ │ ├── production.rb
│ │ └── test.rb
│ ├── initializers
│ │ ├── backtrace_silencers.rb
│ │ ├── inflections.rb
│ │ ├── mime_types.rb
│ │ ├── secret_token.rb
│ │ ├── session_store.rb
│ │ └── wrap_parameters.rb
│ ├── locales
│ │ └── en.yml
│ └── routes.rb
├── db
│ └── test.sqlite3
├── lib
│ └── assets
│ │ └── .gitkeep
├── log
│ ├── .gitkeep
│ ├── development.log
│ └── test.log
├── public
│ ├── 404.html
│ ├── 422.html
│ ├── 500.html
│ └── favicon.ico
└── script
│ └── rails
├── helpers
└── application_helper_spec.rb
├── integration
└── view_homepage_spec.rb
└── spec_helper.rb
/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | .bundle
4 | .config
5 | .yardoc
6 | Gemfile.lock
7 | InstalledFiles
8 | _yardoc
9 | coverage
10 | doc/
11 | lib/bundler/man
12 | pkg
13 | rdoc
14 | spec/reports
15 | test/tmp
16 | test/version_tmp
17 | tmp
18 |
--------------------------------------------------------------------------------
/.rspec:
--------------------------------------------------------------------------------
1 | --color
2 |
--------------------------------------------------------------------------------
/CHANGELOG:
--------------------------------------------------------------------------------
1 | * add ibutton feature
2 | * Releaase 3.2.2.0 & 4.2.2.0
3 | * 2.1.2.1 add if defined?(SimpleForm)
4 | * 2.1.2 fix breadcurm should be plaintext item
5 | * 2.1.1 fix simple_form decrappted warning
6 | * 2.1.0 add will_paginate & simple_form template initializer for bootstrap
7 | * 2.0.0.3 fix notice_mesage
8 |
9 | * 4.2.2.3 upgrade to Rails 4 official
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source 'http://rubygems.org'
2 |
3 | # Specify your gem's dependencies in bootstrap-rails.gemspec
4 | gemspec
5 |
6 |
7 |
8 | gem "simple_form", "3.0.0.rc"
9 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Twitter Bootstrap Helper for Rails 3
2 |
3 | Bootstrap is a toolkit from Twitter designed to kickstart development of webapps and sites. It includes base CSS and HTML for typography, forms, buttons, tables, grids, navigation, and more.
4 |
5 | bootstrap_helper auto generates Bootstrap HTML codes.
6 |
7 | ## Rails 3.1
8 |
9 | include Bootstrap Helper in Gemfile;
10 |
11 | ``` ruby
12 | gem 'bootstrap_helper', '3.2.2.0'
13 | ```
14 |
15 | ## Rails 4.0+
16 |
17 | or you can install from latest build;
18 |
19 | ``` ruby
20 | gem 'bootstrap_helper', '4.2.2.1'
21 | ```
22 |
23 | ## USAGE
24 |
25 |
26 | ### render_page_title
27 |
28 | #### SETUP
29 |
30 | edit your `config/application.rb `
31 |
32 | SITE_NAME = "YOUR SITE NAME"
33 |
34 | in `application.html.erb`, replace `
` with
35 |
36 | <%= render_page_title %>
37 |
38 | define page title in your action
39 |
40 | def index
41 | @page_title = "Posts Index"
42 | end
43 |
44 | will render
45 |
46 | Posts Index | YOUR SITE NAME
47 |
48 | ### render_list
49 |
50 | render_list generates ul & li, auto append: "first", "last" class . If link matches current controller and acttion, it will auto add "active" class. Perfact for "menu"
51 |
52 | <%= render_list :class => "nav" do |li|
53 | li << link_to(t("menu.topics"), topics_path)
54 | li << link_to(t("menu.wiki"), wikis_path )
55 | li << link_to(t("menu.sites"), sites_path )
56 | li << link_to(t("menu.users"), users_path)
57 | end %>
58 |
59 | ### render_body_tag
60 |
61 | in `application.html.erb`, replace `` with
62 |
63 | <%= render_body_tag %>
64 |
65 | render_body_tag auto inserts "controller name" & "action name" in to body class, and generates IE conditional comment.
66 |
67 |
69 |
71 |
72 |
73 |
74 |
75 | ### breadcrumb
76 |
77 | in `application.html.erb`, place this helper
78 |
79 | <%= render_breadcrumb %>
80 |
81 | drop breadcrumb in your action
82 |
83 | def show
84 | @post = Posts.find(params[:id])
85 | drop_breadcrumb("Posts", posts_path)
86 | drop_breadcrumb(@post.title)
87 | end
88 |
89 | it will generate breadcrumb with link for you
90 |
91 | Home / Post / YourPostTitle
92 |
93 | ### notice_message
94 |
95 | in `application.html.erb`, place this helper
96 |
97 | <%= notice_message %>
98 |
99 | write notice message in your action, will generate bootstrap style notice message
100 |
101 | def create
102 | # ….
103 | redirect_to posts_path, :notice => "Create Success!"
104 | end
105 |
106 | def update
107 | redirect_to root_path, :flash => { :warning => "Update Success!" }
108 | end
109 | def no_permission
110 | redirect_to root_path, :flash => { :error => "no permission" }
111 | end
112 |
113 |
114 |
115 | ### Pagination
116 |
117 | Support `will_paginate`, `~> 3.0.3`
118 |
119 | ## Markup Example
120 |
121 | see [example](bootstrap-helper/tree/master/example/application.html.erb)
122 |
123 | ## Other
124 |
125 | ### Form
126 |
127 | Support `simple_form`, `~> 2.0.2`
128 |
129 | You can use simple_form 2.0 with bootstrap form template
130 |
131 | ```
132 | <%= simple_form_for @article do |f| %>
133 | <%= f.input :title, :input_html => {:class => "xxlarge"} , :hint => "this is post title" %>
134 | <% end >
135 | ```
136 |
137 | ## Thanks
138 |
139 | Thanks Twitter for Bootstrap
140 |
141 | Thanks Handlino for HandicraftHelper
142 |
143 | ## License
144 |
145 | Copyright (C) 2011 by xdite
146 |
147 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
148 |
149 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
150 |
151 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env rake
2 | require "bundler/gem_tasks"
3 |
4 | desc "Update Twitter's Bootstrap"
5 | task "update-twitter" do
6 | boostrap_version = "1.3.0"
7 | Dir["vendor/assets/stylesheets/*.*"].each {|f| FileUtils.rm(f)}
8 | Dir["vendor/twitter/lib/*.scss"].each do |file|
9 | cp file, "vendor/assets/stylesheets/", :verbose => true
10 | end
11 | bootstrap_scss = File.read("vendor/assets/stylesheets/bootstrap.scss")
12 |
13 | bootstrap_scss.gsub!(/@VERSION/, "v#{boostrap_version}")
14 | bootstrap_scss.gsub!(/^.*@DATE.*/, " *")
15 |
16 | File.open("vendor/assets/stylesheets/bootstrap.scss", "w") do |f|
17 | f.write(bootstrap_scss)
18 | end
19 |
20 | Dir["vendor/assets/javascripts/*.*"].each {|f| FileUtils.rm(f)}
21 | js_files = Dir["vendor/twitter/js/*.js"].map()
22 | js_files.each do |file|
23 | cp file, "vendor/assets/javascripts/", :verbose => true
24 | end
25 |
26 | js_priorities = {}
27 | js_files.each {|f| js_priorities[File.basename(f)] = 0}
28 |
29 | # popover depend on twipsy
30 | js_priorities["bootstrap-twipsy.js"] = 1
31 | js_priorities["bootstrap-popover.js"] = 2
32 |
33 | js_list = js_priorities.to_a.sort {|a,b| a[1] <=> b[1]}.map{|p| p[0]}
34 |
35 | File.open("vendor/assets/javascripts/bootstrap.js", "w") do |f|
36 | f.write "// Bootstrap v#{boostrap_version}\n"
37 | js_list.each do |js|
38 | f.write "//= require #{js}\n"
39 | end
40 | end
41 | end
--------------------------------------------------------------------------------
/bootstrap_helper.gemspec:
--------------------------------------------------------------------------------
1 | # -*- encoding: utf-8 -*-
2 | require File.expand_path('../lib/bootstrap_helper/version', __FILE__)
3 |
4 | Gem::Specification.new do |gem|
5 | gem.authors = ["xdite"]
6 | gem.email = ["xuite.joke@gmail.com"]
7 | gem.description = %q{Twitter Bootstrap HTML Helper}
8 | gem.summary = %q{Twitter Bootstrap HTML Helper}
9 | gem.homepage = "https://github.com/xdite/bootstrap-helper"
10 |
11 | gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12 | gem.files = `git ls-files`.split("\n")
13 | gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14 | gem.name = "bootstrap_helper"
15 | gem.require_paths = ["lib"]
16 | gem.version = BootstrapHelper::Rails::VERSION
17 |
18 | gem.add_dependency "railties", ">= 4.0.0"
19 | gem.add_dependency "thor", "~> 0.14"
20 | gem.add_dependency "will_paginate", '>= 3.0.3'
21 | gem.add_development_dependency("rspec-rails")
22 | gem.add_development_dependency("capybara", ">= 0.4.0")
23 | gem.add_development_dependency("sqlite3")
24 | gem.add_development_dependency "bundler", ">= 1.3.0"
25 | gem.add_development_dependency "rails", ">= 4.0.0"
26 | end
27 |
28 |
--------------------------------------------------------------------------------
/config/initializers/simple_form.rb:
--------------------------------------------------------------------------------
1 | # Use this setup block to configure all options available in SimpleForm.
2 | if defined?(SimpleForm)
3 | SimpleForm.setup do |config|
4 | # Wrappers are used by the form builder to generate a
5 | # complete input. You can remove any component from the
6 | # wrapper, change the order or even add your own to the
7 | # stack. The options given below are used to wrap the
8 | # whole input.
9 | config.wrappers :default, :class => :input,
10 | :hint_class => :field_with_hint, :error_class => :field_with_errors do |b|
11 | ## Extensions enabled by default
12 | # Any of these extensions can be disabled for a
13 | # given input by passing: `f.input EXTENSION_NAME => false`.
14 | # You can make any of these extensions optional by
15 | # renaming `b.use` to `b.optional`.
16 |
17 | # Determines whether to use HTML5 (:email, :url, ...)
18 | # and required attributes
19 | b.use :html5
20 |
21 | # Calculates placeholders automatically from I18n
22 | # You can also pass a string as f.input :placeholder => "Placeholder"
23 | b.use :placeholder
24 |
25 | ## Optional extensions
26 | # They are disabled unless you pass `f.input EXTENSION_NAME => :lookup`
27 | # to the input. If so, they will retrieve the values from the model
28 | # if any exists. If you want to enable the lookup for any of those
29 | # extensions by default, you can change `b.optional` to `b.use`.
30 |
31 | # Calculates maxlength from length validations for string inputs
32 | b.optional :maxlength
33 |
34 | # Calculates pattern from format validations for string inputs
35 | b.optional :pattern
36 |
37 | # Calculates min and max from length validations for numeric inputs
38 | b.optional :min_max
39 |
40 | # Calculates readonly automatically from readonly attributes
41 | b.optional :readonly
42 |
43 | ## Inputs
44 | b.use :label_input
45 | b.use :hint, :wrap_with => { :tag => :span, :class => :hint }
46 | b.use :error, :wrap_with => { :tag => :span, :class => :error }
47 | end
48 |
49 | config.wrappers :bootstrap, :tag => 'div', :class => 'control-group', :error_class => 'error' do |b|
50 | b.use :html5
51 | b.use :placeholder
52 | b.use :label
53 | b.wrapper :tag => 'div', :class => 'controls' do |ba|
54 | ba.use :input
55 | ba.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
56 | ba.use :hint, :wrap_with => { :tag => 'p', :class => 'help-block' }
57 | end
58 | end
59 |
60 | config.wrappers :prepend, :tag => 'div', :class => "control-group", :error_class => 'error' do |b|
61 | b.use :html5
62 | b.use :placeholder
63 | b.use :label
64 | b.wrapper :tag => 'div', :class => 'controls' do |input|
65 | input.wrapper :tag => 'div', :class => 'input-prepend' do |prepend|
66 | prepend.use :input
67 | end
68 | input.use :hint, :wrap_with => { :tag => 'span', :class => 'help-block' }
69 | input.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
70 | end
71 | end
72 |
73 | config.wrappers :append, :tag => 'div', :class => "control-group", :error_class => 'error' do |b|
74 | b.use :html5
75 | b.use :placeholder
76 | b.use :label
77 | b.wrapper :tag => 'div', :class => 'controls' do |input|
78 | input.wrapper :tag => 'div', :class => 'input-append' do |append|
79 | append.use :input
80 | end
81 | input.use :hint, :wrap_with => { :tag => 'span', :class => 'help-block' }
82 | input.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
83 | end
84 | end
85 |
86 | # Wrappers for forms and inputs using the Twitter Bootstrap toolkit.
87 | # Check the Bootstrap docs (http://twitter.github.com/bootstrap)
88 | # to learn about the different styles for forms and inputs,
89 | # buttons and other elements.
90 | config.default_wrapper = :bootstrap
91 |
92 | # Define the way to render check boxes / radio buttons with labels.
93 | # Defaults to :nested for bootstrap config.
94 | # :inline => input + label
95 | # :nested => label > input
96 | config.boolean_style = :nested
97 |
98 | # Default class for buttons
99 | config.button_class = 'btn'
100 |
101 | # Method used to tidy up errors. Specify any Rails Array method.
102 | # :first lists the first message for each field.
103 | # Use :to_sentence to list all errors for each field.
104 | # config.error_method = :first
105 |
106 | # Default tag used for error notification helper.
107 | config.error_notification_tag = :div
108 |
109 | # CSS class to add for error notification helper.
110 | config.error_notification_class = 'alert alert-error'
111 |
112 | # ID to add for error notification helper.
113 | # config.error_notification_id = nil
114 |
115 | # Series of attempts to detect a default label method for collection.
116 | # config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
117 |
118 | # Series of attempts to detect a default value method for collection.
119 | # config.collection_value_methods = [ :id, :to_s ]
120 |
121 | # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
122 | # config.collection_wrapper_tag = nil
123 |
124 | # You can define the class to use on all collection wrappers. Defaulting to none.
125 | # config.collection_wrapper_class = nil
126 |
127 | # You can wrap each item in a collection of radio/check boxes with a tag,
128 | # defaulting to :span. Please note that when using :boolean_style = :nested,
129 | # SimpleForm will force this option to be a label.
130 | # config.item_wrapper_tag = :span
131 |
132 | # You can define a class to use in all item wrappers. Defaulting to none.
133 | # config.item_wrapper_class = nil
134 |
135 | # How the label text should be generated altogether with the required text.
136 | # config.label_text = lambda { |label, required| "#{required} #{label}" }
137 |
138 | # You can define the class to use on all labels. Default is nil.
139 | config.label_class = 'control-label'
140 |
141 | # You can define the class to use on all forms. Default is simple_form.
142 | # config.form_class = :simple_form
143 |
144 | # You can define which elements should obtain additional classes
145 | # config.generate_additional_classes_for = [:wrapper, :label, :input]
146 |
147 | # Whether attributes are required by default (or not). Default is true.
148 | # config.required_by_default = true
149 |
150 | # Tell browsers whether to use default HTML5 validations (novalidate option).
151 | # Default is enabled.
152 | config.browser_validations = false
153 |
154 | # Collection of methods to detect if a file type was given.
155 | # config.file_methods = [ :mounted_as, :file?, :public_filename ]
156 |
157 | # Custom mappings for input types. This should be a hash containing a regexp
158 | # to match as key, and the input type that will be used when the field name
159 | # matches the regexp as value.
160 | # config.input_mappings = { /count/ => :integer }
161 |
162 | # Default priority for time_zone inputs.
163 | # config.time_zone_priority = nil
164 |
165 | # Default priority for country inputs.
166 | # config.country_priority = nil
167 |
168 | # Default size for text inputs.
169 | # config.default_input_size = 50
170 |
171 | # When false, do not use translations for labels.
172 | # config.translate_labels = true
173 |
174 | # Automatically discover new inputs in Rails' autoload path.
175 | # config.inputs_discovery = true
176 |
177 | # Cache SimpleForm inputs discovery
178 | # config.cache_discovery = !Rails.env.development?
179 | end
180 | end
181 |
--------------------------------------------------------------------------------
/config/initializers/will_paginate.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | if defined?(WillPaginate)
3 | module WillPaginate
4 | module ActionView
5 | def will_paginate(collection = nil, options = {})
6 | options[:renderer] ||= BootstrapLinkRenderer
7 | super.try :html_safe
8 | end
9 |
10 | class BootstrapLinkRenderer < LinkRenderer
11 | protected
12 |
13 | def html_container(html)
14 | tag :div, tag(:ul, html), container_attributes
15 | end
16 |
17 | def page_number(page)
18 | tag :li, link(page, page, :rel => rel_value(page)), :class => ('active' if page == current_page)
19 | end
20 |
21 | def previous_or_next_page(page, text, classname)
22 | tag :li, link(text, page || '#'), :class => [classname[0..3], classname, ('disabled' unless page)].join(' ')
23 | end
24 |
25 | def gap
26 | tag :li, link(super, '#'), :class => 'disabled'
27 | end
28 | end
29 | end
30 | end
31 | end
32 |
--------------------------------------------------------------------------------
/example/application.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | <%= render_page_title %>
5 | <%= csrf_meta_tag %>
6 | <%= stylesheet_link_tag "application"%>
7 |
8 | <%= render_body_tag %>
9 |
10 |
11 |
12 |
15 | <%= render_list :class => "nav" do |li|
16 | li << link_to(t("menu.topics"), topics_path)
17 | li << link_to(t("menu.wiki"), wikis_path )
18 | li << link_to(t("menu.sites"), sites_path )
19 | li << link_to(t("menu.users"), users_path)
20 | end %>
21 | <%= render "common/search_form" %>
22 | <%= render "common/user_navigation" %>
23 |
24 |
25 |
26 |
27 | <%= render_breadcrumb %>
28 |
29 | <%= notice_message %>
30 | <%= yield %>
31 |
32 |
33 |
38 |
39 | <%= javascript_include_tag "application" %>
40 |
41 | <%= yield :page_specific_javascripts %>
42 |
43 | <%= render :partial => "common/facebook_js" %>
44 | <%= render :partial => "common/google_analytics"%>
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/lib/bootstrap_helper.rb:
--------------------------------------------------------------------------------
1 | require "rails"
2 | require "bootstrap_helper/version"
3 | require "action_view"
4 |
5 | module BootstrapHelper
6 | module Rails
7 | if ::Rails.version < "3.1"
8 | require "bootstrap_helper/railtie"
9 | else
10 | require "bootstrap_helper/engine"
11 | end
12 | end
13 | end
--------------------------------------------------------------------------------
/lib/bootstrap_helper/breadcrumb.rb:
--------------------------------------------------------------------------------
1 | module BootstrapHelper
2 | module Breadcrumb
3 | def self.included(receiver)
4 | receiver.extend ClassMethods
5 | receiver.send :include, InstanceMethods
6 | receiver.send :helper, Helpers
7 | receiver.send :before_filter, :set_breadcrumbs
8 | end
9 |
10 | module ClassMethods
11 |
12 | end
13 |
14 | module InstanceMethods
15 | protected
16 |
17 | def set_breadcrumbs
18 | @breadcrumbs = ["Home".html_safe]
19 | end
20 |
21 | def drop_breadcrumb(title=nil, url=nil)
22 | title ||= @page_title
23 |
24 | if title && url
25 | @breadcrumbs.push("#{title}".html_safe)
26 | elsif title
27 | @breadcrumbs.push("#{title}".html_safe)
28 | end
29 | end
30 |
31 | def drop_page_title(title)
32 | @page_title = title
33 | return @page_title
34 | end
35 |
36 | def no_breadcrumbs
37 | @breadcrumbs = []
38 | end
39 | end
40 |
41 | module Helpers
42 |
43 | def render_breadcrumb
44 | return "" if @breadcrumbs.size <= 0
45 | prefix = "".html_safe
46 | crumb = "".html_safe
47 |
48 | @breadcrumbs.each_with_index do |c, i|
49 | breadcrumb_class = []
50 | breadcrumb_class << "first" if i == 0
51 | breadcrumb_class << "last active" if i == (@breadcrumbs.length - 1)
52 |
53 | if i == (@breadcrumbs.length - 1)
54 | breadcrumb_content = c
55 | else
56 | breadcrumb_content = c + " " + content_tag(:span, "/", :class => "divider")
57 | end
58 |
59 | crumb += content_tag(:li, breadcrumb_content ,:class => breadcrumb_class ) + "\n"
60 | end
61 | return prefix + content_tag(:ul, crumb, :class => "breadcrumb menu clearfix")
62 | end
63 | end
64 | end
65 |
66 | end
67 |
--------------------------------------------------------------------------------
/lib/bootstrap_helper/engine.rb:
--------------------------------------------------------------------------------
1 | require "bootstrap_helper/helper"
2 | require "bootstrap_helper/breadcrumb"
3 |
4 | module BootstrapHelper
5 | module Rails
6 | class Engine < ::Rails::Engine
7 | initializer "bootstrap_helper.view_helpers" do
8 | ActionView::Base.send :include, BootstrapHelper::Helper
9 |
10 | end
11 |
12 | config.to_prepare do
13 | ActionController::Base.send :include, BootstrapHelper::Breadcrumb
14 | end
15 |
16 | end
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/lib/bootstrap_helper/helper.rb:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 | module BootstrapHelper
3 |
4 | module Helper
5 | def yield_or_default(message, default_message = "")
6 | message.nil? ? default_message : message
7 | end
8 |
9 |
10 | def render_page_title
11 | title = @page_title ? "#{SITE_NAME} | #{@page_title}" : SITE_NAME rescue "SITE_NAME"
12 | content_tag("title", title, nil, false)
13 | end
14 |
15 | def render_body_tag
16 | class_attribute = ["#{controller_name}-controller","#{action_name}-action"].join(" ")
17 | id_attribute = (@body_id)? " id=\"#{@body_id}-page\"" : ""
18 |
19 | raw(%Q|
21 |
23 |
24 |
25 | |)
26 |
27 | end
28 |
29 |
30 | def notice_message
31 | flash_messages = []
32 | flash.each do |type, message|
33 | type = :success if type == :notice
34 | type = :danger if type == :alert
35 | text = content_tag(:div, link_to("x", "#", :class => "close", "data-dismiss" => "alert") + message, :class => "alert fade in alert-#{type}")
36 | flash_messages << text if message
37 | end
38 | flash_messages.join("\n").html_safe
39 | end
40 |
41 |
42 | def s(html)
43 | sanitize( html, :tags => %w(table thead tbody tr td th ol ul li div span font img sup sub br hr a pre p h1 h2 h3 h4 h5 h6), :attributes => %w(style src href size color) )
44 | end
45 |
46 |
47 | def ibutton(text, path, options = {})
48 |
49 | color_btn_class = ["btn-primary", "btn-danger", "btn-info" , "btn-warning", "btn-success", "btn-inverse"]
50 |
51 | class_name = (options[:class].present?)? options[:class] : ""
52 | icon_class = ""
53 |
54 | if options[:iclass].present?
55 | icon_class = options[:iclass]
56 | icon_class << " icon-white" if !(color_btn_class & class_name.split(" ")).empty?
57 | options.delete(:iclass)
58 | end
59 | link_to path, options do
60 | content_tag(:i, "", :class => icon_class) + content_tag(:span, " #{text}" )
61 | end
62 | end
63 |
64 | def render_table(rows, renderrers, table_options = {})
65 | table_options = {
66 | :has_header => true,
67 | :has_row_info => false,
68 | :caption => "",
69 | :id => nil,
70 | :class_name => "auto",
71 | :blank_message => "No results available."
72 | }.merge(table_options)
73 |
74 | table_tag_options = table_options[:id] ? { :id => table_options[:id], :class => table_options[:class_name] } : { :class => table_options[:class_name] }
75 |
76 | table = TagNode.new('table', table_tag_options)
77 |
78 | if !table_options[:caption].blank?
79 | table << caption = TagNode.new(:caption)
80 | caption << table_options[:caption]
81 | end
82 |
83 | if table_options[:has_header] == true
84 | table << thead = TagNode.new(:thead)
85 | thead << tr = TagNode.new(:tr, :class => 'odd')
86 |
87 | renderrers.each do |renderrer|
88 | tr << th = TagNode.new(:th)
89 | th << renderrer[0]
90 | end
91 | end
92 |
93 | table << tbody = TagNode.new('tbody')
94 | row_info = {}
95 | row_info[:total] = rows.length
96 | rows.each_with_index do |row,i|
97 | row_info[:current] = i
98 | tbody << tr = TagNode.new('tr', :class => cycle("","odd") )
99 | renderrers.each do |renderrer|
100 | tr << td = TagNode.new('td')
101 |
102 | if renderrer[1].class == Proc
103 | if table_options[:has_row_info] == true
104 | td << renderrer[1].call(row, row_info)
105 | else
106 | td << renderrer[1].call(row)
107 | end
108 | else
109 | td << renderrer[1]
110 | end
111 | end
112 | end
113 |
114 | if rows.length <= 0 && table_options[:blank_message] != false
115 | tbody << tr = TagNode.new('tr', :class => "no-record" )
116 | tr << td = TagNode.new('td', :colspan => renderrers.length)
117 | td << table_options[:blank_message]
118 | end
119 |
120 | return table.to_s
121 | end
122 |
123 | # .current will be added to current action, but if you want to add .current to another link, you can set @current = ['/other_link']
124 | # TODO: hot about render_list( *args )
125 | def render_list(list=[], options={})
126 | if list.is_a? Hash
127 | options = list
128 | list = []
129 | end
130 |
131 | yield(list) if block_given?
132 |
133 | list_type ||= "ul"
134 |
135 | if options[:type]
136 | if ["ul", "dl", "ol"].include?(options[:type])
137 | list_type = options[:type]
138 | end
139 | end
140 |
141 | ul = TagNode.new(list_type, :id => options[:id], :class => options[:class] )
142 | ul.addClass("unstyled") if (options[:type] && options[:type] == "unstyled")
143 |
144 | list.each_with_index do |content, i|
145 | item_class = []
146 | item_class << "first" if i == 0
147 | item_class << "last" if i == (list.length - 1)
148 |
149 | item_content = content
150 | item_options = {}
151 |
152 | if content.is_a? Array
153 | item_content = content[0]
154 | item_options = content[1]
155 | end
156 |
157 | if item_options[:class]
158 | item_class << item_options[:class]
159 | end
160 |
161 | link = item_content.match(/href=(["'])(.*?)(\1)/)[2] rescue nil
162 |
163 | if ( link && current_page?(link) ) || ( @current && @current.include?(link) )
164 | item_class << "active"
165 | end
166 |
167 | item_class = (item_class.empty?)? nil : item_class.join(" ")
168 | ul << li = TagNode.new('li', :class => item_class )
169 | li << item_content
170 | end
171 |
172 | return ul.to_s
173 | end
174 |
175 | # Composite pattern
176 | class TagNode
177 | include ActionView::Helpers::TagHelper
178 |
179 | def initialize(name, options = {})
180 | @name = name.to_s
181 | @attributes = options
182 | @children = []
183 | end
184 |
185 | def addClass(x)
186 | if @attributes[:class].blank?
187 | @attributes[:class] = x.to_s
188 | else
189 | @attributes[:class] = @attributes[:class] + " #{x}"
190 | end
191 | end
192 |
193 | def to_s
194 | value = @children.each { |c| c.to_s }.join
195 | content_tag(@name, value.to_s, @attributes, false)
196 | end
197 |
198 | def <<(tag_node)
199 | @children << tag_node
200 | end
201 | end
202 | end
203 |
204 | end
205 |
--------------------------------------------------------------------------------
/lib/bootstrap_helper/railtie.rb:
--------------------------------------------------------------------------------
1 | module BootstrapHelper
2 | module Rails
3 | class Railtie < ::Rails::Railtie
4 | end
5 | end
6 | end
--------------------------------------------------------------------------------
/lib/bootstrap_helper/version.rb:
--------------------------------------------------------------------------------
1 | module BootstrapHelper
2 | module Rails
3 | VERSION = "4.2.3"
4 | end
5 | end
--------------------------------------------------------------------------------
/spec/dummy/.rspec:
--------------------------------------------------------------------------------
1 | --color
2 |
--------------------------------------------------------------------------------
/spec/dummy/README.rdoc:
--------------------------------------------------------------------------------
1 | == Welcome to Rails
2 |
3 | Rails is a web-application framework that includes everything needed to create
4 | database-backed web applications according to the Model-View-Control pattern.
5 |
6 | This pattern splits the view (also called the presentation) into "dumb"
7 | templates that are primarily responsible for inserting pre-built data in between
8 | HTML tags. The model contains the "smart" domain objects (such as Account,
9 | Product, Person, Post) that holds all the business logic and knows how to
10 | persist themselves to a database. The controller handles the incoming requests
11 | (such as Save New Account, Update Product, Show Post) by manipulating the model
12 | and directing data to the view.
13 |
14 | In Rails, the model is handled by what's called an object-relational mapping
15 | layer entitled Active Record. This layer allows you to present the data from
16 | database rows as objects and embellish these data objects with business logic
17 | methods. You can read more about Active Record in
18 | link:files/vendor/rails/activerecord/README.html.
19 |
20 | The controller and view are handled by the Action Pack, which handles both
21 | layers by its two parts: Action View and Action Controller. These two layers
22 | are bundled in a single package due to their heavy interdependence. This is
23 | unlike the relationship between the Active Record and Action Pack that is much
24 | more separate. Each of these packages can be used independently outside of
25 | Rails. You can read more about Action Pack in
26 | link:files/vendor/rails/actionpack/README.html.
27 |
28 |
29 | == Getting Started
30 |
31 | 1. At the command prompt, create a new Rails application:
32 | rails new myapp (where myapp is the application name)
33 |
34 | 2. Change directory to myapp and start the web server:
35 | cd myapp; rails server (run with --help for options)
36 |
37 | 3. Go to http://localhost:3000/ and you'll see:
38 | "Welcome aboard: You're riding Ruby on Rails!"
39 |
40 | 4. Follow the guidelines to start developing your application. You can find
41 | the following resources handy:
42 |
43 | * The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
44 | * Ruby on Rails Tutorial Book: http://www.railstutorial.org/
45 |
46 |
47 | == Debugging Rails
48 |
49 | Sometimes your application goes wrong. Fortunately there are a lot of tools that
50 | will help you debug it and get it back on the rails.
51 |
52 | First area to check is the application log files. Have "tail -f" commands
53 | running on the server.log and development.log. Rails will automatically display
54 | debugging and runtime information to these files. Debugging info will also be
55 | shown in the browser on requests from 127.0.0.1.
56 |
57 | You can also log your own messages directly into the log file from your code
58 | using the Ruby logger class from inside your controllers. Example:
59 |
60 | class WeblogController < ActionController::Base
61 | def destroy
62 | @weblog = Weblog.find(params[:id])
63 | @weblog.destroy
64 | logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
65 | end
66 | end
67 |
68 | The result will be a message in your log file along the lines of:
69 |
70 | Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
71 |
72 | More information on how to use the logger is at http://www.ruby-doc.org/core/
73 |
74 | Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
75 | several books available online as well:
76 |
77 | * Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
78 | * Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
79 |
80 | These two books will bring you up to speed on the Ruby language and also on
81 | programming in general.
82 |
83 |
84 | == Debugger
85 |
86 | Debugger support is available through the debugger command when you start your
87 | Mongrel or WEBrick server with --debugger. This means that you can break out of
88 | execution at any point in the code, investigate and change the model, and then,
89 | resume execution! You need to install ruby-debug to run the server in debugging
90 | mode. With gems, use sudo gem install ruby-debug. Example:
91 |
92 | class WeblogController < ActionController::Base
93 | def index
94 | @posts = Post.all
95 | debugger
96 | end
97 | end
98 |
99 | So the controller will accept the action, run the first line, then present you
100 | with a IRB prompt in the server window. Here you can do things like:
101 |
102 | >> @posts.inspect
103 | => "[#nil, "body"=>nil, "id"=>"1"}>,
105 | #"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
107 | >> @posts.first.title = "hello from a debugger"
108 | => "hello from a debugger"
109 |
110 | ...and even better, you can examine how your runtime objects actually work:
111 |
112 | >> f = @posts.first
113 | => #nil, "body"=>nil, "id"=>"1"}>
114 | >> f.
115 | Display all 152 possibilities? (y or n)
116 |
117 | Finally, when you're ready to resume execution, you can enter "cont".
118 |
119 |
120 | == Console
121 |
122 | The console is a Ruby shell, which allows you to interact with your
123 | application's domain model. Here you'll have all parts of the application
124 | configured, just like it is when the application is running. You can inspect
125 | domain models, change values, and save to the database. Starting the script
126 | without arguments will launch it in the development environment.
127 |
128 | To start the console, run rails console from the application
129 | directory.
130 |
131 | Options:
132 |
133 | * Passing the -s, --sandbox argument will rollback any modifications
134 | made to the database.
135 | * Passing an environment name as an argument will load the corresponding
136 | environment. Example: rails console production.
137 |
138 | To reload your controllers and models after launching the console run
139 | reload!
140 |
141 | More information about irb can be found at:
142 | link:http://www.rubycentral.org/pickaxe/irb.html
143 |
144 |
145 | == dbconsole
146 |
147 | You can go to the command line of your database directly through rails
148 | dbconsole. You would be connected to the database with the credentials
149 | defined in database.yml. Starting the script without arguments will connect you
150 | to the development database. Passing an argument will connect you to a different
151 | database, like rails dbconsole production. Currently works for MySQL,
152 | PostgreSQL and SQLite 3.
153 |
154 | == Description of Contents
155 |
156 | The default directory structure of a generated Ruby on Rails application:
157 |
158 | |-- app
159 | | |-- assets
160 | | |-- images
161 | | |-- javascripts
162 | | `-- stylesheets
163 | | |-- controllers
164 | | |-- helpers
165 | | |-- mailers
166 | | |-- models
167 | | `-- views
168 | | `-- layouts
169 | |-- config
170 | | |-- environments
171 | | |-- initializers
172 | | `-- locales
173 | |-- db
174 | |-- doc
175 | |-- lib
176 | | `-- tasks
177 | |-- log
178 | |-- public
179 | |-- script
180 | |-- test
181 | | |-- fixtures
182 | | |-- functional
183 | | |-- integration
184 | | |-- performance
185 | | `-- unit
186 | |-- tmp
187 | | |-- cache
188 | | |-- pids
189 | | |-- sessions
190 | | `-- sockets
191 | `-- vendor
192 | |-- assets
193 | `-- stylesheets
194 | `-- plugins
195 |
196 | app
197 | Holds all the code that's specific to this particular application.
198 |
199 | app/assets
200 | Contains subdirectories for images, stylesheets, and JavaScript files.
201 |
202 | app/controllers
203 | Holds controllers that should be named like weblogs_controller.rb for
204 | automated URL mapping. All controllers should descend from
205 | ApplicationController which itself descends from ActionController::Base.
206 |
207 | app/models
208 | Holds models that should be named like post.rb. Models descend from
209 | ActiveRecord::Base by default.
210 |
211 | app/views
212 | Holds the template files for the view that should be named like
213 | weblogs/index.html.erb for the WeblogsController#index action. All views use
214 | eRuby syntax by default.
215 |
216 | app/views/layouts
217 | Holds the template files for layouts to be used with views. This models the
218 | common header/footer method of wrapping views. In your views, define a layout
219 | using the layout :default and create a file named default.html.erb.
220 | Inside default.html.erb, call <% yield %> to render the view using this
221 | layout.
222 |
223 | app/helpers
224 | Holds view helpers that should be named like weblogs_helper.rb. These are
225 | generated for you automatically when using generators for controllers.
226 | Helpers can be used to wrap functionality for your views into methods.
227 |
228 | config
229 | Configuration files for the Rails environment, the routing map, the database,
230 | and other dependencies.
231 |
232 | db
233 | Contains the database schema in schema.rb. db/migrate contains all the
234 | sequence of Migrations for your schema.
235 |
236 | doc
237 | This directory is where your application documentation will be stored when
238 | generated using rake doc:app
239 |
240 | lib
241 | Application specific libraries. Basically, any kind of custom code that
242 | doesn't belong under controllers, models, or helpers. This directory is in
243 | the load path.
244 |
245 | public
246 | The directory available for the web server. Also contains the dispatchers and the
247 | default HTML files. This should be set as the DOCUMENT_ROOT of your web
248 | server.
249 |
250 | script
251 | Helper scripts for automation and generation.
252 |
253 | test
254 | Unit and functional tests along with fixtures. When using the rails generate
255 | command, template test files will be generated for you and placed in this
256 | directory.
257 |
258 | vendor
259 | External libraries that the application depends on. Also includes the plugins
260 | subdirectory. If the app has frozen rails, those gems also go here, under
261 | vendor/rails/. This directory is in the load path.
262 |
--------------------------------------------------------------------------------
/spec/dummy/Rakefile:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env rake
2 | # Add your own tasks in files placed in lib/tasks ending in .rake,
3 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4 |
5 | require File.expand_path('../config/application', __FILE__)
6 |
7 | Dummy::Application.load_tasks
8 |
--------------------------------------------------------------------------------
/spec/dummy/app/assets/javascripts/application.js:
--------------------------------------------------------------------------------
1 | // This is a manifest file that'll be compiled into application.js, which will include all the files
2 | // listed below.
3 | //
4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5 | // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6 | //
7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8 | // the compiled file.
9 | //
10 | // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11 | // GO AFTER THE REQUIRES BELOW.
12 | //
13 | //= require jquery
14 | //= require jquery_ujs
15 | //= require_tree .
16 |
--------------------------------------------------------------------------------
/spec/dummy/app/assets/stylesheets/application.css:
--------------------------------------------------------------------------------
1 | /*
2 | * This is a manifest file that'll be compiled into application.css, which will include all the files
3 | * listed below.
4 | *
5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6 | * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7 | *
8 | * You're free to add application-wide styles to this file and they'll appear at the top of the
9 | * compiled file, but it's generally better to create a new file per style scope.
10 | *
11 | *= require_self
12 | *= require_tree .
13 | */
14 |
--------------------------------------------------------------------------------
/spec/dummy/app/controllers/application_controller.rb:
--------------------------------------------------------------------------------
1 | class ApplicationController < ActionController::Base
2 | protect_from_forgery
3 |
4 | include BootstrapHelper::Breadcrumb
5 |
6 | end
7 |
--------------------------------------------------------------------------------
/spec/dummy/app/controllers/welcome_controller.rb:
--------------------------------------------------------------------------------
1 | class WelcomeController < ApplicationController
2 |
3 | def index
4 | drop_breadcrumb("hello")
5 | end
6 | end
7 |
--------------------------------------------------------------------------------
/spec/dummy/app/helpers/application_helper.rb:
--------------------------------------------------------------------------------
1 | module ApplicationHelper
2 | include BootstrapHelper::Helper
3 | end
4 |
--------------------------------------------------------------------------------
/spec/dummy/app/mailers/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdite/bootstrap-helper/487046b72004c53d0d32b672b2a711f7cf63ba51/spec/dummy/app/mailers/.gitkeep
--------------------------------------------------------------------------------
/spec/dummy/app/models/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdite/bootstrap-helper/487046b72004c53d0d32b672b2a711f7cf63ba51/spec/dummy/app/models/.gitkeep
--------------------------------------------------------------------------------
/spec/dummy/app/views/layouts/application.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Dummy
5 | <%= stylesheet_link_tag "application", :media => "all" %>
6 | <%= javascript_include_tag "application" %>
7 | <%= csrf_meta_tags %>
8 |
9 |
10 |
11 | <%= render_breadcrumb %>
12 | <%= yield %>
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/spec/dummy/app/views/welcome/index.html.erb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdite/bootstrap-helper/487046b72004c53d0d32b672b2a711f7cf63ba51/spec/dummy/app/views/welcome/index.html.erb
--------------------------------------------------------------------------------
/spec/dummy/config.ru:
--------------------------------------------------------------------------------
1 | # This file is used by Rack-based servers to start the application.
2 |
3 | require ::File.expand_path('../config/environment', __FILE__)
4 | run Dummy::Application
5 |
--------------------------------------------------------------------------------
/spec/dummy/config/application.rb:
--------------------------------------------------------------------------------
1 | require File.expand_path('../boot', __FILE__)
2 |
3 | # Pick the frameworks you want:
4 | require "active_record/railtie"
5 | require "action_controller/railtie"
6 | require "action_mailer/railtie"
7 | require "active_resource/railtie"
8 | require "sprockets/railtie"
9 | # require "rails/test_unit/railtie"
10 |
11 | Bundler.require
12 | require "bootstrap_helper"
13 |
14 | module Dummy
15 | class Application < Rails::Application
16 | # Settings in config/environments/* take precedence over those specified here.
17 | # Application configuration should go into files in config/initializers
18 | # -- all .rb files in that directory are automatically loaded.
19 |
20 | # Custom directories with classes and modules you want to be autoloadable.
21 | # config.autoload_paths += %W(#{config.root}/extras)
22 |
23 | # Only load the plugins named here, in the order given (default is alphabetical).
24 | # :all can be used as a placeholder for all plugins not explicitly named.
25 | # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
26 |
27 | # Activate observers that should always be running.
28 | # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
29 |
30 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
31 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
32 | # config.time_zone = 'Central Time (US & Canada)'
33 |
34 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
35 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
36 | # config.i18n.default_locale = :de
37 |
38 | # Configure the default encoding used in templates for Ruby 1.9.
39 | config.encoding = "utf-8"
40 |
41 | # Configure sensitive parameters which will be filtered from the log file.
42 | config.filter_parameters += [:password]
43 |
44 | # Enable escaping HTML in JSON.
45 | config.active_support.escape_html_entities_in_json = true
46 |
47 | # Use SQL instead of Active Record's schema dumper when creating the database.
48 | # This is necessary if your schema can't be completely dumped by the schema dumper,
49 | # like if you have constraints or database-specific column types
50 | # config.active_record.schema_format = :sql
51 |
52 | # Enforce whitelist mode for mass assignment.
53 | # This will create an empty whitelist of attributes available for mass-assignment for all models
54 | # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
55 | # parameters by using an attr_accessible or attr_protected declaration.
56 | config.active_record.whitelist_attributes = true
57 |
58 | # Enable the asset pipeline
59 | config.assets.enabled = true
60 |
61 | # Version of your assets, change this if you want to expire all your assets
62 | config.assets.version = '1.0'
63 | end
64 | end
65 |
66 |
--------------------------------------------------------------------------------
/spec/dummy/config/boot.rb:
--------------------------------------------------------------------------------
1 | require 'rubygems'
2 | gemfile = File.expand_path('../../../../Gemfile', __FILE__)
3 |
4 | if File.exist?(gemfile)
5 | ENV['BUNDLE_GEMFILE'] = gemfile
6 | require 'bundler'
7 | Bundler.setup
8 | end
9 |
10 | $:.unshift File.expand_path('../../../../lib', __FILE__)
--------------------------------------------------------------------------------
/spec/dummy/config/database.yml:
--------------------------------------------------------------------------------
1 | # SQLite version 3.x
2 | # gem install sqlite3
3 | #
4 | # Ensure the SQLite 3 gem is defined in your Gemfile
5 | # gem 'sqlite3'
6 | development:
7 | adapter: sqlite3
8 | database: db/development.sqlite3
9 | pool: 5
10 | timeout: 5000
11 |
12 | # Warning: The database defined as "test" will be erased and
13 | # re-generated from your development database when you run "rake".
14 | # Do not set this db to the same as development or production.
15 | test:
16 | adapter: sqlite3
17 | database: db/test.sqlite3
18 | pool: 5
19 | timeout: 5000
20 |
21 | production:
22 | adapter: sqlite3
23 | database: db/production.sqlite3
24 | pool: 5
25 | timeout: 5000
26 |
--------------------------------------------------------------------------------
/spec/dummy/config/environment.rb:
--------------------------------------------------------------------------------
1 | # Load the rails application
2 | require File.expand_path('../application', __FILE__)
3 |
4 | # Initialize the rails application
5 | Dummy::Application.initialize!
6 |
--------------------------------------------------------------------------------
/spec/dummy/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | Dummy::Application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb
3 |
4 | # In the development environment your application's code is reloaded on
5 | # every request. This slows down response time but is perfect for development
6 | # since you don't have to restart the web server when you make code changes.
7 | config.cache_classes = false
8 |
9 | # Log error messages when you accidentally call methods on nil.
10 | config.whiny_nils = true
11 |
12 | # Show full error reports and disable caching
13 | config.consider_all_requests_local = true
14 | config.action_controller.perform_caching = false
15 |
16 | # Don't care if the mailer can't send
17 | config.action_mailer.raise_delivery_errors = false
18 |
19 | # Print deprecation notices to the Rails logger
20 | config.active_support.deprecation = :log
21 |
22 | # Only use best-standards-support built into browsers
23 | config.action_dispatch.best_standards_support = :builtin
24 |
25 | # Raise exception on mass assignment protection for Active Record models
26 | config.active_record.mass_assignment_sanitizer = :strict
27 |
28 | # Log the query plan for queries taking more than this (works
29 | # with SQLite, MySQL, and PostgreSQL)
30 | config.active_record.auto_explain_threshold_in_seconds = 0.5
31 |
32 | # Do not compress assets
33 | config.assets.compress = false
34 |
35 | # Expands the lines which load the assets
36 | config.assets.debug = true
37 | end
38 |
--------------------------------------------------------------------------------
/spec/dummy/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | Dummy::Application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb
3 |
4 | # Code is not reloaded between requests
5 | config.cache_classes = true
6 |
7 | # Full error reports are disabled and caching is turned on
8 | config.consider_all_requests_local = false
9 | config.action_controller.perform_caching = true
10 |
11 | # Disable Rails's static asset server (Apache or nginx will already do this)
12 | config.serve_static_assets = false
13 |
14 | # Compress JavaScripts and CSS
15 | config.assets.compress = true
16 |
17 | # Don't fallback to assets pipeline if a precompiled asset is missed
18 | config.assets.compile = false
19 |
20 | # Generate digests for assets URLs
21 | config.assets.digest = true
22 |
23 | # Defaults to nil and saved in location specified by config.assets.prefix
24 | # config.assets.manifest = YOUR_PATH
25 |
26 | # Specifies the header that your server uses for sending files
27 | # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
28 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
29 |
30 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
31 | # config.force_ssl = true
32 |
33 | # See everything in the log (default is :info)
34 | # config.log_level = :debug
35 |
36 | # Prepend all log lines with the following tags
37 | # config.log_tags = [ :subdomain, :uuid ]
38 |
39 | # Use a different logger for distributed setups
40 | # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
41 |
42 | # Use a different cache store in production
43 | # config.cache_store = :mem_cache_store
44 |
45 | # Enable serving of images, stylesheets, and JavaScripts from an asset server
46 | # config.action_controller.asset_host = "http://assets.example.com"
47 |
48 | # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
49 | # config.assets.precompile += %w( search.js )
50 |
51 | # Disable delivery errors, bad email addresses will be ignored
52 | # config.action_mailer.raise_delivery_errors = false
53 |
54 | # Enable threaded mode
55 | # config.threadsafe!
56 |
57 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
58 | # the I18n.default_locale when a translation can not be found)
59 | config.i18n.fallbacks = true
60 |
61 | # Send deprecation notices to registered listeners
62 | config.active_support.deprecation = :notify
63 |
64 | # Log the query plan for queries taking more than this (works
65 | # with SQLite, MySQL, and PostgreSQL)
66 | # config.active_record.auto_explain_threshold_in_seconds = 0.5
67 | end
68 |
--------------------------------------------------------------------------------
/spec/dummy/config/environments/test.rb:
--------------------------------------------------------------------------------
1 | Dummy::Application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb
3 |
4 | # The test environment is used exclusively to run your application's
5 | # test suite. You never need to work with it otherwise. Remember that
6 | # your test database is "scratch space" for the test suite and is wiped
7 | # and recreated between test runs. Don't rely on the data there!
8 | config.cache_classes = true
9 |
10 | # Configure static asset server for tests with Cache-Control for performance
11 | config.serve_static_assets = true
12 | config.static_cache_control = "public, max-age=3600"
13 |
14 | # Log error messages when you accidentally call methods on nil
15 | config.whiny_nils = true
16 |
17 | # Show full error reports and disable caching
18 | config.consider_all_requests_local = true
19 | config.action_controller.perform_caching = false
20 |
21 | # Raise exceptions instead of rendering exception templates
22 | config.action_dispatch.show_exceptions = false
23 |
24 | # Disable request forgery protection in test environment
25 | config.action_controller.allow_forgery_protection = false
26 |
27 | # Tell Action Mailer not to deliver emails to the real world.
28 | # The :test delivery method accumulates sent emails in the
29 | # ActionMailer::Base.deliveries array.
30 | config.action_mailer.delivery_method = :test
31 |
32 | # Raise exception on mass assignment protection for Active Record models
33 | config.active_record.mass_assignment_sanitizer = :strict
34 |
35 | # Print deprecation notices to the stderr
36 | config.active_support.deprecation = :stderr
37 | end
38 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/backtrace_silencers.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5 |
6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7 | # Rails.backtrace_cleaner.remove_silencers!
8 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new inflection rules using the following format
4 | # (all these examples are active by default):
5 | # ActiveSupport::Inflector.inflections do |inflect|
6 | # inflect.plural /^(ox)$/i, '\1en'
7 | # inflect.singular /^(ox)en/i, '\1'
8 | # inflect.irregular 'person', 'people'
9 | # inflect.uncountable %w( fish sheep )
10 | # end
11 | #
12 | # These inflection rules are supported but not enabled by default:
13 | # ActiveSupport::Inflector.inflections do |inflect|
14 | # inflect.acronym 'RESTful'
15 | # end
16 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/mime_types.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new mime types for use in respond_to blocks:
4 | # Mime::Type.register "text/richtext", :rtf
5 | # Mime::Type.register_alias "text/html", :iphone
6 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/secret_token.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Your secret key for verifying the integrity of signed cookies.
4 | # If you change this key, all old signed cookies will become invalid!
5 | # Make sure the secret is at least 30 characters and all random,
6 | # no regular words or you'll be exposed to dictionary attacks.
7 | Dummy::Application.config.secret_token = 'd76c4299582c60a1f8c040c6f68285a585a2950c167cfd3a853a0429056c383ff6d4b87dbaa32e90416976b22fed944f42d4c1e6f8eaf0f9fb308820aa65083f'
8 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/session_store.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
4 |
5 | # Use the database for sessions instead of the cookie-based default,
6 | # which shouldn't be used to store highly confidential information
7 | # (create the session table with "rails generate session_migration")
8 | # Dummy::Application.config.session_store :active_record_store
9 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/wrap_parameters.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 | #
3 | # This file contains settings for ActionController::ParamsWrapper which
4 | # is enabled by default.
5 |
6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7 | ActiveSupport.on_load(:action_controller) do
8 | wrap_parameters format: [:json]
9 | end
10 |
11 | # Disable root element in JSON by default.
12 | ActiveSupport.on_load(:active_record) do
13 | self.include_root_in_json = false
14 | end
15 |
--------------------------------------------------------------------------------
/spec/dummy/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Sample localization file for English. Add more files in this directory for other locales.
2 | # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3 |
4 | en:
5 | hello: "Hello world"
6 |
--------------------------------------------------------------------------------
/spec/dummy/config/routes.rb:
--------------------------------------------------------------------------------
1 | Dummy::Application.routes.draw do
2 | # The priority is based upon order of creation:
3 | # first created -> highest priority.
4 |
5 | # Sample of regular route:
6 | # match 'products/:id' => 'catalog#view'
7 | # Keep in mind you can assign values other than :controller and :action
8 |
9 | # Sample of named route:
10 | # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
11 | # This route can be invoked with purchase_url(:id => product.id)
12 |
13 | # Sample resource route (maps HTTP verbs to controller actions automatically):
14 | # resources :products
15 |
16 | # Sample resource route with options:
17 | # resources :products do
18 | # member do
19 | # get 'short'
20 | # post 'toggle'
21 | # end
22 | #
23 | # collection do
24 | # get 'sold'
25 | # end
26 | # end
27 |
28 | # Sample resource route with sub-resources:
29 | # resources :products do
30 | # resources :comments, :sales
31 | # resource :seller
32 | # end
33 |
34 | # Sample resource route with more complex sub-resources
35 | # resources :products do
36 | # resources :comments
37 | # resources :sales do
38 | # get 'recent', :on => :collection
39 | # end
40 | # end
41 |
42 | # Sample resource route within a namespace:
43 | # namespace :admin do
44 | # # Directs /admin/products/* to Admin::ProductsController
45 | # # (app/controllers/admin/products_controller.rb)
46 | # resources :products
47 | # end
48 |
49 | # You can have the root of your site routed with "root"
50 | # just remember to delete public/index.html.
51 |
52 | root :to => 'welcome#index'
53 |
54 | # See how all your routes lay out with "rake routes"
55 |
56 | # This is a legacy wild controller route that's not recommended for RESTful applications.
57 | # Note: This route will make all actions in every controller accessible via GET requests.
58 | # match ':controller(/:action(/:id))(.:format)'
59 | end
60 |
--------------------------------------------------------------------------------
/spec/dummy/db/test.sqlite3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdite/bootstrap-helper/487046b72004c53d0d32b672b2a711f7cf63ba51/spec/dummy/db/test.sqlite3
--------------------------------------------------------------------------------
/spec/dummy/lib/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdite/bootstrap-helper/487046b72004c53d0d32b672b2a711f7cf63ba51/spec/dummy/lib/assets/.gitkeep
--------------------------------------------------------------------------------
/spec/dummy/log/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdite/bootstrap-helper/487046b72004c53d0d32b672b2a711f7cf63ba51/spec/dummy/log/.gitkeep
--------------------------------------------------------------------------------
/spec/dummy/log/development.log:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdite/bootstrap-helper/487046b72004c53d0d32b672b2a711f7cf63ba51/spec/dummy/log/development.log
--------------------------------------------------------------------------------
/spec/dummy/log/test.log:
--------------------------------------------------------------------------------
1 | Connecting to database specified by database.yml
2 | Connecting to database specified by database.yml
3 | Connecting to database specified by database.yml
4 | Connecting to database specified by database.yml
5 | Connecting to database specified by database.yml
6 | Connecting to database specified by database.yml
7 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
8 | [1m[35m (0.0ms)[0m rollback transaction
9 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
10 | [1m[35m (0.0ms)[0m rollback transaction
11 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
12 | [1m[35m (0.0ms)[0m rollback transaction
13 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
14 | [1m[35m (0.0ms)[0m rollback transaction
15 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
16 | [1m[35m (0.0ms)[0m rollback transaction
17 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
18 | [1m[35m (0.1ms)[0m rollback transaction
19 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
20 | [1m[35m (0.1ms)[0m rollback transaction
21 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
22 | [1m[35m (0.1ms)[0m rollback transaction
23 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
24 | [1m[35m (0.1ms)[0m rollback transaction
25 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
26 | [1m[35m (0.0ms)[0m rollback transaction
27 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
28 | [1m[35m (0.0ms)[0m rollback transaction
29 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
30 | [1m[35m (0.0ms)[0m rollback transaction
31 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
32 | [1m[35m (0.1ms)[0m rollback transaction
33 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
34 | [1m[35m (0.0ms)[0m rollback transaction
35 | Connecting to database specified by database.yml
36 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
37 | [1m[35m (0.0ms)[0m rollback transaction
38 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
39 | [1m[35m (0.0ms)[0m rollback transaction
40 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
41 | [1m[35m (0.0ms)[0m rollback transaction
42 | [1m[36m (0.0ms)[0m [1mbegin transaction[0m
43 | [1m[35m (0.0ms)[0m rollback transaction
44 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
45 | [1m[35m (0.0ms)[0m rollback transaction
46 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
47 | [1m[35m (0.1ms)[0m rollback transaction
48 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
49 | [1m[35m (0.0ms)[0m rollback transaction
50 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
51 | [1m[35m (0.1ms)[0m rollback transaction
52 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
53 | [1m[35m (0.0ms)[0m rollback transaction
54 | [1m[36m (0.0ms)[0m [1mbegin transaction[0m
55 | [1m[35m (0.0ms)[0m rollback transaction
56 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
57 | [1m[35m (0.0ms)[0m rollback transaction
58 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
59 | [1m[35m (0.1ms)[0m rollback transaction
60 | [1m[36m (0.0ms)[0m [1mbegin transaction[0m
61 | [1m[35m (0.0ms)[0m rollback transaction
62 | [1m[36m (0.0ms)[0m [1mbegin transaction[0m
63 | [1m[35m (0.0ms)[0m rollback transaction
64 | Connecting to database specified by database.yml
65 | Connecting to database specified by database.yml
66 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
67 | [1m[35m (0.0ms)[0m rollback transaction
68 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
69 | [1m[35m (0.0ms)[0m rollback transaction
70 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
71 | [1m[35m (0.0ms)[0m rollback transaction
72 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
73 | [1m[35m (0.0ms)[0m rollback transaction
74 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
75 | [1m[35m (0.0ms)[0m rollback transaction
76 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
77 | [1m[35m (0.1ms)[0m rollback transaction
78 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
79 | [1m[35m (0.1ms)[0m rollback transaction
80 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
81 | [1m[35m (0.0ms)[0m rollback transaction
82 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
83 | [1m[35m (0.0ms)[0m rollback transaction
84 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
85 | [1m[35m (0.0ms)[0m rollback transaction
86 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
87 | [1m[35m (0.1ms)[0m rollback transaction
88 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
89 | [1m[35m (0.1ms)[0m rollback transaction
90 | Connecting to database specified by database.yml
91 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
92 | [1m[35m (0.0ms)[0m rollback transaction
93 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
94 | [1m[35m (0.0ms)[0m rollback transaction
95 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
96 | [1m[35m (0.0ms)[0m rollback transaction
97 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
98 | [1m[35m (0.0ms)[0m rollback transaction
99 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
100 | [1m[35m (0.0ms)[0m rollback transaction
101 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
102 | [1m[35m (0.1ms)[0m rollback transaction
103 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
104 | [1m[35m (0.0ms)[0m rollback transaction
105 | [1m[36m (0.0ms)[0m [1mbegin transaction[0m
106 | [1m[35m (0.0ms)[0m rollback transaction
107 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
108 | [1m[35m (0.0ms)[0m rollback transaction
109 | [1m[36m (0.0ms)[0m [1mbegin transaction[0m
110 | [1m[35m (0.0ms)[0m rollback transaction
111 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
112 | [1m[35m (0.1ms)[0m rollback transaction
113 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
114 | [1m[35m (0.0ms)[0m rollback transaction
115 | Connecting to database specified by database.yml
116 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
117 | [1m[35m (0.0ms)[0m rollback transaction
118 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
119 | [1m[35m (0.0ms)[0m rollback transaction
120 | [1m[36m (0.0ms)[0m [1mbegin transaction[0m
121 | [1m[35m (0.0ms)[0m rollback transaction
122 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
123 | [1m[35m (0.0ms)[0m rollback transaction
124 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
125 | [1m[35m (0.0ms)[0m rollback transaction
126 | [1m[36m (0.0ms)[0m [1mbegin transaction[0m
127 | [1m[35m (0.1ms)[0m rollback transaction
128 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
129 | [1m[35m (0.0ms)[0m rollback transaction
130 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
131 | [1m[35m (0.0ms)[0m rollback transaction
132 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
133 | [1m[35m (0.0ms)[0m rollback transaction
134 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
135 | [1m[35m (0.0ms)[0m rollback transaction
136 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
137 | [1m[35m (0.0ms)[0m rollback transaction
138 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
139 | [1m[35m (0.0ms)[0m rollback transaction
140 | Connecting to database specified by database.yml
141 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
142 | [1m[35m (0.0ms)[0m rollback transaction
143 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
144 | [1m[35m (0.0ms)[0m rollback transaction
145 | [1m[36m (0.0ms)[0m [1mbegin transaction[0m
146 | [1m[35m (0.0ms)[0m rollback transaction
147 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
148 | [1m[35m (0.0ms)[0m rollback transaction
149 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
150 | [1m[35m (0.0ms)[0m rollback transaction
151 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
152 | [1m[35m (0.1ms)[0m rollback transaction
153 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
154 | [1m[35m (0.1ms)[0m rollback transaction
155 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
156 | [1m[35m (0.0ms)[0m rollback transaction
157 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
158 | [1m[35m (0.0ms)[0m rollback transaction
159 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
160 | [1m[35m (0.1ms)[0m rollback transaction
161 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
162 | [1m[35m (0.1ms)[0m rollback transaction
163 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
164 | [1m[35m (0.1ms)[0m rollback transaction
165 | Connecting to database specified by database.yml
166 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
167 | [1m[35m (0.1ms)[0m rollback transaction
168 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
169 | [1m[35m (0.0ms)[0m rollback transaction
170 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
171 | [1m[35m (0.0ms)[0m rollback transaction
172 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
173 | [1m[35m (0.0ms)[0m rollback transaction
174 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
175 | [1m[35m (0.0ms)[0m rollback transaction
176 | [1m[36m (0.0ms)[0m [1mbegin transaction[0m
177 | [1m[35m (0.1ms)[0m rollback transaction
178 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
179 | [1m[35m (0.1ms)[0m rollback transaction
180 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
181 | [1m[35m (0.0ms)[0m rollback transaction
182 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
183 | [1m[35m (0.0ms)[0m rollback transaction
184 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
185 | [1m[35m (0.0ms)[0m rollback transaction
186 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
187 | [1m[35m (0.1ms)[0m rollback transaction
188 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
189 | [1m[35m (0.1ms)[0m rollback transaction
190 | Connecting to database specified by database.yml
191 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
192 | [1m[35m (0.1ms)[0m rollback transaction
193 | Connecting to database specified by database.yml
194 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
195 | [1m[35m (0.0ms)[0m rollback transaction
196 | Connecting to database specified by database.yml
197 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
198 | Processing by WelcomeController#index as HTML
199 | Rendered welcome/index.html.erb within layouts/application (7.1ms)
200 | Completed 200 OK in 61ms (Views: 60.9ms | ActiveRecord: 0.0ms)
201 | [1m[35m (0.1ms)[0m rollback transaction
202 | Connecting to database specified by database.yml
203 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
204 | Processing by WelcomeController#index as HTML
205 | Rendered welcome/index.html.erb within layouts/application (38.3ms)
206 | Completed 200 OK in 54ms (Views: 53.5ms | ActiveRecord: 0.0ms)
207 | [1m[35m (0.1ms)[0m rollback transaction
208 | Connecting to database specified by database.yml
209 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
210 | [1m[35m (0.1ms)[0m rollback transaction
211 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
212 | [1m[35m (0.0ms)[0m rollback transaction
213 | Connecting to database specified by database.yml
214 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
215 | [1m[35m (0.1ms)[0m rollback transaction
216 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
217 | [1m[35m (0.0ms)[0m rollback transaction
218 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
219 | [1m[35m (0.1ms)[0m rollback transaction
220 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
221 | [1m[35m (0.1ms)[0m rollback transaction
222 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
223 | [1m[35m (0.0ms)[0m rollback transaction
224 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
225 | [1m[35m (0.1ms)[0m rollback transaction
226 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
227 | [1m[35m (0.0ms)[0m rollback transaction
228 | [1m[36m (0.0ms)[0m [1mbegin transaction[0m
229 | [1m[35m (0.1ms)[0m rollback transaction
230 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
231 | [1m[35m (0.1ms)[0m rollback transaction
232 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
233 | [1m[35m (0.1ms)[0m rollback transaction
234 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
235 | [1m[35m (0.1ms)[0m rollback transaction
236 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
237 | [1m[35m (0.1ms)[0m rollback transaction
238 | Connecting to database specified by database.yml
239 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
240 | Processing by WelcomeController#index as HTML
241 | Rendered welcome/index.html.erb within layouts/application (37.5ms)
242 | Completed 200 OK in 53ms (Views: 52.9ms | ActiveRecord: 0.0ms)
243 | [1m[35m (0.1ms)[0m rollback transaction
244 | Connecting to database specified by database.yml
245 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
246 | [1m[35m (0.1ms)[0m rollback transaction
247 | [1m[36m (0.0ms)[0m [1mbegin transaction[0m
248 | Processing by WelcomeController#index as HTML
249 | Completed 200 OK in 53ms (Views: 52.1ms | ActiveRecord: 0.0ms)
250 | [1m[35m (0.1ms)[0m rollback transaction
251 | Connecting to database specified by database.yml
252 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
253 | [1m[35m (0.0ms)[0m rollback transaction
254 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
255 | Processing by WelcomeController#index as HTML
256 | Completed 200 OK in 56ms (Views: 55.5ms | ActiveRecord: 0.0ms)
257 | [1m[35m (0.1ms)[0m rollback transaction
258 | Connecting to database specified by database.yml
259 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
260 | [1m[35m (0.0ms)[0m rollback transaction
261 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
262 | Processing by WelcomeController#index as HTML
263 | Completed 200 OK in 54ms (Views: 53.2ms | ActiveRecord: 0.0ms)
264 | [1m[35m (0.1ms)[0m rollback transaction
265 | Connecting to database specified by database.yml
266 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
267 | [1m[35m (0.1ms)[0m rollback transaction
268 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
269 | Processing by WelcomeController#index as HTML
270 | Completed 200 OK in 53ms (Views: 52.6ms | ActiveRecord: 0.0ms)
271 | [1m[35m (0.1ms)[0m rollback transaction
272 | Connecting to database specified by database.yml
273 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
274 | [1m[35m (0.0ms)[0m rollback transaction
275 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
276 | Processing by WelcomeController#index as HTML
277 | Completed 200 OK in 53ms (Views: 52.4ms | ActiveRecord: 0.0ms)
278 | [1m[35m (0.1ms)[0m rollback transaction
279 | Connecting to database specified by database.yml
280 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
281 | [1m[35m (0.0ms)[0m rollback transaction
282 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
283 | Processing by WelcomeController#index as HTML
284 | Completed 200 OK in 53ms (Views: 52.3ms | ActiveRecord: 0.0ms)
285 | [1m[35m (0.1ms)[0m rollback transaction
286 | Connecting to database specified by database.yml
287 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
288 | [1m[35m (0.0ms)[0m rollback transaction
289 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
290 | Processing by WelcomeController#index as HTML
291 | Completed 200 OK in 54ms (Views: 53.1ms | ActiveRecord: 0.0ms)
292 | [1m[35m (0.1ms)[0m rollback transaction
293 | Connecting to database specified by database.yml
294 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
295 | [1m[35m (0.0ms)[0m rollback transaction
296 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
297 | Processing by WelcomeController#index as HTML
298 | Completed 200 OK in 53ms (Views: 52.6ms | ActiveRecord: 0.0ms)
299 | [1m[35m (0.1ms)[0m rollback transaction
300 | Connecting to database specified by database.yml
301 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
302 | [1m[35m (0.1ms)[0m rollback transaction
303 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
304 | Processing by WelcomeController#index as HTML
305 | Completed 200 OK in 57ms (Views: 56.1ms | ActiveRecord: 0.0ms)
306 | [1m[35m (0.1ms)[0m rollback transaction
307 | Connecting to database specified by database.yml
308 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
309 | [1m[35m (0.0ms)[0m rollback transaction
310 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
311 | Processing by WelcomeController#index as HTML
312 | Completed 200 OK in 54ms (Views: 53.7ms | ActiveRecord: 0.0ms)
313 | [1m[35m (0.1ms)[0m rollback transaction
314 | Connecting to database specified by database.yml
315 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
316 | [1m[35m (0.1ms)[0m rollback transaction
317 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
318 | Processing by WelcomeController#index as HTML
319 | Completed 200 OK in 53ms (Views: 52.4ms | ActiveRecord: 0.0ms)
320 | [1m[35m (0.1ms)[0m rollback transaction
321 | Connecting to database specified by database.yml
322 | Connecting to database specified by database.yml
323 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
324 |
325 |
326 | Started GET "/" for 127.0.0.1 at 2012-10-14 01:06:48 +0800
327 | Processing by WelcomeController#index as HTML
328 | Rendered welcome/index.html.erb within layouts/application (3.1ms)
329 | Completed 200 OK in 67ms (Views: 66.6ms | ActiveRecord: 0.0ms)
330 | [1m[35m (0.1ms)[0m rollback transaction
331 | Connecting to database specified by database.yml
332 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
333 | [1m[35m (0.0ms)[0m rollback transaction
334 | Connecting to database specified by database.yml
335 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
336 |
337 |
338 | Started GET "/" for 127.0.0.1 at 2012-10-14 01:08:13 +0800
339 | Processing by WelcomeController#index as HTML
340 | Rendered welcome/index.html.erb within layouts/application (3.0ms)
341 | Completed 200 OK in 63ms (Views: 62.7ms | ActiveRecord: 0.0ms)
342 | [1m[35m (0.1ms)[0m rollback transaction
343 | Connecting to database specified by database.yml
344 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
345 |
346 |
347 | Started GET "/" for 127.0.0.1 at 2012-10-14 01:08:32 +0800
348 | Processing by WelcomeController#index as HTML
349 | Rendered welcome/index.html.erb within layouts/application (3.2ms)
350 | Completed 200 OK in 64ms (Views: 63.2ms | ActiveRecord: 0.0ms)
351 | [1m[35m (0.1ms)[0m rollback transaction
352 | Connecting to database specified by database.yml
353 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
354 |
355 |
356 | Started GET "/" for 127.0.0.1 at 2012-10-14 01:09:02 +0800
357 | Processing by WelcomeController#index as HTML
358 | Rendered welcome/index.html.erb within layouts/application (3.1ms)
359 | Completed 200 OK in 66ms (Views: 65.0ms | ActiveRecord: 0.0ms)
360 | [1m[35m (0.1ms)[0m rollback transaction
361 | Connecting to database specified by database.yml
362 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
363 |
364 |
365 | Started GET "/" for 127.0.0.1 at 2012-10-14 01:09:57 +0800
366 | Processing by WelcomeController#index as HTML
367 | Rendered welcome/index.html.erb within layouts/application (3.1ms)
368 | Completed 200 OK in 64ms (Views: 63.7ms | ActiveRecord: 0.0ms)
369 | [1m[35m (0.1ms)[0m rollback transaction
370 | Connecting to database specified by database.yml
371 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
372 |
373 |
374 | Started GET "/" for 127.0.0.1 at 2012-10-14 01:10:52 +0800
375 | Processing by WelcomeController#index as HTML
376 | Rendered welcome/index.html.erb within layouts/application (3.1ms)
377 | Completed 200 OK in 74ms (Views: 73.7ms | ActiveRecord: 0.0ms)
378 | [1m[35m (0.1ms)[0m rollback transaction
379 | Connecting to database specified by database.yml
380 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
381 |
382 |
383 | Started GET "/" for 127.0.0.1 at 2012-10-14 01:14:50 +0800
384 | Processing by WelcomeController#index as HTML
385 | Rendered welcome/index.html.erb within layouts/application (3.7ms)
386 | Completed 200 OK in 67ms (Views: 66.1ms | ActiveRecord: 0.0ms)
387 | [1m[35m (0.1ms)[0m rollback transaction
388 | Connecting to database specified by database.yml
389 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
390 |
391 |
392 | Started GET "/" for 127.0.0.1 at 2012-10-14 01:15:19 +0800
393 | Processing by WelcomeController#index as HTML
394 | Rendered welcome/index.html.erb within layouts/application (3.2ms)
395 | Completed 200 OK in 67ms (Views: 66.9ms | ActiveRecord: 0.0ms)
396 | [1m[35m (0.1ms)[0m rollback transaction
397 | Connecting to database specified by database.yml
398 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
399 |
400 |
401 | Started GET "/" for 127.0.0.1 at 2012-10-14 01:15:45 +0800
402 | Processing by WelcomeController#index as HTML
403 | Rendered welcome/index.html.erb within layouts/application (3.1ms)
404 | Completed 200 OK in 65ms (Views: 64.4ms | ActiveRecord: 0.0ms)
405 | [1m[35m (0.1ms)[0m rollback transaction
406 | Connecting to database specified by database.yml
407 | Connecting to database specified by database.yml
408 | Connecting to database specified by database.yml
409 | Connecting to database specified by database.yml
410 | [1m[36m (0.3ms)[0m [1mbegin transaction[0m
411 | [1m[35m (0.1ms)[0m rollback transaction
412 | [1m[36m (0.1ms)[0m [1mbegin transaction[0m
413 | Processing by WelcomeController#index as HTML
414 | Completed 200 OK in 34ms (Views: 33.9ms | ActiveRecord: 0.0ms)
415 | [1m[35m (0.1ms)[0m rollback transaction
416 |
--------------------------------------------------------------------------------
/spec/dummy/public/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The page you were looking for doesn't exist (404)
5 |
17 |
18 |
19 |
20 |
21 |
22 |
The page you were looking for doesn't exist.
23 |
You may have mistyped the address or the page may have moved.
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/spec/dummy/public/422.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The change you wanted was rejected (422)
5 |
17 |
18 |
19 |
20 |
21 |
22 |
The change you wanted was rejected.
23 |
Maybe you tried to change something you didn't have access to.
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/spec/dummy/public/500.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | We're sorry, but something went wrong (500)
5 |
17 |
18 |
19 |
20 |
21 |
22 |
We're sorry, but something went wrong.
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/spec/dummy/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdite/bootstrap-helper/487046b72004c53d0d32b672b2a711f7cf63ba51/spec/dummy/public/favicon.ico
--------------------------------------------------------------------------------
/spec/dummy/script/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3 |
4 | APP_PATH = File.expand_path('../../config/application', __FILE__)
5 | require File.expand_path('../../config/boot', __FILE__)
6 | require 'rails/commands'
7 |
--------------------------------------------------------------------------------
/spec/helpers/application_helper_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe ApplicationHelper do
4 |
5 | describe "yield_or_default" do
6 | it "should return yield_name" do
7 | yield_or_default(:xxx).should == :xxx
8 | end
9 |
10 | it "should return default message" do
11 | yield_or_default(nil).should == ""
12 | end
13 | end
14 |
15 | describe "render_page_title" do
16 | it "should return 'SITENAME' when @page_title and SITE_NAME not given" do
17 | render_page_title.should == "SITE_NAME"
18 | end
19 |
20 | it "should return 'SITENAME' when @page_title not given" do
21 | SITE_NAME = "Foo"
22 | render_page_title.should == "Foo"
23 | end
24 |
25 | it "should return @page_title when @page_title is given" do
26 | @page_title = "Bar"
27 | render_page_title.should == "Foo | Bar"
28 | end
29 | end
30 |
31 |
32 | describe "notice_message" do
33 |
34 | it "should return flash message" do
35 | stub!(:flash).and_return({:warning => "Update Success!"})
36 | notice_message.should == ""
37 | end
38 |
39 | it "should return alert-success message when use notice message" do
40 | stub!(:flash).and_return({:notice => "Update Success!"})
41 | notice_message.should == ""
42 | end
43 |
44 | end
45 |
46 | describe "s" do
47 |
48 | let(:tags) { %w(table thead tbody tr td th ol ul li div span font img sup sub br hr a pre p h1 h2 h3 h4 h5 h6)}
49 | let(:poison_string) {"javascript: alert('hello');"}
50 |
51 |
52 | def sanitize_tags(tags,attributes)
53 | tags.each do |tag|
54 | attributes.each do |attribute|
55 | html_tag = content_tag(tag, "", attribute.to_sym => poison_string )
56 | s(html_tag).should == content_tag(tag, "")
57 | end
58 | end
59 | end
60 |
61 | it "should sanitize javascripts hiddln in tags using href src" do
62 | attributes = %w(href src)
63 | sanitize_tags(tags,attributes)
64 | end
65 |
66 |
67 | it "should sanitize javascripts hiddlen in tags using style" do
68 | attributes = %w(style)
69 | tags.each do |tag|
70 | attributes.each do |attribute|
71 | html_tag = content_tag(tag, "", attribute.to_sym => poison_string )
72 | s(html_tag).should == content_tag(tag, "", attribute => "")
73 | end
74 | end
75 | end
76 |
77 | end
78 |
79 | describe "render_list" do
80 | before do
81 | self.stub!("current_page?").and_return(true)
82 | end
83 |
84 | def render_some_list(options={})
85 | list = render_list options do |li|
86 | li << link_to("Link 1", "#")
87 | li << link_to("Link 2", "#")
88 | li << link_to("Link 3", "#")
89 | end
90 | end
91 |
92 |
93 | it "should return ul & li" do
94 | list = render_some_list
95 | list.should == ""
96 | end
97 |
98 | it "should return ul with class_name" do
99 | options = { :class => "foo" }
100 | list = render_some_list(options)
101 | list.should == ""
102 | end
103 |
104 | it "should return ul with id_name" do
105 | options = { :id => "bar" }
106 | list = render_some_list(options)
107 | list.should == ""
108 | end
109 | end
110 | end
111 |
--------------------------------------------------------------------------------
/spec/integration/view_homepage_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | feature 'View the homepage' do
4 |
5 | scenario 'page should have breadcrumb' do
6 | visit_homepage
7 | page.should have_css(".breadcrumb")
8 | end
9 |
10 |
11 | def visit_homepage
12 | visit root_path
13 | end
14 |
15 | end
16 |
--------------------------------------------------------------------------------
/spec/spec_helper.rb:
--------------------------------------------------------------------------------
1 | # This file is copied to spec/ when you run 'rails generate rspec:install'
2 | ENV["RAILS_ENV"] ||= 'test'
3 | require File.expand_path("../dummy/config/environment", __FILE__)
4 | require 'rspec/rails'
5 | require 'rspec/autorun'
6 |
7 | # Configure capybara for integration testing
8 | require "capybara/rails"
9 | Capybara.default_driver = :rack_test
10 | Capybara.default_selector = :css
11 |
12 | # Load support files
13 | Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
14 |
15 |
16 | RSpec.configure do |config|
17 | # ## Mock Framework
18 | #
19 | # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
20 | #
21 | # config.mock_with :mocha
22 | # config.mock_with :flexmock
23 | # config.mock_with :rr
24 |
25 | # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
26 | config.fixture_path = "#{::Rails.root}/spec/fixtures"
27 |
28 | # If you're not using ActiveRecord, or you'd prefer not to run each of your
29 | # examples within a transaction, remove the following line or assign false
30 | # instead of true.
31 | config.use_transactional_fixtures = true
32 |
33 | # If true, the base class of anonymous controllers will be inferred
34 | # automatically. This will be the default behavior in future versions of
35 | # rspec-rails.
36 | # config.infer_base_class_for_anonymous_controllers = false
37 |
38 | # Run specs in random order to surface order dependencies. If you find an
39 | # order dependency and want to debug it, you can fix the order by providing
40 | # the seed, which is printed after each run.
41 | # --seed 1234
42 | # config.order = "random"
43 |
44 | end
45 |
--------------------------------------------------------------------------------