rows_controller 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +2 -0
- data/.rvmrc +3 -0
- data/.watchr +56 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +136 -0
- data/MIT-LICENSE +20 -0
- data/README.md +91 -0
- data/Rakefile +30 -0
- data/app/controllers/rows_controller.rb +80 -0
- data/app/controllers/rows_controller/helpers.rb +86 -0
- data/app/views/rows/_form.html.erb +3 -0
- data/app/views/rows/_list.html.erb +31 -0
- data/app/views/rows/_submit.html.erb +22 -0
- data/app/views/rows/_submit_part.html.erb +4 -0
- data/app/views/rows/destroy.js.erb +1 -0
- data/app/views/rows/edit.html.erb +22 -0
- data/app/views/rows/index.html.erb +20 -0
- data/app/views/rows/new.html.erb +22 -0
- data/app/views/rows/show.html.erb +25 -0
- data/app/views/shared/_error_explanation.html.erb +14 -0
- data/app/views/shared/_flash.html.erb +9 -0
- data/lib/rows_controller.rb +5 -0
- data/lib/rows_controller/engine.rb +4 -0
- data/lib/rows_controller/locales/en.yml +33 -0
- data/lib/rows_controller/version.rb +3 -0
- data/rows_controller.gemspec +27 -0
- data/spec/controllers/orders_spec.rb +65 -0
- data/spec/controllers/rows_spec.rb +19 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +9 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/orders_controller.rb +3 -0
- data/spec/dummy/app/models/order.rb +10 -0
- data/spec/dummy/app/views/layouts/application.html.erb +13 -0
- data/spec/dummy/app/views/orders/_form.html.erb +12 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +49 -0
- data/spec/dummy/config/boot.rb +9 -0
- data/spec/dummy/config/database.yml +22 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +30 -0
- data/spec/dummy/config/environments/production.rb +60 -0
- data/spec/dummy/config/environments/test.rb +40 -0
- data/spec/dummy/config/initializers/secret_token.rb +1 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/routes.rb +7 -0
- data/spec/dummy/db/migrate/001_create_orders.rb +10 -0
- data/spec/dummy/db/schema.rb +23 -0
- data/spec/dummy/db/seeds.rb +7 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/integration/order_spec.rb +45 -0
- data/spec/models/order_spec.rb +7 -0
- data/spec/spec_helper.rb +63 -0
- data/spec/support/describe_private.rb +14 -0
- metadata +164 -0
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
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
|
@@ -0,0 +1,9 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into including all the files listed below.
|
2
|
+
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
3
|
+
// be included in the compiled file accessible from http://example.com/assets/application.js
|
4
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
5
|
+
// the compiled file.
|
6
|
+
//
|
7
|
+
//= require jquery
|
8
|
+
//= require jquery_ujs
|
9
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%#= stylesheet_link_tag "application" %>
|
6
|
+
<%= javascript_include_tag "application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<%= render '/shared/flash' %>
|
11
|
+
<%= yield %>
|
12
|
+
</body>
|
13
|
+
</html>
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
require 'rows_controller'
|
5
|
+
|
6
|
+
if defined?(Bundler)
|
7
|
+
# If you precompile assets before deploying to production, use this line
|
8
|
+
Bundler.require(*Rails.groups(:assets => %w(development test)))
|
9
|
+
# If you want your assets lazily compiled in production, use this line
|
10
|
+
# Bundler.require(:default, :assets, Rails.env)
|
11
|
+
end
|
12
|
+
|
13
|
+
module Dummy
|
14
|
+
class Application < Rails::Application
|
15
|
+
# Settings in config/environments/* take precedence over those specified here.
|
16
|
+
# Application configuration should go into files in config/initializers
|
17
|
+
# -- all .rb files in that directory are automatically loaded.
|
18
|
+
|
19
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
20
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
21
|
+
|
22
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
23
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
24
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
25
|
+
|
26
|
+
# Activate observers that should always be running.
|
27
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
28
|
+
|
29
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
30
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
31
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
32
|
+
|
33
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
34
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
35
|
+
# config.i18n.default_locale = :de
|
36
|
+
|
37
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
38
|
+
config.encoding = "utf-8"
|
39
|
+
|
40
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
41
|
+
config.filter_parameters += [:password]
|
42
|
+
|
43
|
+
# Enable the asset pipeline
|
44
|
+
config.assets.enabled = true
|
45
|
+
|
46
|
+
# Version of your assets, change this if you want to expire all your assets
|
47
|
+
config.assets.version = '1.0'
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
# Set up gems listed in the Gemfile.
|
4
|
+
#ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
5
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
|
6
|
+
|
7
|
+
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
|
8
|
+
|
9
|
+
$:.unshift File.expand_path('../../../../lib', __FILE__)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install sqlite3
|
3
|
+
development:
|
4
|
+
adapter: sqlite3
|
5
|
+
database: db/development.sqlite3
|
6
|
+
pool: 5
|
7
|
+
timeout: 5000
|
8
|
+
|
9
|
+
# Warning: The database defined as "test" will be erased and
|
10
|
+
# re-generated from your development database when you run "rake".
|
11
|
+
# Do not set this db to the same as development or production.
|
12
|
+
test:
|
13
|
+
adapter: sqlite3
|
14
|
+
database: db/test.sqlite3
|
15
|
+
pool: 5
|
16
|
+
timeout: 5000
|
17
|
+
|
18
|
+
production:
|
19
|
+
adapter: sqlite3
|
20
|
+
database: db/production.sqlite3
|
21
|
+
pool: 5
|
22
|
+
timeout: 5000
|
@@ -0,0 +1,30 @@
|
|
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
|
+
# Do not compress assets
|
26
|
+
config.assets.compress = false
|
27
|
+
|
28
|
+
# Expands the lines which load the assets
|
29
|
+
config.assets.debug = false
|
30
|
+
end
|
@@ -0,0 +1,60 @@
|
|
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 Rails.root.join("public/assets")
|
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
|
+
# Use a different logger for distributed setups
|
37
|
+
# config.logger = SyslogLogger.new
|
38
|
+
|
39
|
+
# Use a different cache store in production
|
40
|
+
# config.cache_store = :mem_cache_store
|
41
|
+
|
42
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
43
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
44
|
+
|
45
|
+
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
46
|
+
# config.assets.precompile += %w( search.js )
|
47
|
+
|
48
|
+
# Disable delivery errors, bad email addresses will be ignored
|
49
|
+
# config.action_mailer.raise_delivery_errors = false
|
50
|
+
|
51
|
+
# Enable threaded mode
|
52
|
+
# config.threadsafe!
|
53
|
+
|
54
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
55
|
+
# the I18n.default_locale when a translation can not be found)
|
56
|
+
config.i18n.fallbacks = true
|
57
|
+
|
58
|
+
# Send deprecation notices to registered listeners
|
59
|
+
config.active_support.deprecation = :notify
|
60
|
+
end
|
@@ -0,0 +1,40 @@
|
|
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
|
+
#DK config.cache_classes = true
|
9
|
+
config.cache_classes = false
|
10
|
+
|
11
|
+
# Configure static asset server for tests with Cache-Control for performance
|
12
|
+
config.serve_static_assets = true
|
13
|
+
config.static_cache_control = "public, max-age=3600"
|
14
|
+
|
15
|
+
# Log error messages when you accidentally call methods on nil
|
16
|
+
config.whiny_nils = true
|
17
|
+
|
18
|
+
# Show full error reports and disable caching
|
19
|
+
config.consider_all_requests_local = true
|
20
|
+
config.action_controller.perform_caching = false
|
21
|
+
|
22
|
+
# Raise exceptions instead of rendering exception templates
|
23
|
+
config.action_dispatch.show_exceptions = false
|
24
|
+
|
25
|
+
# Disable request forgery protection in test environment
|
26
|
+
config.action_controller.allow_forgery_protection = false
|
27
|
+
|
28
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
29
|
+
# The :test delivery method accumulates sent emails in the
|
30
|
+
# ActionMailer::Base.deliveries array.
|
31
|
+
config.action_mailer.delivery_method = :test
|
32
|
+
|
33
|
+
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
34
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
35
|
+
# like if you have constraints or database-specific column types
|
36
|
+
# config.active_record.schema_format = :sql
|
37
|
+
|
38
|
+
# Print deprecation notices to the stderr
|
39
|
+
config.active_support.deprecation = :stderr
|
40
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Dummy::Application.config.secret_token = '937a92d6932bff76ce073df95330b64d1df95bb11505bc24ebda6f103ca567a0fedf45811d459ac97b24901f0650da5280cdf82e7de21e86ebfc35586bb06f32'
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
Dummy::Application.config.session_store :cookie_store, key: '_hugo_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
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
+
#
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
7
|
+
# database schema. If you need to create the application database on another
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
+
#
|
12
|
+
# It's strongly recommended to check this file into your version control system.
|
13
|
+
|
14
|
+
ActiveRecord::Schema.define(:version => 1) do
|
15
|
+
|
16
|
+
create_table "orders", :force => true do |t|
|
17
|
+
t.string "name"
|
18
|
+
t.string "qty"
|
19
|
+
t.datetime "created_at"
|
20
|
+
t.datetime "updated_at"
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# This file should contain all the record creation needed to seed the database with its default values.
|
2
|
+
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
3
|
+
#
|
4
|
+
# Examples:
|
5
|
+
#
|
6
|
+
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
|
7
|
+
# Mayor.create(name: 'Emanuel', city: cities.first)
|
File without changes
|
@@ -0,0 +1,6 @@
|
|
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'
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Order" do
|
4
|
+
before do
|
5
|
+
Order.delete_all
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should be created' do
|
9
|
+
visit "/orders"
|
10
|
+
page.should have_content("is empty")
|
11
|
+
|
12
|
+
click_link "Create"
|
13
|
+
fill_in "Name", :with => "a name"
|
14
|
+
click_button "Create"
|
15
|
+
page.should have_content("Order created.")
|
16
|
+
page.should have_content("Show Order")
|
17
|
+
|
18
|
+
Order.all.first.name.should == "a name"
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should be deleted' do
|
22
|
+
Order.create
|
23
|
+
n = Order.all.length
|
24
|
+
visit "/orders"
|
25
|
+
page.should have_content("Listing Order")
|
26
|
+
|
27
|
+
click_link "Delete"
|
28
|
+
page.should have_content("Order deleted.")
|
29
|
+
Order.all.length.should == (n - 1)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should be copied' do
|
33
|
+
order = Order.create :name => 'name', :qty => '123'
|
34
|
+
n = Order.all.length
|
35
|
+
visit "/orders/#{order.id}/copy"
|
36
|
+
page.should have_content("New")
|
37
|
+
fill_in "Name", :with => "a name"
|
38
|
+
click_button "Create"
|
39
|
+
|
40
|
+
Order.all.length.should == (n + 1)
|
41
|
+
order2 = Order.find(order.id + 1)
|
42
|
+
order2.name.should_not == order.name
|
43
|
+
order2.qty.should == order.qty
|
44
|
+
end
|
45
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'spork'
|
3
|
+
|
4
|
+
Spork.prefork do
|
5
|
+
# Loading more in this block will cause your tests to run faster. However,
|
6
|
+
# if you change any configuration or code from libraries loaded here, you'll
|
7
|
+
# need to restart spork for it take effect.
|
8
|
+
|
9
|
+
ENV["RAILS_ENV"] = "test"
|
10
|
+
|
11
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
12
|
+
require "rails/test_help"
|
13
|
+
require "rspec/rails"
|
14
|
+
|
15
|
+
# ActionMailer::Base.delivery_method = :test
|
16
|
+
# ActionMailer::Base.perform_deliveries = true
|
17
|
+
# ActionMailer::Base.default_url_options[:host] = "test.com"
|
18
|
+
|
19
|
+
Rails.backtrace_cleaner.remove_silencers!
|
20
|
+
|
21
|
+
# Configure capybara for integration testing
|
22
|
+
require "capybara/rails"
|
23
|
+
Capybara.default_driver = :rack_test
|
24
|
+
Capybara.default_selector = :css
|
25
|
+
|
26
|
+
# Run any available migration
|
27
|
+
ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__)
|
28
|
+
|
29
|
+
# Load support files
|
30
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
31
|
+
|
32
|
+
RSpec.configure do |config|
|
33
|
+
# Remove this line if you don't want RSpec's should and should_not
|
34
|
+
# methods or matchers
|
35
|
+
require 'rspec/expectations'
|
36
|
+
config.include RSpec::Matchers
|
37
|
+
|
38
|
+
# == Mock Framework
|
39
|
+
config.mock_with :rspec
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
Spork.each_run do
|
45
|
+
# This code will be run each time you run your specs.
|
46
|
+
Dir["#{File.dirname(__FILE__)}/../lib/controllers/*.rb"].each { |f| load f }
|
47
|
+
|
48
|
+
unless ENV['COVERAGE'].nil?
|
49
|
+
require 'simplecov'
|
50
|
+
SimpleCov.start 'rails' do
|
51
|
+
coverage_dir 'coverage'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
# --- Instructions ---
|
58
|
+
# - Sort through your spec_helper file. Place as much environment loading
|
59
|
+
# code that you don't normally modify during development in the
|
60
|
+
# Spork.prefork block.
|
61
|
+
# - Place the rest under Spork.each_run block
|
62
|
+
# - Any code that is left outside of the blocks will be ran during preforking
|
63
|
+
# and during each_run!
|