From c60e8b35679451acb78cb60b08e3cf92da295bdc Mon Sep 17 00:00:00 2001 From: Fabio Napoleoni Date: Mon, 2 Oct 2017 21:56:46 +0200 Subject: [PATCH 01/29] Remove Gemfile.lock from repository --- .gitignore | 3 + Gemfile.lock | 243 --------------------------------------------------- 2 files changed, 3 insertions(+), 243 deletions(-) delete mode 100644 Gemfile.lock diff --git a/.gitignore b/.gitignore index 7a39f62d..433317c5 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,6 @@ bin/ .rspec config/cloudinary.yml + +# Should not go into published repository +Gemfile.lock diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 563d1b81..00000000 --- a/Gemfile.lock +++ /dev/null @@ -1,243 +0,0 @@ -PATH - remote: . - specs: - attachinary (1.3.1) - cloudinary (~> 1.1.0) - rails (>= 3.2) - -GEM - remote: http://rubygems.org/ - specs: - actionmailer (4.2.3) - actionpack (= 4.2.3) - actionview (= 4.2.3) - activejob (= 4.2.3) - mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.3) - actionview (= 4.2.3) - activesupport (= 4.2.3) - rack (~> 1.6) - rack-test (~> 0.6.2) - rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.3) - activesupport (= 4.2.3) - builder (~> 3.1) - erubis (~> 2.7.0) - rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - activejob (4.2.3) - activesupport (= 4.2.3) - globalid (>= 0.3.0) - activemodel (4.2.3) - activesupport (= 4.2.3) - builder (~> 3.1) - activerecord (4.2.3) - activemodel (= 4.2.3) - activesupport (= 4.2.3) - arel (~> 6.0) - activesupport (4.2.3) - i18n (~> 0.7) - json (~> 1.7, >= 1.7.7) - minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) - tzinfo (~> 1.1) - addressable (2.3.8) - arel (6.0.3) - aws_cf_signer (0.1.3) - bson (3.1.2) - builder (3.2.2) - capybara (2.4.4) - mime-types (>= 1.16) - nokogiri (>= 1.3.3) - rack (>= 1.0.0) - rack-test (>= 0.5.4) - xpath (~> 2.0) - capybara-webkit (1.6.0) - capybara (>= 2.3.0, < 2.5.0) - json - cloudinary (1.1.0) - aws_cf_signer - rest-client - coderay (1.1.0) - coffee-rails (4.1.0) - coffee-script (>= 2.2.0) - railties (>= 4.0.0, < 5.0) - coffee-script (2.4.1) - coffee-script-source - execjs - coffee-script-source (1.9.1.1) - connection_pool (2.2.0) - database_cleaner (1.4.1) - diff-lcs (1.2.5) - domain_name (0.5.24) - unf (>= 0.0.5, < 1.0.0) - erubis (2.7.0) - execjs (2.5.2) - factory_girl (4.5.0) - activesupport (>= 3.0.0) - factory_girl_rails (4.5.0) - factory_girl (~> 4.5.0) - railties (>= 3.0.0) - ffi (1.9.10) - formatador (0.2.5) - globalid (0.3.6) - activesupport (>= 4.1.0) - guard (2.12.8) - formatador (>= 0.2.4) - listen (>= 2.7, <= 4.0) - lumberjack (~> 1.0) - nenv (~> 0.1) - notiffany (~> 0.0) - pry (>= 0.9.12) - shellany (~> 0.0) - thor (>= 0.18.1) - guard-compat (1.2.1) - guard-rspec (4.6.2) - guard (~> 2.1) - guard-compat (~> 1.1) - rspec (>= 2.99.0, < 4.0) - http-cookie (1.0.2) - domain_name (~> 0.5) - i18n (0.7.0) - jquery-rails (4.0.4) - rails-dom-testing (~> 1.0) - railties (>= 4.2.0) - thor (>= 0.14, < 2.0) - json (1.8.3) - launchy (2.4.3) - addressable (~> 2.3) - listen (3.0.2) - rb-fsevent (>= 0.9.3) - rb-inotify (>= 0.9) - loofah (2.0.2) - nokogiri (>= 1.5.9) - lumberjack (1.0.9) - mail (2.6.3) - mime-types (>= 1.16, < 3) - method_source (0.8.2) - mime-types (2.6.1) - mini_portile (0.6.2) - minitest (5.7.0) - mongoid (4.0.2) - activemodel (~> 4.0) - moped (~> 2.0.0) - origin (~> 2.1) - tzinfo (>= 0.3.37) - moped (2.0.6) - bson (~> 3.0) - connection_pool (~> 2.0) - optionable (~> 0.2.0) - nenv (0.2.0) - netrc (0.10.3) - nokogiri (1.6.6.2) - mini_portile (~> 0.6.0) - notiffany (0.0.6) - nenv (~> 0.1) - shellany (~> 0.0) - optionable (0.2.0) - origin (2.1.1) - pry (0.10.1) - coderay (~> 1.1.0) - method_source (~> 0.8.1) - slop (~> 3.4) - rack (1.6.4) - rack-test (0.6.3) - rack (>= 1.0) - rails (4.2.3) - actionmailer (= 4.2.3) - actionpack (= 4.2.3) - actionview (= 4.2.3) - activejob (= 4.2.3) - activemodel (= 4.2.3) - activerecord (= 4.2.3) - activesupport (= 4.2.3) - bundler (>= 1.3.0, < 2.0) - railties (= 4.2.3) - sprockets-rails - rails-deprecated_sanitizer (1.0.3) - activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.6) - activesupport (>= 4.2.0.beta, < 5.0) - nokogiri (~> 1.6.0) - rails-deprecated_sanitizer (>= 1.0.1) - rails-html-sanitizer (1.0.2) - loofah (~> 2.0) - railties (4.2.3) - actionpack (= 4.2.3) - activesupport (= 4.2.3) - rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) - rake (10.4.2) - rb-fsevent (0.9.5) - rb-inotify (0.9.5) - ffi (>= 0.5.0) - rest-client (1.8.0) - http-cookie (>= 1.0.2, < 2.0) - mime-types (>= 1.16, < 3.0) - netrc (~> 0.7) - rspec (3.3.0) - rspec-core (~> 3.3.0) - rspec-expectations (~> 3.3.0) - rspec-mocks (~> 3.3.0) - rspec-core (3.3.2) - rspec-support (~> 3.3.0) - rspec-expectations (3.3.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.3.0) - rspec-mocks (3.3.2) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.3.0) - rspec-rails (3.3.3) - actionpack (>= 3.0, < 4.3) - activesupport (>= 3.0, < 4.3) - railties (>= 3.0, < 4.3) - rspec-core (~> 3.3.0) - rspec-expectations (~> 3.3.0) - rspec-mocks (~> 3.3.0) - rspec-support (~> 3.3.0) - rspec-support (3.3.0) - shellany (0.0.1) - simple_form (3.1.0) - actionpack (~> 4.0) - activemodel (~> 4.0) - slop (3.6.0) - sprockets (3.3.4) - rack (~> 1.0) - sprockets-rails (2.3.3) - actionpack (>= 3.0) - activesupport (>= 3.0) - sprockets (>= 2.8, < 4.0) - sqlite3 (1.3.10) - thor (0.19.1) - thread_safe (0.3.5) - tzinfo (1.2.2) - thread_safe (~> 0.1) - unf (0.1.4) - unf_ext - unf_ext (0.0.7.1) - valid_attribute (2.0.0) - xpath (2.0.0) - nokogiri (~> 1.3) - -PLATFORMS - ruby - -DEPENDENCIES - attachinary! - capybara - capybara-webkit - cloudinary - coffee-rails - database_cleaner - factory_girl_rails - guard-rspec - jquery-rails - launchy - mongoid - rb-fsevent (~> 0.9.1) - rspec-rails - simple_form - sqlite3 - valid_attribute From b93d975ec3157fe01bbb273d9bc665dacd17e215 Mon Sep 17 00:00:00 2001 From: Fabio Napoleoni Date: Mon, 2 Oct 2017 21:57:01 +0200 Subject: [PATCH 02/29] Move development dependencies to Gemfile --- Gemfile | 14 +++++++++++++- attachinary.gemspec | 29 +++++++++-------------------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/Gemfile b/Gemfile index cb628e1c..352e557b 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ -source "http://rubygems.org" +source 'http://rubygems.org' # Declare your gem's dependencies in attachinary.gemspec. # Bundler will treat runtime dependencies like base dependencies, and @@ -18,6 +18,18 @@ group :mongoid do gem 'mongoid' end +group :development, :test do + gem 'sqlite3' + gem 'rspec-rails' + gem 'valid_attribute' + gem 'capybara' + gem 'selenium-webdriver' + gem 'factory_girl_rails' + gem 'launchy' + gem 'database_cleaner' + gem 'guard-rspec' +end + # Declare any dependencies that are still in development here instead of in # your gemspec. These might include edge Rails or gems from your path or diff --git a/attachinary.gemspec b/attachinary.gemspec index 8a8d8806..6ca8c53f 100644 --- a/attachinary.gemspec +++ b/attachinary.gemspec @@ -1,32 +1,21 @@ -$:.push File.expand_path("../lib", __FILE__) +$:.push File.expand_path('../lib', __FILE__) # Maintain your gem's version: -require "attachinary/version" +require 'attachinary/version' # Describe your gem and declare its dependencies: Gem::Specification.new do |s| - s.name = "attachinary" + s.name = 'attachinary' s.version = Attachinary::VERSION - s.authors = ["Milovan Zogovic"] - s.email = ["milovan.zogovic@gmail.com"] - s.homepage = "" + s.authors = ['Milovan Zogovic'] + s.email = ['milovan.zogovic@gmail.com'] + s.homepage = '' s.summary = "attachinary-#{s.version}" - s.description = "Attachments handler for Rails that uses Cloudinary for storage." + s.description = 'Attachments handler for Rails that uses Cloudinary for storage.' - s.files = Dir["{app,config,db,lib,vendor}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.md"] - s.test_files = Dir["test/**/*"] + s.files = Dir['{app,config,db,lib,vendor}/**/*'] + ['MIT-LICENSE', 'Rakefile', 'README.md'] + s.test_files = Dir['spec/**/*'] s.add_dependency 'rails', '>= 3.2' s.add_dependency 'cloudinary', '~> 1.1.0' - - s.add_development_dependency 'sqlite3' - s.add_development_dependency 'rspec-rails' - s.add_development_dependency 'valid_attribute' - s.add_development_dependency 'capybara' - s.add_development_dependency 'capybara-webkit' - s.add_development_dependency 'factory_girl_rails' - s.add_development_dependency 'launchy' - s.add_development_dependency 'database_cleaner' - s.add_development_dependency 'rb-fsevent', '~> 0.9.1' - s.add_development_dependency 'guard-rspec' end From 4856360ce1605d380318a7b4f34b5fc0aa5905da Mon Sep 17 00:00:00 2001 From: Fabio Napoleoni Date: Mon, 2 Oct 2017 22:03:02 +0200 Subject: [PATCH 03/29] For now stick with rails 4.x.x --- attachinary.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/attachinary.gemspec b/attachinary.gemspec index 6ca8c53f..850ad5f6 100644 --- a/attachinary.gemspec +++ b/attachinary.gemspec @@ -16,6 +16,6 @@ Gem::Specification.new do |s| s.files = Dir['{app,config,db,lib,vendor}/**/*'] + ['MIT-LICENSE', 'Rakefile', 'README.md'] s.test_files = Dir['spec/**/*'] - s.add_dependency 'rails', '>= 3.2' + s.add_dependency 'rails', '>= 3.2', '< 5' s.add_dependency 'cloudinary', '~> 1.1.0' end From 54143b92723432e870cdd732551cc0a3544ad071 Mon Sep 17 00:00:00 2001 From: Fabio Napoleoni Date: Mon, 2 Oct 2017 22:08:26 +0200 Subject: [PATCH 04/29] Use require_relative instead of plain require --- lib/attachinary/engine.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/attachinary/engine.rb b/lib/attachinary/engine.rb index df946fbb..d1deb9f1 100644 --- a/lib/attachinary/engine.rb +++ b/lib/attachinary/engine.rb @@ -1,5 +1,5 @@ -require 'attachinary/view_helpers' -require 'attachinary/form_builder' +require_relative 'view_helpers' +require_relative 'form_builder' module Attachinary class Engine < ::Rails::Engine From 17981fb354b55d6a7edebbc4ed3d0dd0cc4d1e06 Mon Sep 17 00:00:00 2001 From: Fabio Napoleoni Date: Mon, 2 Oct 2017 22:15:31 +0200 Subject: [PATCH 05/29] Updated dependencies --- Gemfile | 6 ++++-- spec/dummy4/Gemfile | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 352e557b..507f3691 100644 --- a/Gemfile +++ b/Gemfile @@ -5,6 +5,9 @@ source 'http://rubygems.org' # development dependencies will be added by default to the :development group. gemspec +# For now test on latest rails 4.2.x +gem 'rails', '~> 4.2.3' + # used by the dummy application gem 'jquery-rails' gem 'cloudinary' @@ -20,14 +23,13 @@ end group :development, :test do gem 'sqlite3' - gem 'rspec-rails' + gem 'rspec-rails', '~> 3.5' gem 'valid_attribute' gem 'capybara' gem 'selenium-webdriver' gem 'factory_girl_rails' gem 'launchy' gem 'database_cleaner' - gem 'guard-rspec' end diff --git a/spec/dummy4/Gemfile b/spec/dummy4/Gemfile index 778cfae5..23c7b0ac 100644 --- a/spec/dummy4/Gemfile +++ b/spec/dummy4/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '4.2.3' +gem 'rails', '~> 4.2.3' # Use sqlite3 as the database for Active Record gem 'sqlite3' # Use SCSS for stylesheets From b6dec9db46d6a995f63715e8fe72f956c8618ef9 Mon Sep 17 00:00:00 2001 From: Fabio Napoleoni Date: Mon, 2 Oct 2017 22:18:58 +0200 Subject: [PATCH 06/29] Regenerated rspec files from scratch --- .gitignore | 5 +- .rspec | 2 + spec/rails_helper.rb | 57 +++++++++++++++++ spec/spec_helper.rb | 149 +++++++++++++++++++++++++------------------ 4 files changed, 150 insertions(+), 63 deletions(-) create mode 100644 .rspec create mode 100644 spec/rails_helper.rb diff --git a/.gitignore b/.gitignore index 433317c5..5cd66734 100644 --- a/.gitignore +++ b/.gitignore @@ -9,8 +9,11 @@ spec/dummy/.sass-cache spec/dummy/config/cloudinary.yml bin/ -.rspec + config/cloudinary.yml # Should not go into published repository Gemfile.lock + +# Failed rspec examples +spec/examples.txt diff --git a/.rspec b/.rspec new file mode 100644 index 00000000..0f30adeb --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--color +--require rails_helper diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb new file mode 100644 index 00000000..761caae9 --- /dev/null +++ b/spec/rails_helper.rb @@ -0,0 +1,57 @@ +# This file is copied to spec/ when you run 'rails generate rspec:install' +require 'spec_helper' +ENV['RAILS_ENV'] ||= 'test' +require File.expand_path('../dummy4/config/environment', __FILE__) +# Prevent database truncation if the environment is production +abort('The Rails environment is running in production mode!') if Rails.env.production? +require 'rspec/rails' +# Add additional requires below this line. Rails is not loaded until this point! + +# Requires supporting ruby files with custom matchers and macros, etc, in +# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are +# run as spec files by default. This means that files in spec/support that end +# in _spec.rb will both be required and run as specs, causing the specs to be +# run twice. It is recommended that you do not name files matching this glob to +# end with _spec.rb. You can configure this pattern with the --pattern +# option on the command line or in ~/.rspec, .rspec or `.rspec-local`. +# +# The following line is provided for convenience purposes. It has the downside +# of increasing the boot-up time by auto-requiring all files in the support +# directory. Alternatively, in the individual `*_spec.rb` files, manually +# require only the support files necessary. +# +# Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } + +# Checks for pending migration and applies them before tests are run. +# If you are not using ActiveRecord, you can remove this line. +ActiveRecord::Migration.maintain_test_schema! + +RSpec.configure do |config| + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures + config.fixture_path = "#{::Rails.root}/spec/fixtures" + + # If you're not using ActiveRecord, or you'd prefer not to run each of your + # examples within a transaction, remove the following line or assign false + # instead of true. + config.use_transactional_fixtures = true + + # RSpec Rails can automatically mix in different behaviours to your tests + # based on their file location, for example enabling you to call `get` and + # `post` in specs under `spec/controllers`. + # + # You can disable this behaviour by removing the line below, and instead + # explicitly tag your specs with their type, e.g.: + # + # RSpec.describe UsersController, :type => :controller do + # # ... + # end + # + # The different available types are documented in the features, such as in + # https://relishapp.com/rspec/rspec-rails/docs + config.infer_spec_type_from_file_location! + + # Filter lines from Rails gems in backtraces. + config.filter_rails_from_backtrace! + # arbitrary gems may also be filtered via: + # config.filter_gems_from_backtrace("gem name") +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f559819e..5026c54a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,70 +1,95 @@ -# Configure Rails Envinronment -ENV["RAILS_ENV"] = "test" -ATTACHINARY_ORM ||= (ENV["ATTACHINARY_ORM"] || :active_record).to_sym - -# $:.unshift File.dirname(__FILE__) -# require 'rspec/rails' -# require "dummy/config/environment.rb" -SPEC_ROOT = "#{::Rails.root}/.." -require "#{SPEC_ROOT}/orm/#{ATTACHINARY_ORM}" - -require 'valid_attribute' -require 'capybara/rspec' - -require 'factory_girl' -require "#{SPEC_ROOT}/factories" - -require 'database_cleaner' - -require "capybara/webkit" -Capybara.javascript_driver = :webkit - -Capybara::Webkit.configure do |config| - config.allow_url("api.cloudinary.com") - config.allow_url("res.cloudinary.com") -end - -# ENGINE_RAILS_ROOT = File.join(File.dirname(__FILE__), '../') - -# Requires supporting ruby files with custom matchers and macros, etc, -# in spec/support/ and its subdirectories. -# Uncomment next line to load all support files, if you have more than one -# Uncomment next line to load all support files, if you have more than one -# Dir[File.join(ENGINE_RAILS_ROOT, "../../spec/support/**/*.rb")].each {|f| require f } -require "#{SPEC_ROOT}/support/request_helpers" - +# This file was generated by the `rails generate rspec:install` command. Conventionally, all +# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. +# The generated `.rspec` file contains `--require spec_helper` which will cause +# this file to always be loaded, without a need to explicitly require it in any +# files. +# +# Given that it is always loaded, you are encouraged to keep this file as +# light-weight as possible. Requiring heavyweight dependencies from this file +# will add to the boot time of your test suite on EVERY test run, even for an +# individual file that may not need all of that loaded. Instead, consider making +# a separate helper file that requires the additional dependencies and performs +# the additional setup, and require it from the spec files that actually need +# it. +# +# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config| - config.color = true - config.treat_symbols_as_metadata_keys_with_true_values = true - config.filter_run focus: true - config.run_all_when_everything_filtered = true - - config.use_transactional_fixtures = false - config.include FactoryGirl::Syntax::Methods - config.include RequestHelpers, type: :feature - - config.before(:suite) do - DatabaseCleaner.strategy = :truncation + # rspec-expectations config goes here. You can use an alternate + # assertion/expectation library such as wrong or the stdlib/minitest + # assertions if you prefer. + config.expect_with :rspec do |expectations| + # This option will default to `true` in RSpec 4. It makes the `description` + # and `failure_message` of custom matchers include text for helper methods + # defined using `chain`, e.g.: + # be_bigger_than(2).and_smaller_than(4).description + # # => "be bigger than 2 and smaller than 4" + # ...rather than: + # # => "be bigger than 2" + expectations.include_chain_clauses_in_custom_matcher_descriptions = true end - config.before(:each) do |example| - DatabaseCleaner.start + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. This is generally recommended, and will default to + # `true` in RSpec 4. + mocks.verify_partial_doubles = true end - config.after(:each) do - DatabaseCleaner.clean + # This option will default to `:apply_to_host_groups` in RSpec 4 (and will + # have no way to turn it off -- the option exists only for backwards + # compatibility in RSpec 3). It causes shared context metadata to be + # inherited by the metadata hash of host groups and examples, rather than + # triggering implicit auto-inclusion in groups with matching metadata. + config.shared_context_metadata_behavior = :apply_to_host_groups + + # The settings below are suggested to provide a good initial experience + # with RSpec, but feel free to customize to your heart's content. + + # This allows you to limit a spec run to individual examples or groups + # you care about by tagging them with `:focus` metadata. When nothing + # is tagged with `:focus`, all examples get run. RSpec also provides + # aliases for `it`, `describe`, and `context` that include `:focus` + # metadata: `fit`, `fdescribe` and `fcontext`, respectively. + config.filter_run_when_matching :focus + + # Allows RSpec to persist some state between runs in order to support + # the `--only-failures` and `--next-failure` CLI options. We recommend + # you configure your source control system to ignore this file. + config.example_status_persistence_file_path = 'spec/examples.txt' + + # Limits the available syntax to the non-monkey patched syntax that is + # recommended. For more details, see: + # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ + # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ + # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode + config.disable_monkey_patching! + + # Many RSpec users commonly either run the entire suite or an individual + # file, and it's useful to allow more verbose output when running an + # individual spec file. + if config.files_to_run.one? + # Use the documentation formatter for detailed output, + # unless a formatter has already been configured + # (e.g. via a command-line flag). + config.default_formatter = "doc" end - config.after(:suite) do - print "\n\n Cleaning up uploaded files" - - begin - Cloudinary::Api.delete_resources_by_tag('test_env') - print " (done)" - rescue Cloudinary::Api::RateLimited => e - print " (#{e.message})" - end - - print "\n\n" - end + # Print the 10 slowest examples and example groups at the + # end of the spec run, to help surface which specs are running + # particularly slow. + config.profile_examples = 10 + + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = :random + + # Seed global randomization in this process using the `--seed` CLI option. + # Setting this allows you to use `--seed` to deterministically reproduce + # test failures related to randomization by passing the same `--seed` value + # as the one that triggered the failure. + Kernel.srand config.seed end From 23bad81d3f663754c275cfe310821cdeeb8207da Mon Sep 17 00:00:00 2001 From: Fabio Napoleoni Date: Mon, 2 Oct 2017 22:23:28 +0200 Subject: [PATCH 07/29] Use new RSpec default with specs --- spec/features/notes_spec.rb | 4 +--- spec/models/attachinary/file_spec.rb | 4 +--- spec/models/note_spec.rb | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/spec/features/notes_spec.rb b/spec/features/notes_spec.rb index 3574832c..3ed2d24b 100644 --- a/spec/features/notes_spec.rb +++ b/spec/features/notes_spec.rb @@ -1,6 +1,4 @@ -require 'rails_helper' - -describe 'Notes' do +RSpec.describe 'Notes' do Capybara.default_wait_time = 15 describe 'Creating new note' do diff --git a/spec/models/attachinary/file_spec.rb b/spec/models/attachinary/file_spec.rb index 0c76c00c..af7ab543 100644 --- a/spec/models/attachinary/file_spec.rb +++ b/spec/models/attachinary/file_spec.rb @@ -1,6 +1,4 @@ -require 'spec_helper' - -describe Attachinary::File do +RSpec.describe Attachinary::File do subject { build(:file) } describe 'validations' do diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index adf83350..9119219a 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -1,6 +1,4 @@ -require 'spec_helper' - -describe Note do +RSpec.describe Note do subject { build(:note) } describe 'validations' do From 90c86f7068f4643db659e4959b449d1b2ce1b72d Mon Sep 17 00:00:00 2001 From: Fabio Napoleoni Date: Mon, 2 Oct 2017 22:26:03 +0200 Subject: [PATCH 08/29] Removed dummy rails 3 app --- ...0120612112526_create_attachinary_tables.rb | 2 +- spec/dummy/Gemfile | 46 - spec/dummy/Gemfile.lock | 250 ---- spec/dummy/Rakefile | 7 - spec/dummy/app/active_record/note.rb | 12 - .../app/assets/javascripts/application.js | 28 - .../app/assets/stylesheets/application.css | 21 - .../app/controllers/application_controller.rb | 3 - .../dummy/app/controllers/notes_controller.rb | 56 - spec/dummy/app/mongoid/note.rb | 13 - .../app/views/layouts/application.html.erb | 15 - .../app/views/notes/_form_builder.html.erb | 28 - .../dummy/app/views/notes/_form_nojs.html.erb | 17 - spec/dummy/app/views/notes/_form_raw.html.erb | 28 - .../views/notes/_form_simple_form.html.erb | 17 - spec/dummy/app/views/notes/_note.html.erb | 15 - spec/dummy/app/views/notes/edit.html.erb | 1 - spec/dummy/app/views/notes/index.html.erb | 13 - spec/dummy/app/views/notes/new.html.erb | 1 - spec/dummy/config.ru | 4 - spec/dummy/config/application.rb | 71 -- spec/dummy/config/boot.rb | 9 - spec/dummy/config/cloudinary.yml.example | 15 - spec/dummy/config/database.yml | 25 - spec/dummy/config/environment.rb | 5 - spec/dummy/config/environments/development.rb | 33 - spec/dummy/config/environments/production.rb | 63 - spec/dummy/config/environments/test.rb | 37 - spec/dummy/config/initializers/attachinary.rb | 1 - .../initializers/backtrace_silencers.rb | 7 - spec/dummy/config/initializers/inflections.rb | 15 - spec/dummy/config/initializers/mime_types.rb | 5 - .../dummy/config/initializers/secret_token.rb | 7 - .../config/initializers/session_store.rb | 8 - .../config/initializers/wrap_parameters.rb | 14 - spec/dummy/config/locales/en.yml | 5 - spec/dummy/config/mongoid.yml | 68 - spec/dummy/config/routes.rb | 5 - .../migrate/20120608091037_create_tables.rb | 17 - .../db/migrate/20120608104143_create_notes.rb | 9 - spec/dummy/db/schema.rb | 38 - spec/dummy/lib/assets/.gitkeep | 0 spec/dummy/log/.gitkeep | 0 spec/dummy/public/.gitkeep | 0 spec/dummy/script/rails | 6 - spec/dummy/spec/rails_helper.rb | 48 - spec/dummy/spec/spec_helper.rb | 92 -- .../assets/javascripts/jquery.fileupload.js | 1108 ----------------- .../javascripts/jquery.iframe-transport.js | 172 --- .../assets/javascripts/jquery.ui.widget.js | 528 -------- 50 files changed, 1 insertion(+), 2987 deletions(-) delete mode 100644 spec/dummy/Gemfile delete mode 100644 spec/dummy/Gemfile.lock delete mode 100644 spec/dummy/Rakefile delete mode 100644 spec/dummy/app/active_record/note.rb delete mode 100644 spec/dummy/app/assets/javascripts/application.js delete mode 100644 spec/dummy/app/assets/stylesheets/application.css delete mode 100644 spec/dummy/app/controllers/application_controller.rb delete mode 100644 spec/dummy/app/controllers/notes_controller.rb delete mode 100644 spec/dummy/app/mongoid/note.rb delete mode 100644 spec/dummy/app/views/layouts/application.html.erb delete mode 100644 spec/dummy/app/views/notes/_form_builder.html.erb delete mode 100644 spec/dummy/app/views/notes/_form_nojs.html.erb delete mode 100644 spec/dummy/app/views/notes/_form_raw.html.erb delete mode 100644 spec/dummy/app/views/notes/_form_simple_form.html.erb delete mode 100644 spec/dummy/app/views/notes/_note.html.erb delete mode 100644 spec/dummy/app/views/notes/edit.html.erb delete mode 100644 spec/dummy/app/views/notes/index.html.erb delete mode 100644 spec/dummy/app/views/notes/new.html.erb delete mode 100644 spec/dummy/config.ru delete mode 100644 spec/dummy/config/application.rb delete mode 100644 spec/dummy/config/boot.rb delete mode 100644 spec/dummy/config/cloudinary.yml.example delete mode 100644 spec/dummy/config/database.yml delete mode 100644 spec/dummy/config/environment.rb delete mode 100644 spec/dummy/config/environments/development.rb delete mode 100644 spec/dummy/config/environments/production.rb delete mode 100644 spec/dummy/config/environments/test.rb delete mode 100644 spec/dummy/config/initializers/attachinary.rb delete mode 100644 spec/dummy/config/initializers/backtrace_silencers.rb delete mode 100644 spec/dummy/config/initializers/inflections.rb delete mode 100644 spec/dummy/config/initializers/mime_types.rb delete mode 100644 spec/dummy/config/initializers/secret_token.rb delete mode 100644 spec/dummy/config/initializers/session_store.rb delete mode 100644 spec/dummy/config/initializers/wrap_parameters.rb delete mode 100644 spec/dummy/config/locales/en.yml delete mode 100644 spec/dummy/config/mongoid.yml delete mode 100644 spec/dummy/config/routes.rb delete mode 100644 spec/dummy/db/migrate/20120608091037_create_tables.rb delete mode 100644 spec/dummy/db/migrate/20120608104143_create_notes.rb delete mode 100644 spec/dummy/db/schema.rb delete mode 100644 spec/dummy/lib/assets/.gitkeep delete mode 100644 spec/dummy/log/.gitkeep delete mode 100644 spec/dummy/public/.gitkeep delete mode 100755 spec/dummy/script/rails delete mode 100644 spec/dummy/spec/rails_helper.rb delete mode 100644 spec/dummy/spec/spec_helper.rb delete mode 100644 spec/dummy/vendor/assets/javascripts/jquery.fileupload.js delete mode 100644 spec/dummy/vendor/assets/javascripts/jquery.iframe-transport.js delete mode 100644 spec/dummy/vendor/assets/javascripts/jquery.ui.widget.js diff --git a/db/migrate/20120612112526_create_attachinary_tables.rb b/db/migrate/20120612112526_create_attachinary_tables.rb index 09aa11c7..afcacbce 100644 --- a/db/migrate/20120612112526_create_attachinary_tables.rb +++ b/db/migrate/20120612112526_create_attachinary_tables.rb @@ -10,7 +10,7 @@ def change t.integer :height t.string :format t.string :resource_type - t.timestamps + t.timestamps null: false end add_index :attachinary_files, [:attachinariable_type, :attachinariable_id, :scope], name: 'by_scoped_parent' end diff --git a/spec/dummy/Gemfile b/spec/dummy/Gemfile deleted file mode 100644 index 34478bef..00000000 --- a/spec/dummy/Gemfile +++ /dev/null @@ -1,46 +0,0 @@ -source 'https://rubygems.org' - -# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '~> 3.2' -# Use sqlite3 as the database for Active Record -gem 'sqlite3' -# Use Uglifier as compressor for JavaScript assets -gem 'uglifier', '>= 1.3.0' -# Use CoffeeScript for .coffee assets and views -gem 'coffee-rails' -# Use jquery as the JavaScript library -gem 'jquery-rails' -# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks -gem 'jbuilder', '~> 2.0' - -# Use ActiveModel has_secure_password -# gem 'bcrypt', '~> 3.1.7' - -# Use Unicorn as the app server -# gem 'unicorn' - -# Use Capistrano for deployment -# gem 'capistrano-rails', group: :development - -group :development, :test do - - # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring - gem 'spring' - gem 'rspec-rails' - gem 'ruby-debug-ide' - gem 'valid_attribute' - gem 'capybara' - gem 'capybara-webkit' - gem 'selenium-webdriver' - gem 'factory_girl_rails' - gem 'launchy' - gem 'database_cleaner' - gem 'rb-fsevent', '~> 0.9.1' - gem 'guard-rspec' -end - -gem 'mongoid' -gem 'cloudinary', '~> 1.1' -gem 'attachinary', :path => '../..' -gem 'simple_form' - diff --git a/spec/dummy/Gemfile.lock b/spec/dummy/Gemfile.lock deleted file mode 100644 index 4fe32805..00000000 --- a/spec/dummy/Gemfile.lock +++ /dev/null @@ -1,250 +0,0 @@ -PATH - remote: ../.. - specs: - attachinary (1.3.1) - cloudinary (~> 1.1.0) - rails (>= 3.2) - -GEM - remote: https://rubygems.org/ - specs: - actionmailer (3.2.22) - actionpack (= 3.2.22) - mail (~> 2.5.4) - actionpack (3.2.22) - activemodel (= 3.2.22) - activesupport (= 3.2.22) - builder (~> 3.0.0) - erubis (~> 2.7.0) - journey (~> 1.0.4) - rack (~> 1.4.5) - rack-cache (~> 1.2) - rack-test (~> 0.6.1) - sprockets (~> 2.2.1) - activemodel (3.2.22) - activesupport (= 3.2.22) - builder (~> 3.0.0) - activerecord (3.2.22) - activemodel (= 3.2.22) - activesupport (= 3.2.22) - arel (~> 3.0.2) - tzinfo (~> 0.3.29) - activeresource (3.2.22) - activemodel (= 3.2.22) - activesupport (= 3.2.22) - activesupport (3.2.22) - i18n (~> 0.6, >= 0.6.4) - multi_json (~> 1.0) - addressable (2.3.8) - arel (3.0.3) - aws_cf_signer (0.1.3) - builder (3.0.4) - capybara (2.4.4) - mime-types (>= 1.16) - nokogiri (>= 1.3.3) - rack (>= 1.0.0) - rack-test (>= 0.5.4) - xpath (~> 2.0) - capybara-webkit (1.6.0) - capybara (>= 2.3.0, < 2.5.0) - json - childprocess (0.5.6) - ffi (~> 1.0, >= 1.0.11) - cloudinary (1.1.0) - aws_cf_signer - rest-client - coderay (1.1.0) - coffee-rails (3.2.2) - coffee-script (>= 2.2.0) - railties (~> 3.2.0) - coffee-script (2.4.1) - coffee-script-source - execjs - coffee-script-source (1.9.1.1) - database_cleaner (1.4.1) - diff-lcs (1.2.5) - domain_name (0.5.24) - unf (>= 0.0.5, < 1.0.0) - erubis (2.7.0) - execjs (2.5.2) - factory_girl (4.5.0) - activesupport (>= 3.0.0) - factory_girl_rails (4.5.0) - factory_girl (~> 4.5.0) - railties (>= 3.0.0) - ffi (1.9.10) - formatador (0.2.5) - guard (2.12.9) - formatador (>= 0.2.4) - listen (>= 2.7, <= 4.0) - lumberjack (~> 1.0) - nenv (~> 0.1) - notiffany (~> 0.0) - pry (>= 0.9.12) - shellany (~> 0.0) - thor (>= 0.18.1) - guard-compat (1.2.1) - guard-rspec (4.6.3) - guard (~> 2.1) - guard-compat (~> 1.1) - rspec (>= 2.99.0, < 4.0) - hike (1.2.3) - http-cookie (1.0.2) - domain_name (~> 0.5) - i18n (0.7.0) - jbuilder (2.3.1) - activesupport (>= 3.0.0, < 5) - multi_json (~> 1.2) - journey (1.0.4) - jquery-rails (3.1.3) - railties (>= 3.0, < 5.0) - thor (>= 0.14, < 2.0) - json (1.8.3) - launchy (2.4.3) - addressable (~> 2.3) - listen (3.0.3) - rb-fsevent (>= 0.9.3) - rb-inotify (>= 0.9) - lumberjack (1.0.9) - mail (2.5.4) - mime-types (~> 1.16) - treetop (~> 1.4.8) - method_source (0.8.2) - mime-types (1.25.1) - mini_portile (0.6.2) - mongoid (3.1.7) - activemodel (~> 3.2) - moped (~> 1.4) - origin (~> 1.0) - tzinfo (~> 0.3.29) - moped (1.5.2) - multi_json (1.11.2) - nenv (0.2.0) - netrc (0.10.3) - nokogiri (1.6.6.2) - mini_portile (~> 0.6.0) - notiffany (0.0.6) - nenv (~> 0.1) - shellany (~> 0.0) - origin (1.1.0) - polyglot (0.3.5) - pry (0.10.1) - coderay (~> 1.1.0) - method_source (~> 0.8.1) - slop (~> 3.4) - rack (1.4.7) - rack-cache (1.2) - rack (>= 0.4) - rack-ssl (1.3.4) - rack - rack-test (0.6.3) - rack (>= 1.0) - rails (3.2.22) - actionmailer (= 3.2.22) - actionpack (= 3.2.22) - activerecord (= 3.2.22) - activeresource (= 3.2.22) - activesupport (= 3.2.22) - bundler (~> 1.0) - railties (= 3.2.22) - railties (3.2.22) - actionpack (= 3.2.22) - activesupport (= 3.2.22) - rack-ssl (~> 1.3.2) - rake (>= 0.8.7) - rdoc (~> 3.4) - thor (>= 0.14.6, < 2.0) - rake (10.4.2) - rb-fsevent (0.9.5) - rb-inotify (0.9.5) - ffi (>= 0.5.0) - rdoc (3.12.2) - json (~> 1.4) - rest-client (1.8.0) - http-cookie (>= 1.0.2, < 2.0) - mime-types (>= 1.16, < 3.0) - netrc (~> 0.7) - rspec (3.3.0) - rspec-core (~> 3.3.0) - rspec-expectations (~> 3.3.0) - rspec-mocks (~> 3.3.0) - rspec-core (3.3.2) - rspec-support (~> 3.3.0) - rspec-expectations (3.3.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.3.0) - rspec-mocks (3.3.2) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.3.0) - rspec-rails (3.3.3) - actionpack (>= 3.0, < 4.3) - activesupport (>= 3.0, < 4.3) - railties (>= 3.0, < 4.3) - rspec-core (~> 3.3.0) - rspec-expectations (~> 3.3.0) - rspec-mocks (~> 3.3.0) - rspec-support (~> 3.3.0) - rspec-support (3.3.0) - ruby-debug-ide (0.4.32) - rake (>= 0.8.1) - rubyzip (1.1.7) - selenium-webdriver (2.47.1) - childprocess (~> 0.5) - multi_json (~> 1.0) - rubyzip (~> 1.0) - websocket (~> 1.0) - shellany (0.0.1) - simple_form (2.1.2) - actionpack (~> 3.0) - activemodel (~> 3.0) - slop (3.6.0) - spring (1.3.6) - sprockets (2.2.3) - hike (~> 1.2) - multi_json (~> 1.0) - rack (~> 1.0) - tilt (~> 1.1, != 1.3.0) - sqlite3 (1.3.10) - thor (0.19.1) - tilt (1.4.1) - treetop (1.4.15) - polyglot - polyglot (>= 0.3.1) - tzinfo (0.3.44) - uglifier (2.7.1) - execjs (>= 0.3.0) - json (>= 1.8.0) - unf (0.1.4) - unf_ext - unf_ext (0.0.7.1) - valid_attribute (2.0.0) - websocket (1.2.2) - xpath (2.0.0) - nokogiri (~> 1.3) - -PLATFORMS - ruby - -DEPENDENCIES - attachinary! - capybara - capybara-webkit - cloudinary (~> 1.1) - coffee-rails - database_cleaner - factory_girl_rails - guard-rspec - jbuilder (~> 2.0) - jquery-rails - launchy - mongoid - rails (~> 3.2) - rb-fsevent (~> 0.9.1) - rspec-rails - ruby-debug-ide - selenium-webdriver - simple_form - spring - sqlite3 - uglifier (>= 1.3.0) - valid_attribute diff --git a/spec/dummy/Rakefile b/spec/dummy/Rakefile deleted file mode 100644 index 36458522..00000000 --- a/spec/dummy/Rakefile +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env rake -# Add your own tasks in files placed in lib/tasks ending in .rake, -# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. - -require File.expand_path('../config/application', __FILE__) - -Dummy::Application.load_tasks diff --git a/spec/dummy/app/active_record/note.rb b/spec/dummy/app/active_record/note.rb deleted file mode 100644 index e232b487..00000000 --- a/spec/dummy/app/active_record/note.rb +++ /dev/null @@ -1,12 +0,0 @@ -class Note < ActiveRecord::Base - - has_attachment :photo, accept: [:jpg, :png, :gif] - has_attachments :images, accept: [:jpg, :png, :gif], maximum: 3 - - validates :body, presence: true, length: { minimum: 4, maximum: 128 } - validates :photo, presence: true - - attr_accessible :body if Rails::VERSION::MAJOR == 3 - - -end diff --git a/spec/dummy/app/assets/javascripts/application.js b/spec/dummy/app/assets/javascripts/application.js deleted file mode 100644 index 9cc30527..00000000 --- a/spec/dummy/app/assets/javascripts/application.js +++ /dev/null @@ -1,28 +0,0 @@ -// This is a manifest file that'll be compiled into application.js, which will include all the files -// listed below. -// -// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, -// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. -// -// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the -// the compiled file. -// -// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD -// GO AFTER THE REQUIRES BELOW. -// -//= require jquery -//= require jquery_ujs -//= -//= require jquery.ui.widget -//= require jquery.iframe-transport -//= require jquery.fileupload -//= require cloudinary/jquery.cloudinary -//= require attachinary -//= -//= require_tree . - -jQuery(function() { - - $('.attachinary-input').attachinary(); - -}) diff --git a/spec/dummy/app/assets/stylesheets/application.css b/spec/dummy/app/assets/stylesheets/application.css deleted file mode 100644 index 9cbb7588..00000000 --- a/spec/dummy/app/assets/stylesheets/application.css +++ /dev/null @@ -1,21 +0,0 @@ -/* - * This is a manifest file that'll be compiled into application.css, which will include all the files - * listed below. - * - * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, - * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. - * - * You're free to add application-wide styles to this file and they'll appear at the top of the - * compiled file, but it's generally better to create a new file per style scope. - * - *= require_self - *= require_tree . - */ - -form.uploading { - background-color: #ccc; -} - -input.uploading { - background-color: #999; -} diff --git a/spec/dummy/app/controllers/application_controller.rb b/spec/dummy/app/controllers/application_controller.rb deleted file mode 100644 index e8065d95..00000000 --- a/spec/dummy/app/controllers/application_controller.rb +++ /dev/null @@ -1,3 +0,0 @@ -class ApplicationController < ActionController::Base - protect_from_forgery -end diff --git a/spec/dummy/app/controllers/notes_controller.rb b/spec/dummy/app/controllers/notes_controller.rb deleted file mode 100644 index 2eb6e6a8..00000000 --- a/spec/dummy/app/controllers/notes_controller.rb +++ /dev/null @@ -1,56 +0,0 @@ -class NotesController < ApplicationController - - def index - if Rails::VERSION::MAJOR == 3 - @notes = Note.all - else - @notes = Note.all.to_a - end - end - - def new - @note = Note.new - end - - def create - @note = Note.new note_params - if @note.save - redirect_to notes_url - else - render 'new' - end - end - - def edit - @note = Note.find params[:id] - end - - def update - @note = Note.find params[:id] - if @note.update_attributes(note_params) - redirect_to notes_url - else - render 'edit' - end - end - - def destroy - @note = Note.find params[:id] - @note.destroy - redirect_to :back - end - - private - - def note_params - if Rails::VERSION::MAJOR == 3 - params[:note].slice(:body, :photo) - else - params.require(:note).permit( - :body, - :photo, - ) - end - end - -end diff --git a/spec/dummy/app/mongoid/note.rb b/spec/dummy/app/mongoid/note.rb deleted file mode 100644 index b68a9cc5..00000000 --- a/spec/dummy/app/mongoid/note.rb +++ /dev/null @@ -1,13 +0,0 @@ -class Note - include Mongoid::Document - include Mongoid::Timestamps - field :body, type: String - - has_attachment :photo, accept: [:jpg, :png, :gif] - has_attachments :images, accept: [:jpg, :png, :gif], maximum: 3 - - validates :body, presence: true, length: { minimum: 5, maximum: 128 } - validates :photo, presence: true - - attr_accessible :body -end diff --git a/spec/dummy/app/views/layouts/application.html.erb b/spec/dummy/app/views/layouts/application.html.erb deleted file mode 100644 index 52016450..00000000 --- a/spec/dummy/app/views/layouts/application.html.erb +++ /dev/null @@ -1,15 +0,0 @@ - - - - Dummy - <%= stylesheet_link_tag "application", :media => "all" %> - <%= javascript_include_tag "application" %> - <%= cloudinary_js_config %> - <%= csrf_meta_tags %> - - - -<%= yield %> - - - diff --git a/spec/dummy/app/views/notes/_form_builder.html.erb b/spec/dummy/app/views/notes/_form_builder.html.erb deleted file mode 100644 index 67d12f21..00000000 --- a/spec/dummy/app/views/notes/_form_builder.html.erb +++ /dev/null @@ -1,28 +0,0 @@ -<%= form_for note, html: { multipart: true } do |f| %> - - <%= hidden_field_tag 'kind', params[:kind] %> - - <%= f.label 'Body' %> -
- - <%= f.text_field :body %> -
<%= note.errors[:body].first %>
-
- -
- <%= f.attachinary_file_field :photo %> -
<%= note.errors[:photo].first %>
-
- -
- -
- <%= f.attachinary_file_field :images %> -
<%= note.errors[:image].first %>
-
- -
-
- - <%= f.submit %> -<% end %> diff --git a/spec/dummy/app/views/notes/_form_nojs.html.erb b/spec/dummy/app/views/notes/_form_nojs.html.erb deleted file mode 100644 index 37b47fcb..00000000 --- a/spec/dummy/app/views/notes/_form_nojs.html.erb +++ /dev/null @@ -1,17 +0,0 @@ -<%= simple_form_for note, html: { novalidate: true, multipart: true } do |f| %> - - <%= hidden_field_tag 'kind', params[:kind] %> - - <%= f.input :body, as: :string %> - -
- <%= f.input :photo, as: :file %> -
- -
- <%= f.input :images, as: :file, input_html: { multiple: true } %> -
- - <%= f.submit %> - -<% end %> diff --git a/spec/dummy/app/views/notes/_form_raw.html.erb b/spec/dummy/app/views/notes/_form_raw.html.erb deleted file mode 100644 index 4de66551..00000000 --- a/spec/dummy/app/views/notes/_form_raw.html.erb +++ /dev/null @@ -1,28 +0,0 @@ -<%= form_for note, html: { multipart: true } do |f| %> - - <%= hidden_field_tag 'kind', params[:kind] %> - - <%= f.label 'Body' %> -
- - <%= f.text_field :body %> -
<%= note.errors[:body].first %>
-
- -
- <%= attachinary_file_field_tag 'note[photo]', note, :photo %> -
<%= note.errors[:photo].first %>
-
- -
- -
- <%= attachinary_file_field_tag 'note[images][]', note, :images %> -
<%= note.errors[:image].first %>
-
- -
-
- - <%= f.submit %> -<% end %> diff --git a/spec/dummy/app/views/notes/_form_simple_form.html.erb b/spec/dummy/app/views/notes/_form_simple_form.html.erb deleted file mode 100644 index af39b812..00000000 --- a/spec/dummy/app/views/notes/_form_simple_form.html.erb +++ /dev/null @@ -1,17 +0,0 @@ -<%= simple_form_for note, html: { novalidate: true, multipart: true } do |f| %> - - <%= hidden_field_tag 'kind', params[:kind] %> - - <%= f.input :body, as: :string %> - -
- <%= f.input :photo, as: :attachinary %> -
- -
- <%= f.input :images, as: :attachinary %> -
- - <%= f.submit %> - -<% end %> diff --git a/spec/dummy/app/views/notes/_note.html.erb b/spec/dummy/app/views/notes/_note.html.erb deleted file mode 100644 index 81d4142a..00000000 --- a/spec/dummy/app/views/notes/_note.html.erb +++ /dev/null @@ -1,15 +0,0 @@ -
- <% if note.photo? %> - <%= cl_image_tag note.photo.path, - size: '120x120', crop: :fill, html_width: nil, html_height: nil %>
- - <% note.images.each do |image| %> - <%= cl_image_tag image.path, size: '37x37', crop: :fill, html_width: nil, html_height: nil %> - <% end %> - <% end %>
- <%= note.body %>
- <%= link_to 'edit (raw)', edit_note_path(note, kind: 'raw') %>
- <%= link_to 'edit (builder)', edit_note_path(note, kind: 'builder') %>
- <%= link_to 'edit (simple form)', edit_note_path(note, kind: 'simple_form') %>
- <%= link_to 'delete', note_path(note), method: :delete %> -
diff --git a/spec/dummy/app/views/notes/edit.html.erb b/spec/dummy/app/views/notes/edit.html.erb deleted file mode 100644 index ae99480f..00000000 --- a/spec/dummy/app/views/notes/edit.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= render "form_#{params[:kind]}", note: @note %> diff --git a/spec/dummy/app/views/notes/index.html.erb b/spec/dummy/app/views/notes/index.html.erb deleted file mode 100644 index 6b074379..00000000 --- a/spec/dummy/app/views/notes/index.html.erb +++ /dev/null @@ -1,13 +0,0 @@ -

Notes

-

<%= ATTACHINARY_ORM %>

- -
- <%= render @notes %> -
- -
-
-<%= link_to 'create (raw)', new_note_path(kind: 'raw') %>
-<%= link_to 'create (builder)', new_note_path(kind: 'builder') %>
-<%= link_to 'create (simple form)', new_note_path(kind: 'simple_form') %>
-<%= link_to 'create (no javascript)', new_note_path(kind: 'nojs') %>
diff --git a/spec/dummy/app/views/notes/new.html.erb b/spec/dummy/app/views/notes/new.html.erb deleted file mode 100644 index ae99480f..00000000 --- a/spec/dummy/app/views/notes/new.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= render "form_#{params[:kind]}", note: @note %> diff --git a/spec/dummy/config.ru b/spec/dummy/config.ru deleted file mode 100644 index 1989ed8d..00000000 --- a/spec/dummy/config.ru +++ /dev/null @@ -1,4 +0,0 @@ -# This file is used by Rack-based servers to start the application. - -require ::File.expand_path('../config/environment', __FILE__) -run Dummy::Application diff --git a/spec/dummy/config/application.rb b/spec/dummy/config/application.rb deleted file mode 100644 index e444789a..00000000 --- a/spec/dummy/config/application.rb +++ /dev/null @@ -1,71 +0,0 @@ -require File.expand_path('../boot', __FILE__) - -require 'rails/all' - -Bundler.require :default, ATTACHINARY_ORM - -begin - require "#{ATTACHINARY_ORM}/railtie" -rescue LoadError -end - -require "attachinary" - -module Dummy - class Application < Rails::Application - # Settings in config/environments/* take precedence over those specified here. - # Application configuration should go into files in config/initializers - # -- all .rb files in that directory are automatically loaded. - - # Custom directories with classes and modules you want to be autoloadable. - # config.autoload_paths += %W(#{config.root}/extras) - config.autoload_paths.reject!{ |p| p =~ /\/app\/(\w+)$/ && !%w(controllers helpers views).include?($1) } - config.autoload_paths += [ "#{config.root}/app/#{ATTACHINARY_ORM}" ] - - # Only load the plugins named here, in the order given (default is alphabetical). - # :all can be used as a placeholder for all plugins not explicitly named. - # config.plugins = [ :exception_notification, :ssl_requirement, :all ] - - # Activate observers that should always be running. - # config.active_record.observers = :cacher, :garbage_collector, :forum_observer - - # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. - # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. - # config.time_zone = 'Central Time (US & Canada)' - - # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. - # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] - # config.i18n.default_locale = :de - - # Configure the default encoding used in templates for Ruby 1.9. - config.encoding = "utf-8" - - config.eager_load = true - - # Configure sensitive parameters which will be filtered from the log file. - config.filter_parameters += [:password] - - # Enable escaping HTML in JSON. - config.active_support.escape_html_entities_in_json = true - - # Use SQL instead of Active Record's schema dumper when creating the database. - # This is necessary if your schema can't be completely dumped by the schema dumper, - # like if you have constraints or database-specific column types - # config.active_record.schema_format = :sql - - if Rails::VERSION::MAJOR == 3 - config.active_record.whitelist_attributes = true - end - - # Enable the asset pipeline - config.assets.enabled = true - - # Version of your assets, change this if you want to expire all your assets - config.assets.version = '1.0' - - config.secret_key_base = 'xxx' - - I18n.enforce_available_locales = false - end -end - diff --git a/spec/dummy/config/boot.rb b/spec/dummy/config/boot.rb deleted file mode 100644 index 003a4bcf..00000000 --- a/spec/dummy/config/boot.rb +++ /dev/null @@ -1,9 +0,0 @@ -unless defined?(ATTACHINARY_ORM) - ATTACHINARY_ORM = (ENV["ATTACHINARY_ORM"] || :active_record).to_sym -end - -require 'rubygems' -# Set up gems listed in the Gemfile. -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) - -require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) diff --git a/spec/dummy/config/cloudinary.yml.example b/spec/dummy/config/cloudinary.yml.example deleted file mode 100644 index 07600e48..00000000 --- a/spec/dummy/config/cloudinary.yml.example +++ /dev/null @@ -1,15 +0,0 @@ -default: &default - enhance_image_tag: true - static_image_support: true - cdn_subdomain: true - secure_distribution: false - private_cdn: false - cloud_name: zogash - api_key: 'xxx' - api_secret: xxx - -development: - <<: *default - -test: - <<: *default diff --git a/spec/dummy/config/database.yml b/spec/dummy/config/database.yml deleted file mode 100644 index 51a4dd45..00000000 --- a/spec/dummy/config/database.yml +++ /dev/null @@ -1,25 +0,0 @@ -# SQLite version 3.x -# gem install sqlite3 -# -# Ensure the SQLite 3 gem is defined in your Gemfile -# gem 'sqlite3' -development: - adapter: sqlite3 - database: db/development.sqlite3 - pool: 5 - timeout: 5000 - -# Warning: The database defined as "test" will be erased and -# re-generated from your development database when you run "rake". -# Do not set this db to the same as development or production. -test: - adapter: sqlite3 - database: db/test.sqlite3 - pool: 5 - timeout: 5000 - -production: - adapter: sqlite3 - database: db/production.sqlite3 - pool: 5 - timeout: 5000 diff --git a/spec/dummy/config/environment.rb b/spec/dummy/config/environment.rb deleted file mode 100644 index 3da5eb91..00000000 --- a/spec/dummy/config/environment.rb +++ /dev/null @@ -1,5 +0,0 @@ -# Load the rails application -require File.expand_path('../application', __FILE__) - -# Initialize the rails application -Dummy::Application.initialize! diff --git a/spec/dummy/config/environments/development.rb b/spec/dummy/config/environments/development.rb deleted file mode 100644 index 20c2de52..00000000 --- a/spec/dummy/config/environments/development.rb +++ /dev/null @@ -1,33 +0,0 @@ -Dummy::Application.configure do - # Settings specified here will take precedence over those in config/application.rb - - # In the development environment your application's code is reloaded on - # every request. This slows down response time but is perfect for development - # since you don't have to restart the web server when you make code changes. - config.cache_classes = false - - # Show full error reports and disable caching - config.consider_all_requests_local = true - config.action_controller.perform_caching = false - - # Don't care if the mailer can't send - config.action_mailer.raise_delivery_errors = false - - # Print deprecation notices to the Rails logger - config.active_support.deprecation = :log - - # Only use best-standards-support built into browsers - config.action_dispatch.best_standards_support = :builtin - - if Rails::VERSION::MAJOR == 3 - config.active_record.mass_assignment_sanitizer = :strict - end - - # Do not compress assets - config.assets.compress = false - - # Expands the lines which load the assets - config.assets.debug = true - - config.eager_load = false -end diff --git a/spec/dummy/config/environments/production.rb b/spec/dummy/config/environments/production.rb deleted file mode 100644 index cd7d2428..00000000 --- a/spec/dummy/config/environments/production.rb +++ /dev/null @@ -1,63 +0,0 @@ -Dummy::Application.configure do - # Settings specified here will take precedence over those in config/application.rb - - # Code is not reloaded between requests - config.cache_classes = true - - # Full error reports are disabled and caching is turned on - config.consider_all_requests_local = false - config.action_controller.perform_caching = true - - # Disable Rails's static asset server (Apache or nginx will already do this) - config.serve_static_assets = false - - # Compress JavaScripts and CSS - config.assets.compress = true - - # Don't fallback to assets pipeline if a precompiled asset is missed - config.assets.compile = false - - # Generate digests for assets URLs - config.assets.digest = true - - # Defaults to nil and saved in location specified by config.assets.prefix - # config.assets.manifest = YOUR_PATH - - # Specifies the header that your server uses for sending files - # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache - # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx - - # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - # config.force_ssl = true - - # See everything in the log (default is :info) - # config.log_level = :debug - - # Prepend all log lines with the following tags - # config.log_tags = [ :subdomain, :uuid ] - - # Use a different logger for distributed setups - # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) - - # Use a different cache store in production - # config.cache_store = :mem_cache_store - - # Enable serving of images, stylesheets, and JavaScripts from an asset server - # config.action_controller.asset_host = "http://assets.example.com" - - # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) - # config.assets.precompile += %w( search.js ) - - # Disable delivery errors, bad email addresses will be ignored - # config.action_mailer.raise_delivery_errors = false - - # Enable threaded mode - # config.threadsafe! - - # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation can not be found) - config.i18n.fallbacks = true - - # Send deprecation notices to registered listeners - config.active_support.deprecation = :notify -end diff --git a/spec/dummy/config/environments/test.rb b/spec/dummy/config/environments/test.rb deleted file mode 100644 index 9ab0f7ec..00000000 --- a/spec/dummy/config/environments/test.rb +++ /dev/null @@ -1,37 +0,0 @@ -Dummy::Application.configure do - # Settings specified here will take precedence over those in config/application.rb - - # The test environment is used exclusively to run your application's - # test suite. You never need to work with it otherwise. Remember that - # your test database is "scratch space" for the test suite and is wiped - # and recreated between test runs. Don't rely on the data there! - config.cache_classes = true - - # Configure static asset server for tests with Cache-Control for performance - config.serve_static_assets = true - config.static_cache_control = "public, max-age=3600" - - # Show full error reports and disable caching - config.consider_all_requests_local = true - config.action_controller.perform_caching = false - - # Raise exceptions instead of rendering exception templates - config.action_dispatch.show_exceptions = false - - # Disable request forgery protection in test environment - config.action_controller.allow_forgery_protection = false - - # Tell Action Mailer not to deliver emails to the real world. - # The :test delivery method accumulates sent emails in the - # ActionMailer::Base.deliveries array. - config.action_mailer.delivery_method = :test - - if Rails::VERSION::MAJOR == 3 - config.active_record.mass_assignment_sanitizer = :strict - end - - # Print deprecation notices to the stderr - config.active_support.deprecation = :stderr - - config.eager_load = false -end diff --git a/spec/dummy/config/initializers/attachinary.rb b/spec/dummy/config/initializers/attachinary.rb deleted file mode 100644 index 3cbe0cf0..00000000 --- a/spec/dummy/config/initializers/attachinary.rb +++ /dev/null @@ -1 +0,0 @@ -require "attachinary/orm/#{ATTACHINARY_ORM}" diff --git a/spec/dummy/config/initializers/backtrace_silencers.rb b/spec/dummy/config/initializers/backtrace_silencers.rb deleted file mode 100644 index 59385cdf..00000000 --- a/spec/dummy/config/initializers/backtrace_silencers.rb +++ /dev/null @@ -1,7 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. -# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } - -# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. -# Rails.backtrace_cleaner.remove_silencers! diff --git a/spec/dummy/config/initializers/inflections.rb b/spec/dummy/config/initializers/inflections.rb deleted file mode 100644 index 5d8d9be2..00000000 --- a/spec/dummy/config/initializers/inflections.rb +++ /dev/null @@ -1,15 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Add new inflection rules using the following format -# (all these examples are active by default): -# ActiveSupport::Inflector.inflections do |inflect| -# inflect.plural /^(ox)$/i, '\1en' -# inflect.singular /^(ox)en/i, '\1' -# inflect.irregular 'person', 'people' -# inflect.uncountable %w( fish sheep ) -# end -# -# These inflection rules are supported but not enabled by default: -# ActiveSupport::Inflector.inflections do |inflect| -# inflect.acronym 'RESTful' -# end diff --git a/spec/dummy/config/initializers/mime_types.rb b/spec/dummy/config/initializers/mime_types.rb deleted file mode 100644 index 72aca7e4..00000000 --- a/spec/dummy/config/initializers/mime_types.rb +++ /dev/null @@ -1,5 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Add new mime types for use in respond_to blocks: -# Mime::Type.register "text/richtext", :rtf -# Mime::Type.register_alias "text/html", :iphone diff --git a/spec/dummy/config/initializers/secret_token.rb b/spec/dummy/config/initializers/secret_token.rb deleted file mode 100644 index dd41d81e..00000000 --- a/spec/dummy/config/initializers/secret_token.rb +++ /dev/null @@ -1,7 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Your secret key for verifying the integrity of signed cookies. -# If you change this key, all old signed cookies will become invalid! -# Make sure the secret is at least 30 characters and all random, -# no regular words or you'll be exposed to dictionary attacks. -Dummy::Application.config.secret_token = 'f183aecf8ec1f4324366308b34353d5e40beaca43b38dd65b122cdced57debe3e611d14aa40d6c654ce9c5311f31aee580d5b1f39debaad9430e09aafb1ec8c5' diff --git a/spec/dummy/config/initializers/session_store.rb b/spec/dummy/config/initializers/session_store.rb deleted file mode 100644 index 952473ff..00000000 --- a/spec/dummy/config/initializers/session_store.rb +++ /dev/null @@ -1,8 +0,0 @@ -# Be sure to restart your server when you modify this file. - -Dummy::Application.config.session_store :cookie_store, key: '_dummy_session' - -# Use the database for sessions instead of the cookie-based default, -# which shouldn't be used to store highly confidential information -# (create the session table with "rails generate session_migration") -# Dummy::Application.config.session_store :active_record_store diff --git a/spec/dummy/config/initializers/wrap_parameters.rb b/spec/dummy/config/initializers/wrap_parameters.rb deleted file mode 100644 index 999df201..00000000 --- a/spec/dummy/config/initializers/wrap_parameters.rb +++ /dev/null @@ -1,14 +0,0 @@ -# Be sure to restart your server when you modify this file. -# -# This file contains settings for ActionController::ParamsWrapper which -# is enabled by default. - -# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. -ActiveSupport.on_load(:action_controller) do - wrap_parameters format: [:json] -end - -# Disable root element in JSON by default. -ActiveSupport.on_load(:active_record) do - self.include_root_in_json = false -end diff --git a/spec/dummy/config/locales/en.yml b/spec/dummy/config/locales/en.yml deleted file mode 100644 index 179c14ca..00000000 --- a/spec/dummy/config/locales/en.yml +++ /dev/null @@ -1,5 +0,0 @@ -# Sample localization file for English. Add more files in this directory for other locales. -# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. - -en: - hello: "Hello world" diff --git a/spec/dummy/config/mongoid.yml b/spec/dummy/config/mongoid.yml deleted file mode 100644 index f6458b3d..00000000 --- a/spec/dummy/config/mongoid.yml +++ /dev/null @@ -1,68 +0,0 @@ -development: - # Configure available database sessions. (required) - sessions: - # Defines the default session. (required) - default: - # Defines the name of the default database that Mongoid can connect to. - # (required). - database: attachinary_development - # Provides the hosts the default session can connect to. Must be an array - # of host:port pairs. (required) - hosts: - - localhost:27017 - options: - # Change whether the session persists in safe mode by default. - # (default: false) - # safe: false - - # Change the default consistency model to :eventual or :strong. - # :eventual will send reads to secondaries, :strong sends everything - # to master. (default: :eventual) - consistency: :strong - # Configure Mongoid specific options. (optional) - options: - # Configuration for whether or not to allow access to fields that do - # not have a field definition on the model. (default: true) - # allow_dynamic_fields: true - - # Enable the identity map, needed for eager loading. (default: false) - # identity_map_enabled: false - - # Includes the root model name in json serialization. (default: false) - # include_root_in_json: false - - # Include the _type field in serializaion. (default: false) - # include_type_for_serialization: false - - # Preload all models in development, needed when models use - # inheritance. (default: false) - # preload_models: false - - # Protect id and type from mass assignment. (default: true) - # protect_sensitive_fields: true - - # Raise an error when performing a #find and the document is not found. - # (default: true) - # raise_not_found_error: true - - # Raise an error when defining a scope with the same name as an - # existing method. (default: false) - # scope_overwrite_exception: false - - # Skip the database version check, used when connecting to a db without - # admin access. (default: false) - # skip_version_check: false - - # User Active Support's time zone in conversions. (default: true) - # use_activesupport_time_zone: true - - # Ensure all times are UTC in the app side. (default: false) - # use_utc: false -test: - sessions: - default: - database: attachinary_test - hosts: - - localhost:27017 - options: - consistency: :strong diff --git a/spec/dummy/config/routes.rb b/spec/dummy/config/routes.rb deleted file mode 100644 index dcf061f0..00000000 --- a/spec/dummy/config/routes.rb +++ /dev/null @@ -1,5 +0,0 @@ -Rails.application.routes.draw do - mount Attachinary::Engine => "/attachinary" - resources :notes - root to: 'notes#index' -end diff --git a/spec/dummy/db/migrate/20120608091037_create_tables.rb b/spec/dummy/db/migrate/20120608091037_create_tables.rb deleted file mode 100644 index e6ea6c70..00000000 --- a/spec/dummy/db/migrate/20120608091037_create_tables.rb +++ /dev/null @@ -1,17 +0,0 @@ -class CreateTables < ActiveRecord::Migration - def change - create_table :attachinary_files do |t| - t.references :attachinariable, polymorphic: true - t.string :scope - - t.string :public_id - t.string :version - t.integer :width - t.integer :height - t.string :format - t.string :resource_type - t.timestamps - end - add_index :attachinary_files, [:attachinariable_type, :attachinariable_id, :scope], name: 'by_scoped_parent' - end -end diff --git a/spec/dummy/db/migrate/20120608104143_create_notes.rb b/spec/dummy/db/migrate/20120608104143_create_notes.rb deleted file mode 100644 index 3cd2131a..00000000 --- a/spec/dummy/db/migrate/20120608104143_create_notes.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CreateNotes < ActiveRecord::Migration - def change - create_table :notes do |t| - t.text :body - - t.timestamps - end - end -end diff --git a/spec/dummy/db/schema.rb b/spec/dummy/db/schema.rb deleted file mode 100644 index 2eb8762a..00000000 --- a/spec/dummy/db/schema.rb +++ /dev/null @@ -1,38 +0,0 @@ -# encoding: UTF-8 -# This file is auto-generated from the current state of the database. Instead -# of editing this file, please use the migrations feature of Active Record to -# incrementally modify your database, and then regenerate this schema definition. -# -# Note that this schema.rb definition is the authoritative source for your -# database schema. If you need to create the application database on another -# system, you should be using db:schema:load, not running all the migrations -# from scratch. The latter is a flawed and unsustainable approach (the more migrations -# you'll amass, the slower it'll run and the greater likelihood for issues). -# -# It's strongly recommended to check this file into your version control system. - -ActiveRecord::Schema.define(:version => 20120608104143) do - - create_table "attachinary_files", :force => true do |t| - t.integer "attachinariable_id" - t.string "attachinariable_type" - t.string "scope" - t.string "public_id" - t.string "version" - t.integer "width" - t.integer "height" - t.string "format" - t.string "resource_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "attachinary_files", ["attachinariable_type", "attachinariable_id", "scope"], :name => "by_scoped_parent" - - create_table "notes", :force => true do |t| - t.text "body" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - -end diff --git a/spec/dummy/lib/assets/.gitkeep b/spec/dummy/lib/assets/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/spec/dummy/log/.gitkeep b/spec/dummy/log/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/spec/dummy/public/.gitkeep b/spec/dummy/public/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/spec/dummy/script/rails b/spec/dummy/script/rails deleted file mode 100755 index f8da2cff..00000000 --- a/spec/dummy/script/rails +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby -# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. - -APP_PATH = File.expand_path('../../config/application', __FILE__) -require File.expand_path('../../config/boot', __FILE__) -require 'rails/commands' diff --git a/spec/dummy/spec/rails_helper.rb b/spec/dummy/spec/rails_helper.rb deleted file mode 100644 index d6720cee..00000000 --- a/spec/dummy/spec/rails_helper.rb +++ /dev/null @@ -1,48 +0,0 @@ -# This file is copied to spec/ when you run 'rails generate rspec:install' -ENV['RAILS_ENV'] ||= 'test' -require File.expand_path("../../config/environment", __FILE__) -# Prevent database truncation if the environment is production -abort("The Rails environment is running in production mode!") if Rails.env.production? -require 'spec_helper' -require 'rspec/rails' -# Add additional requires below this line. Rails is not loaded until this point! -require '../spec_helper.rb' -# Requires supporting ruby files with custom matchers and macros, etc, in -# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are -# run as spec files by default. This means that files in spec/support that end -# in _spec.rb will both be required and run as specs, causing the specs to be -# run twice. It is recommended that you do not name files matching this glob to -# end with _spec.rb. You can configure this pattern with the --pattern -# option on the command line or in ~/.rspec, .rspec or `.rspec-local`. -# -# The following line is provided for convenience purposes. It has the downside -# of increasing the boot-up time by auto-requiring all files in the support -# directory. Alternatively, in the individual `*_spec.rb` files, manually -# require only the support files necessary. -# -# Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } - -RSpec.configure do |config| - # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = "#{::Rails.root}/spec/fixtures" - - # If you're not using ActiveRecord, or you'd prefer not to run each of your - # examples within a transaction, remove the following line or assign false - # instead of true. - config.use_transactional_fixtures = true - - # RSpec Rails can automatically mix in different behaviours to your tests - # based on their file location, for example enabling you to call `get` and - # `post` in specs under `spec/controllers`. - # - # You can disable this behaviour by removing the line below, and instead - # explicitly tag your specs with their type, e.g.: - # - # RSpec.describe UsersController, :type => :controller do - # # ... - # end - # - # The different available types are documented in the features, such as in - # https://relishapp.com/rspec/rspec-rails/docs - config.infer_spec_type_from_file_location! -end diff --git a/spec/dummy/spec/spec_helper.rb b/spec/dummy/spec/spec_helper.rb deleted file mode 100644 index 913e28a6..00000000 --- a/spec/dummy/spec/spec_helper.rb +++ /dev/null @@ -1,92 +0,0 @@ -# This file was generated by the `rails generate rspec:install` command. Conventionally, all -# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. -# The generated `.rspec` file contains `--require spec_helper` which will cause -# this file to always be loaded, without a need to explicitly require it in any -# files. -# -# Given that it is always loaded, you are encouraged to keep this file as -# light-weight as possible. Requiring heavyweight dependencies from this file -# will add to the boot time of your test suite on EVERY test run, even for an -# individual file that may not need all of that loaded. Instead, consider making -# a separate helper file that requires the additional dependencies and performs -# the additional setup, and require it from the spec files that actually need -# it. -# -# The `.rspec` file also contains a few flags that are not defaults but that -# users commonly want. -# -# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration -RSpec.configure do |config| - # rspec-expectations config goes here. You can use an alternate - # assertion/expectation library such as wrong or the stdlib/minitest - # assertions if you prefer. - config.expect_with :rspec do |expectations| - # This option will default to `true` in RSpec 4. It makes the `description` - # and `failure_message` of custom matchers include text for helper methods - # defined using `chain`, e.g.: - # be_bigger_than(2).and_smaller_than(4).description - # # => "be bigger than 2 and smaller than 4" - # ...rather than: - # # => "be bigger than 2" - expectations.include_chain_clauses_in_custom_matcher_descriptions = true - end - - # rspec-mocks config goes here. You can use an alternate test double - # library (such as bogus or mocha) by changing the `mock_with` option here. - config.mock_with :rspec do |mocks| - # Prevents you from mocking or stubbing a method that does not exist on - # a real object. This is generally recommended, and will default to - # `true` in RSpec 4. - mocks.verify_partial_doubles = true - end - -# The settings below are suggested to provide a good initial experience -# with RSpec, but feel free to customize to your heart's content. -=begin - # These two settings work together to allow you to limit a spec run - # to individual examples or groups you care about by tagging them with - # `:focus` metadata. When nothing is tagged with `:focus`, all examples - # get run. - config.filter_run :focus - config.run_all_when_everything_filtered = true - - # Allows RSpec to persist some state between runs in order to support - # the `--only-failures` and `--next-failure` CLI options. We recommend - # you configure your source control system to ignore this file. - config.example_status_persistence_file_path = "spec/examples.txt" - - # Limits the available syntax to the non-monkey patched syntax that is - # recommended. For more details, see: - # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax - # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ - # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching - config.disable_monkey_patching! - - # Many RSpec users commonly either run the entire suite or an individual - # file, and it's useful to allow more verbose output when running an - # individual spec file. - if config.files_to_run.one? - # Use the documentation formatter for detailed output, - # unless a formatter has already been configured - # (e.g. via a command-line flag). - config.default_formatter = 'doc' - end - - # Print the 10 slowest examples and example groups at the - # end of the spec run, to help surface which specs are running - # particularly slow. - config.profile_examples = 10 - - # Run specs in random order to surface order dependencies. If you find an - # order dependency and want to debug it, you can fix the order by providing - # the seed, which is printed after each run. - # --seed 1234 - config.order = :random - - # Seed global randomization in this process using the `--seed` CLI option. - # Setting this allows you to use `--seed` to deterministically reproduce - # test failures related to randomization by passing the same `--seed` value - # as the one that triggered the failure. - Kernel.srand config.seed -=end -end diff --git a/spec/dummy/vendor/assets/javascripts/jquery.fileupload.js b/spec/dummy/vendor/assets/javascripts/jquery.fileupload.js deleted file mode 100644 index 6356012f..00000000 --- a/spec/dummy/vendor/assets/javascripts/jquery.fileupload.js +++ /dev/null @@ -1,1108 +0,0 @@ -/* - * jQuery File Upload Plugin 5.19.3 - * https://github.com/blueimp/jQuery-File-Upload - * - * Copyright 2010, Sebastian Tschan - * https://blueimp.net - * - * Licensed under the MIT license: - * http://www.opensource.org/licenses/MIT - */ - -/*jslint nomen: true, unparam: true, regexp: true */ -/*global define, window, document, Blob, FormData, location */ - -(function (factory) { - 'use strict'; - if (typeof define === 'function' && define.amd) { - // Register as an anonymous AMD module: - define([ - 'jquery', - 'jquery.ui.widget' - ], factory); - } else { - // Browser globals: - factory(window.jQuery); - } -}(function ($) { - 'use strict'; - - // The FileReader API is not actually used, but works as feature detection, - // as e.g. Safari supports XHR file uploads via the FormData API, - // but not non-multipart XHR file uploads: - $.support.xhrFileUpload = !!(window.XMLHttpRequestUpload && window.FileReader); - $.support.xhrFormDataFileUpload = !!window.FormData; - - // The fileupload widget listens for change events on file input fields defined - // via fileInput setting and paste or drop events of the given dropZone. - // In addition to the default jQuery Widget methods, the fileupload widget - // exposes the "add" and "send" methods, to add or directly send files using - // the fileupload API. - // By default, files added via file input selection, paste, drag & drop or - // "add" method are uploaded immediately, but it is possible to override - // the "add" callback option to queue file uploads. - $.widget('blueimp.fileupload', { - - options: { - // The drop target element(s), by the default the complete document. - // Set to null to disable drag & drop support: - dropZone: $(document), - // The paste target element(s), by the default the complete document. - // Set to null to disable paste support: - pasteZone: $(document), - // The file input field(s), that are listened to for change events. - // If undefined, it is set to the file input fields inside - // of the widget element on plugin initialization. - // Set to null to disable the change listener. - fileInput: undefined, - // By default, the file input field is replaced with a clone after - // each input field change event. This is required for iframe transport - // queues and allows change events to be fired for the same file - // selection, but can be disabled by setting the following option to false: - replaceFileInput: true, - // The parameter name for the file form data (the request argument name). - // If undefined or empty, the name property of the file input field is - // used, or "files[]" if the file input name property is also empty, - // can be a string or an array of strings: - paramName: undefined, - // By default, each file of a selection is uploaded using an individual - // request for XHR type uploads. Set to false to upload file - // selections in one request each: - singleFileUploads: true, - // To limit the number of files uploaded with one XHR request, - // set the following option to an integer greater than 0: - limitMultiFileUploads: undefined, - // Set the following option to true to issue all file upload requests - // in a sequential order: - sequentialUploads: false, - // To limit the number of concurrent uploads, - // set the following option to an integer greater than 0: - limitConcurrentUploads: undefined, - // Set the following option to true to force iframe transport uploads: - forceIframeTransport: false, - // Set the following option to the location of a redirect url on the - // origin server, for cross-domain iframe transport uploads: - redirect: undefined, - // The parameter name for the redirect url, sent as part of the form - // data and set to 'redirect' if this option is empty: - redirectParamName: undefined, - // Set the following option to the location of a postMessage window, - // to enable postMessage transport uploads: - postMessage: undefined, - // By default, XHR file uploads are sent as multipart/form-data. - // The iframe transport is always using multipart/form-data. - // Set to false to enable non-multipart XHR uploads: - multipart: true, - // To upload large files in smaller chunks, set the following option - // to a preferred maximum chunk size. If set to 0, null or undefined, - // or the browser does not support the required Blob API, files will - // be uploaded as a whole. - maxChunkSize: undefined, - // When a non-multipart upload or a chunked multipart upload has been - // aborted, this option can be used to resume the upload by setting - // it to the size of the already uploaded bytes. This option is most - // useful when modifying the options object inside of the "add" or - // "send" callbacks, as the options are cloned for each file upload. - uploadedBytes: undefined, - // By default, failed (abort or error) file uploads are removed from the - // global progress calculation. Set the following option to false to - // prevent recalculating the global progress data: - recalculateProgress: true, - // Interval in milliseconds to calculate and trigger progress events: - progressInterval: 100, - // Interval in milliseconds to calculate progress bitrate: - bitrateInterval: 500, - - // Additional form data to be sent along with the file uploads can be set - // using this option, which accepts an array of objects with name and - // value properties, a function returning such an array, a FormData - // object (for XHR file uploads), or a simple object. - // The form of the first fileInput is given as parameter to the function: - formData: function (form) { - return form.serializeArray(); - }, - - // The add callback is invoked as soon as files are added to the fileupload - // widget (via file input selection, drag & drop, paste or add API call). - // If the singleFileUploads option is enabled, this callback will be - // called once for each file in the selection for XHR file uplaods, else - // once for each file selection. - // The upload starts when the submit method is invoked on the data parameter. - // The data object contains a files property holding the added files - // and allows to override plugin options as well as define ajax settings. - // Listeners for this callback can also be bound the following way: - // .bind('fileuploadadd', func); - // data.submit() returns a Promise object and allows to attach additional - // handlers using jQuery's Deferred callbacks: - // data.submit().done(func).fail(func).always(func); - add: function (e, data) { - data.submit(); - }, - - // Other callbacks: - // Callback for the submit event of each file upload: - // submit: function (e, data) {}, // .bind('fileuploadsubmit', func); - // Callback for the start of each file upload request: - // send: function (e, data) {}, // .bind('fileuploadsend', func); - // Callback for successful uploads: - // done: function (e, data) {}, // .bind('fileuploaddone', func); - // Callback for failed (abort or error) uploads: - // fail: function (e, data) {}, // .bind('fileuploadfail', func); - // Callback for completed (success, abort or error) requests: - // always: function (e, data) {}, // .bind('fileuploadalways', func); - // Callback for upload progress events: - // progress: function (e, data) {}, // .bind('fileuploadprogress', func); - // Callback for global upload progress events: - // progressall: function (e, data) {}, // .bind('fileuploadprogressall', func); - // Callback for uploads start, equivalent to the global ajaxStart event: - // start: function (e) {}, // .bind('fileuploadstart', func); - // Callback for uploads stop, equivalent to the global ajaxStop event: - // stop: function (e) {}, // .bind('fileuploadstop', func); - // Callback for change events of the fileInput(s): - // change: function (e, data) {}, // .bind('fileuploadchange', func); - // Callback for paste events to the pasteZone(s): - // paste: function (e, data) {}, // .bind('fileuploadpaste', func); - // Callback for drop events of the dropZone(s): - // drop: function (e, data) {}, // .bind('fileuploaddrop', func); - // Callback for dragover events of the dropZone(s): - // dragover: function (e) {}, // .bind('fileuploaddragover', func); - - // The plugin options are used as settings object for the ajax calls. - // The following are jQuery ajax settings required for the file uploads: - processData: false, - contentType: false, - cache: false - }, - - // A list of options that require a refresh after assigning a new value: - _refreshOptionsList: [ - 'fileInput', - 'dropZone', - 'pasteZone', - 'multipart', - 'forceIframeTransport' - ], - - _BitrateTimer: function () { - this.timestamp = +(new Date()); - this.loaded = 0; - this.bitrate = 0; - this.getBitrate = function (now, loaded, interval) { - var timeDiff = now - this.timestamp; - if (!this.bitrate || !interval || timeDiff > interval) { - this.bitrate = (loaded - this.loaded) * (1000 / timeDiff) * 8; - this.loaded = loaded; - this.timestamp = now; - } - return this.bitrate; - }; - }, - - _isXHRUpload: function (options) { - return !options.forceIframeTransport && - ((!options.multipart && $.support.xhrFileUpload) || - $.support.xhrFormDataFileUpload); - }, - - _getFormData: function (options) { - var formData; - if (typeof options.formData === 'function') { - return options.formData(options.form); - } - if ($.isArray(options.formData)) { - return options.formData; - } - if (options.formData) { - formData = []; - $.each(options.formData, function (name, value) { - formData.push({name: name, value: value}); - }); - return formData; - } - return []; - }, - - _getTotal: function (files) { - var total = 0; - $.each(files, function (index, file) { - total += file.size || 1; - }); - return total; - }, - - _onProgress: function (e, data) { - if (e.lengthComputable) { - var now = +(new Date()), - total, - loaded; - if (data._time && data.progressInterval && - (now - data._time < data.progressInterval) && - e.loaded !== e.total) { - return; - } - data._time = now; - total = data.total || this._getTotal(data.files); - loaded = parseInt( - e.loaded / e.total * (data.chunkSize || total), - 10 - ) + (data.uploadedBytes || 0); - this._loaded += loaded - (data.loaded || data.uploadedBytes || 0); - data.lengthComputable = true; - data.loaded = loaded; - data.total = total; - data.bitrate = data._bitrateTimer.getBitrate( - now, - loaded, - data.bitrateInterval - ); - // Trigger a custom progress event with a total data property set - // to the file size(s) of the current upload and a loaded data - // property calculated accordingly: - this._trigger('progress', e, data); - // Trigger a global progress event for all current file uploads, - // including ajax calls queued for sequential file uploads: - this._trigger('progressall', e, { - lengthComputable: true, - loaded: this._loaded, - total: this._total, - bitrate: this._bitrateTimer.getBitrate( - now, - this._loaded, - data.bitrateInterval - ) - }); - } - }, - - _initProgressListener: function (options) { - var that = this, - xhr = options.xhr ? options.xhr() : $.ajaxSettings.xhr(); - // Accesss to the native XHR object is required to add event listeners - // for the upload progress event: - if (xhr.upload) { - $(xhr.upload).bind('progress', function (e) { - var oe = e.originalEvent; - // Make sure the progress event properties get copied over: - e.lengthComputable = oe.lengthComputable; - e.loaded = oe.loaded; - e.total = oe.total; - that._onProgress(e, options); - }); - options.xhr = function () { - return xhr; - }; - } - }, - - _initXHRData: function (options) { - var formData, - file = options.files[0], - // Ignore non-multipart setting if not supported: - multipart = options.multipart || !$.support.xhrFileUpload, - paramName = options.paramName[0]; - options.headers = options.headers || {}; - if (options.contentRange) { - options.headers['Content-Range'] = options.contentRange; - } - if (!multipart) { - options.headers['Content-Disposition'] = 'attachment; filename="' + - encodeURI(file.name) + '"'; - options.contentType = file.type; - options.data = options.blob || file; - } else if ($.support.xhrFormDataFileUpload) { - if (options.postMessage) { - // window.postMessage does not allow sending FormData - // objects, so we just add the File/Blob objects to - // the formData array and let the postMessage window - // create the FormData object out of this array: - formData = this._getFormData(options); - if (options.blob) { - formData.push({ - name: paramName, - value: options.blob - }); - } else { - $.each(options.files, function (index, file) { - formData.push({ - name: options.paramName[index] || paramName, - value: file - }); - }); - } - } else { - if (options.formData instanceof FormData) { - formData = options.formData; - } else { - formData = new FormData(); - $.each(this._getFormData(options), function (index, field) { - formData.append(field.name, field.value); - }); - } - if (options.blob) { - options.headers['Content-Disposition'] = 'attachment; filename="' + - encodeURI(file.name) + '"'; - options.headers['Content-Description'] = encodeURI(file.type); - formData.append(paramName, options.blob, file.name); - } else { - $.each(options.files, function (index, file) { - // File objects are also Blob instances. - // This check allows the tests to run with - // dummy objects: - if (file instanceof Blob) { - formData.append( - options.paramName[index] || paramName, - file, - file.name - ); - } - }); - } - } - options.data = formData; - } - // Blob reference is not needed anymore, free memory: - options.blob = null; - }, - - _initIframeSettings: function (options) { - // Setting the dataType to iframe enables the iframe transport: - options.dataType = 'iframe ' + (options.dataType || ''); - // The iframe transport accepts a serialized array as form data: - options.formData = this._getFormData(options); - // Add redirect url to form data on cross-domain uploads: - if (options.redirect && $('').prop('href', options.url) - .prop('host') !== location.host) { - options.formData.push({ - name: options.redirectParamName || 'redirect', - value: options.redirect - }); - } - }, - - _initDataSettings: function (options) { - if (this._isXHRUpload(options)) { - if (!this._chunkedUpload(options, true)) { - if (!options.data) { - this._initXHRData(options); - } - this._initProgressListener(options); - } - if (options.postMessage) { - // Setting the dataType to postmessage enables the - // postMessage transport: - options.dataType = 'postmessage ' + (options.dataType || ''); - } - } else { - this._initIframeSettings(options, 'iframe'); - } - }, - - _getParamName: function (options) { - var fileInput = $(options.fileInput), - paramName = options.paramName; - if (!paramName) { - paramName = []; - fileInput.each(function () { - var input = $(this), - name = input.prop('name') || 'files[]', - i = (input.prop('files') || [1]).length; - while (i) { - paramName.push(name); - i -= 1; - } - }); - if (!paramName.length) { - paramName = [fileInput.prop('name') || 'files[]']; - } - } else if (!$.isArray(paramName)) { - paramName = [paramName]; - } - return paramName; - }, - - _initFormSettings: function (options) { - // Retrieve missing options from the input field and the - // associated form, if available: - if (!options.form || !options.form.length) { - options.form = $(options.fileInput.prop('form')); - // If the given file input doesn't have an associated form, - // use the default widget file input's form: - if (!options.form.length) { - options.form = $(this.options.fileInput.prop('form')); - } - } - options.paramName = this._getParamName(options); - if (!options.url) { - options.url = options.form.prop('action') || location.href; - } - // The HTTP request method must be "POST" or "PUT": - options.type = (options.type || options.form.prop('method') || '') - .toUpperCase(); - if (options.type !== 'POST' && options.type !== 'PUT') { - options.type = 'POST'; - } - if (!options.formAcceptCharset) { - options.formAcceptCharset = options.form.attr('accept-charset'); - } - }, - - _getAJAXSettings: function (data) { - var options = $.extend({}, this.options, data); - this._initFormSettings(options); - this._initDataSettings(options); - return options; - }, - - // Maps jqXHR callbacks to the equivalent - // methods of the given Promise object: - _enhancePromise: function (promise) { - promise.success = promise.done; - promise.error = promise.fail; - promise.complete = promise.always; - return promise; - }, - - // Creates and returns a Promise object enhanced with - // the jqXHR methods abort, success, error and complete: - _getXHRPromise: function (resolveOrReject, context, args) { - var dfd = $.Deferred(), - promise = dfd.promise(); - context = context || this.options.context || promise; - if (resolveOrReject === true) { - dfd.resolveWith(context, args); - } else if (resolveOrReject === false) { - dfd.rejectWith(context, args); - } - promise.abort = dfd.promise; - return this._enhancePromise(promise); - }, - - // Parses the Range header from the server response - // and returns the uploaded bytes: - _getUploadedBytes: function (jqXHR) { - var range = jqXHR.getResponseHeader('Range'), - parts = range && range.split('-'), - upperBytesPos = parts && parts.length > 1 && - parseInt(parts[1], 10); - return upperBytesPos && upperBytesPos + 1; - }, - - // Uploads a file in multiple, sequential requests - // by splitting the file up in multiple blob chunks. - // If the second parameter is true, only tests if the file - // should be uploaded in chunks, but does not invoke any - // upload requests: - _chunkedUpload: function (options, testOnly) { - var that = this, - file = options.files[0], - fs = file.size, - ub = options.uploadedBytes = options.uploadedBytes || 0, - mcs = options.maxChunkSize || fs, - slice = file.slice || file.webkitSlice || file.mozSlice, - dfd = $.Deferred(), - promise = dfd.promise(), - jqXHR, - upload; - if (!(this._isXHRUpload(options) && slice && (ub || mcs < fs)) || - options.data) { - return false; - } - if (testOnly) { - return true; - } - if (ub >= fs) { - file.error = 'Uploaded bytes exceed file size'; - return this._getXHRPromise( - false, - options.context, - [null, 'error', file.error] - ); - } - // The chunk upload method: - upload = function (i) { - // Clone the options object for each chunk upload: - var o = $.extend({}, options); - o.blob = slice.call( - file, - ub, - ub + mcs - ); - // Store the current chunk size, as the blob itself - // will be dereferenced after data processing: - o.chunkSize = o.blob.size; - // Expose the chunk bytes position range: - o.contentRange = 'bytes ' + ub + '-' + - (ub + o.chunkSize - 1) + '/' + fs; - // Process the upload data (the blob and potential form data): - that._initXHRData(o); - // Add progress listeners for this chunk upload: - that._initProgressListener(o); - jqXHR = ($.ajax(o) || that._getXHRPromise(false, o.context)) - .done(function (result, textStatus, jqXHR) { - ub = that._getUploadedBytes(jqXHR) || - (ub + o.chunkSize); - // Create a progress event if upload is done and - // no progress event has been invoked for this chunk: - if (!o.loaded) { - that._onProgress($.Event('progress', { - lengthComputable: true, - loaded: ub - o.uploadedBytes, - total: ub - o.uploadedBytes - }), o); - } - options.uploadedBytes = o.uploadedBytes = ub; - if (ub < fs) { - // File upload not yet complete, - // continue with the next chunk: - upload(); - } else { - dfd.resolveWith( - o.context, - [result, textStatus, jqXHR] - ); - } - }) - .fail(function (jqXHR, textStatus, errorThrown) { - dfd.rejectWith( - o.context, - [jqXHR, textStatus, errorThrown] - ); - }); - }; - this._enhancePromise(promise); - promise.abort = function () { - return jqXHR.abort(); - }; - upload(); - return promise; - }, - - _beforeSend: function (e, data) { - if (this._active === 0) { - // the start callback is triggered when an upload starts - // and no other uploads are currently running, - // equivalent to the global ajaxStart event: - this._trigger('start'); - // Set timer for global bitrate progress calculation: - this._bitrateTimer = new this._BitrateTimer(); - } - this._active += 1; - // Initialize the global progress values: - this._loaded += data.uploadedBytes || 0; - this._total += this._getTotal(data.files); - }, - - _onDone: function (result, textStatus, jqXHR, options) { - if (!this._isXHRUpload(options)) { - // Create a progress event for each iframe load: - this._onProgress($.Event('progress', { - lengthComputable: true, - loaded: 1, - total: 1 - }), options); - } - options.result = result; - options.textStatus = textStatus; - options.jqXHR = jqXHR; - this._trigger('done', null, options); - }, - - _onFail: function (jqXHR, textStatus, errorThrown, options) { - options.jqXHR = jqXHR; - options.textStatus = textStatus; - options.errorThrown = errorThrown; - this._trigger('fail', null, options); - if (options.recalculateProgress) { - // Remove the failed (error or abort) file upload from - // the global progress calculation: - this._loaded -= options.loaded || options.uploadedBytes || 0; - this._total -= options.total || this._getTotal(options.files); - } - }, - - _onAlways: function (jqXHRorResult, textStatus, jqXHRorError, options) { - this._active -= 1; - options.textStatus = textStatus; - if (jqXHRorError && jqXHRorError.always) { - options.jqXHR = jqXHRorError; - options.result = jqXHRorResult; - } else { - options.jqXHR = jqXHRorResult; - options.errorThrown = jqXHRorError; - } - this._trigger('always', null, options); - if (this._active === 0) { - // The stop callback is triggered when all uploads have - // been completed, equivalent to the global ajaxStop event: - this._trigger('stop'); - // Reset the global progress values: - this._loaded = this._total = 0; - this._bitrateTimer = null; - } - }, - - _onSend: function (e, data) { - var that = this, - jqXHR, - aborted, - slot, - pipe, - options = that._getAJAXSettings(data), - send = function () { - that._sending += 1; - // Set timer for bitrate progress calculation: - options._bitrateTimer = new that._BitrateTimer(); - jqXHR = jqXHR || ( - ((aborted || that._trigger('send', e, options) === false) && - that._getXHRPromise(false, options.context, aborted)) || - that._chunkedUpload(options) || $.ajax(options) - ).done(function (result, textStatus, jqXHR) { - that._onDone(result, textStatus, jqXHR, options); - }).fail(function (jqXHR, textStatus, errorThrown) { - that._onFail(jqXHR, textStatus, errorThrown, options); - }).always(function (jqXHRorResult, textStatus, jqXHRorError) { - that._sending -= 1; - that._onAlways( - jqXHRorResult, - textStatus, - jqXHRorError, - options - ); - if (options.limitConcurrentUploads && - options.limitConcurrentUploads > that._sending) { - // Start the next queued upload, - // that has not been aborted: - var nextSlot = that._slots.shift(), - isPending; - while (nextSlot) { - // jQuery 1.6 doesn't provide .state(), - // while jQuery 1.8+ removed .isRejected(): - isPending = nextSlot.state ? - nextSlot.state() === 'pending' : - !nextSlot.isRejected(); - if (isPending) { - nextSlot.resolve(); - break; - } - nextSlot = that._slots.shift(); - } - } - }); - return jqXHR; - }; - this._beforeSend(e, options); - if (this.options.sequentialUploads || - (this.options.limitConcurrentUploads && - this.options.limitConcurrentUploads <= this._sending)) { - if (this.options.limitConcurrentUploads > 1) { - slot = $.Deferred(); - this._slots.push(slot); - pipe = slot.pipe(send); - } else { - pipe = (this._sequence = this._sequence.pipe(send, send)); - } - // Return the piped Promise object, enhanced with an abort method, - // which is delegated to the jqXHR object of the current upload, - // and jqXHR callbacks mapped to the equivalent Promise methods: - pipe.abort = function () { - aborted = [undefined, 'abort', 'abort']; - if (!jqXHR) { - if (slot) { - slot.rejectWith(options.context, aborted); - } - return send(); - } - return jqXHR.abort(); - }; - return this._enhancePromise(pipe); - } - return send(); - }, - - _onAdd: function (e, data) { - var that = this, - result = true, - options = $.extend({}, this.options, data), - limit = options.limitMultiFileUploads, - paramName = this._getParamName(options), - paramNameSet, - paramNameSlice, - fileSet, - i; - if (!(options.singleFileUploads || limit) || - !this._isXHRUpload(options)) { - fileSet = [data.files]; - paramNameSet = [paramName]; - } else if (!options.singleFileUploads && limit) { - fileSet = []; - paramNameSet = []; - for (i = 0; i < data.files.length; i += limit) { - fileSet.push(data.files.slice(i, i + limit)); - paramNameSlice = paramName.slice(i, i + limit); - if (!paramNameSlice.length) { - paramNameSlice = paramName; - } - paramNameSet.push(paramNameSlice); - } - } else { - paramNameSet = paramName; - } - data.originalFiles = data.files; - $.each(fileSet || data.files, function (index, element) { - var newData = $.extend({}, data); - newData.files = fileSet ? element : [element]; - newData.paramName = paramNameSet[index]; - newData.submit = function () { - newData.jqXHR = this.jqXHR = - (that._trigger('submit', e, this) !== false) && - that._onSend(e, this); - return this.jqXHR; - }; - return (result = that._trigger('add', e, newData)); - }); - return result; - }, - - _replaceFileInput: function (input) { - var inputClone = input.clone(true); - $('
').append(inputClone)[0].reset(); - // Detaching allows to insert the fileInput on another form - // without loosing the file input value: - input.after(inputClone).detach(); - // Avoid memory leaks with the detached file input: - $.cleanData(input.unbind('remove')); - // Replace the original file input element in the fileInput - // elements set with the clone, which has been copied including - // event handlers: - this.options.fileInput = this.options.fileInput.map(function (i, el) { - if (el === input[0]) { - return inputClone[0]; - } - return el; - }); - // If the widget has been initialized on the file input itself, - // override this.element with the file input clone: - if (input[0] === this.element[0]) { - this.element = inputClone; - } - }, - - _handleFileTreeEntry: function (entry, path) { - var that = this, - dfd = $.Deferred(), - errorHandler = function (e) { - if (e && !e.entry) { - e.entry = entry; - } - // Since $.when returns immediately if one - // Deferred is rejected, we use resolve instead. - // This allows valid files and invalid items - // to be returned together in one set: - dfd.resolve([e]); - }, - dirReader; - path = path || ''; - if (entry.isFile) { - if (entry._file) { - // Workaround for Chrome bug #149735 - entry._file.relativePath = path; - dfd.resolve(entry._file); - } else { - entry.file(function (file) { - file.relativePath = path; - dfd.resolve(file); - }, errorHandler); - } - } else if (entry.isDirectory) { - dirReader = entry.createReader(); - dirReader.readEntries(function (entries) { - that._handleFileTreeEntries( - entries, - path + entry.name + '/' - ).done(function (files) { - dfd.resolve(files); - }).fail(errorHandler); - }, errorHandler); - } else { - // Return an empy list for file system items - // other than files or directories: - dfd.resolve([]); - } - return dfd.promise(); - }, - - _handleFileTreeEntries: function (entries, path) { - var that = this; - return $.when.apply( - $, - $.map(entries, function (entry) { - return that._handleFileTreeEntry(entry, path); - }) - ).pipe(function () { - return Array.prototype.concat.apply( - [], - arguments - ); - }); - }, - - _getDroppedFiles: function (dataTransfer) { - dataTransfer = dataTransfer || {}; - var items = dataTransfer.items; - if (items && items.length && (items[0].webkitGetAsEntry || - items[0].getAsEntry)) { - return this._handleFileTreeEntries( - $.map(items, function (item) { - var entry; - if (item.webkitGetAsEntry) { - entry = item.webkitGetAsEntry(); - if (entry) { - // Workaround for Chrome bug #149735: - entry._file = item.getAsFile(); - } - return entry; - } - return item.getAsEntry(); - }) - ); - } - return $.Deferred().resolve( - $.makeArray(dataTransfer.files) - ).promise(); - }, - - _getSingleFileInputFiles: function (fileInput) { - fileInput = $(fileInput); - var entries = fileInput.prop('webkitEntries') || - fileInput.prop('entries'), - files, - value; - if (entries && entries.length) { - return this._handleFileTreeEntries(entries); - } - files = $.makeArray(fileInput.prop('files')); - if (!files.length) { - value = fileInput.prop('value'); - if (!value) { - return $.Deferred().resolve([]).promise(); - } - // If the files property is not available, the browser does not - // support the File API and we add a pseudo File object with - // the input value as name with path information removed: - files = [{name: value.replace(/^.*\\/, '')}]; - } else if (files[0].name === undefined && files[0].fileName) { - // File normalization for Safari 4 and Firefox 3: - $.each(files, function (index, file) { - file.name = file.fileName; - file.size = file.fileSize; - }); - } - return $.Deferred().resolve(files).promise(); - }, - - _getFileInputFiles: function (fileInput) { - if (!(fileInput instanceof $) || fileInput.length === 1) { - return this._getSingleFileInputFiles(fileInput); - } - return $.when.apply( - $, - $.map(fileInput, this._getSingleFileInputFiles) - ).pipe(function () { - return Array.prototype.concat.apply( - [], - arguments - ); - }); - }, - - _onChange: function (e) { - var that = this, - data = { - fileInput: $(e.target), - form: $(e.target.form) - }; - this._getFileInputFiles(data.fileInput).always(function (files) { - data.files = files; - if (that.options.replaceFileInput) { - that._replaceFileInput(data.fileInput); - } - if (that._trigger('change', e, data) !== false) { - that._onAdd(e, data); - } - }); - }, - - _onPaste: function (e) { - var cbd = e.originalEvent.clipboardData, - items = (cbd && cbd.items) || [], - data = {files: []}; - $.each(items, function (index, item) { - var file = item.getAsFile && item.getAsFile(); - if (file) { - data.files.push(file); - } - }); - if (this._trigger('paste', e, data) === false || - this._onAdd(e, data) === false) { - return false; - } - }, - - _onDrop: function (e) { - e.preventDefault(); - var that = this, - dataTransfer = e.dataTransfer = e.originalEvent.dataTransfer, - data = {}; - this._getDroppedFiles(dataTransfer).always(function (files) { - data.files = files; - if (that._trigger('drop', e, data) !== false) { - that._onAdd(e, data); - } - }); - }, - - _onDragOver: function (e) { - var dataTransfer = e.dataTransfer = e.originalEvent.dataTransfer; - if (this._trigger('dragover', e) === false) { - return false; - } - if (dataTransfer) { - dataTransfer.dropEffect = 'copy'; - } - e.preventDefault(); - }, - - _initEventHandlers: function () { - if (this._isXHRUpload(this.options)) { - this._on(this.options.dropZone, { - dragover: this._onDragOver, - drop: this._onDrop - }); - this._on(this.options.pasteZone, { - paste: this._onPaste - }); - } - this._on(this.options.fileInput, { - change: this._onChange - }); - }, - - _destroyEventHandlers: function () { - this._off(this.options.dropZone, 'dragover drop'); - this._off(this.options.pasteZone, 'paste'); - this._off(this.options.fileInput, 'change'); - }, - - _setOption: function (key, value) { - var refresh = $.inArray(key, this._refreshOptionsList) !== -1; - if (refresh) { - this._destroyEventHandlers(); - } - this._super(key, value); - if (refresh) { - this._initSpecialOptions(); - this._initEventHandlers(); - } - }, - - _initSpecialOptions: function () { - var options = this.options; - if (options.fileInput === undefined) { - options.fileInput = this.element.is('input[type="file"]') ? - this.element : this.element.find('input[type="file"]'); - } else if (!(options.fileInput instanceof $)) { - options.fileInput = $(options.fileInput); - } - if (!(options.dropZone instanceof $)) { - options.dropZone = $(options.dropZone); - } - if (!(options.pasteZone instanceof $)) { - options.pasteZone = $(options.pasteZone); - } - }, - - _create: function () { - var options = this.options; - // Initialize options set via HTML5 data-attributes: - $.extend(options, $(this.element[0].cloneNode(false)).data()); - this._initSpecialOptions(); - this._slots = []; - this._sequence = this._getXHRPromise(true); - this._sending = this._active = this._loaded = this._total = 0; - this._initEventHandlers(); - }, - - _destroy: function () { - this._destroyEventHandlers(); - }, - - // This method is exposed to the widget API and allows adding files - // using the fileupload API. The data parameter accepts an object which - // must have a files property and can contain additional options: - // .fileupload('add', {files: filesList}); - add: function (data) { - var that = this; - if (!data || this.options.disabled) { - return; - } - if (data.fileInput && !data.files) { - this._getFileInputFiles(data.fileInput).always(function (files) { - data.files = files; - that._onAdd(null, data); - }); - } else { - data.files = $.makeArray(data.files); - this._onAdd(null, data); - } - }, - - // This method is exposed to the widget API and allows sending files - // using the fileupload API. The data parameter accepts an object which - // must have a files or fileInput property and can contain additional options: - // .fileupload('send', {files: filesList}); - // The method returns a Promise object for the file upload call. - send: function (data) { - if (data && !this.options.disabled) { - if (data.fileInput && !data.files) { - var that = this, - dfd = $.Deferred(), - promise = dfd.promise(), - jqXHR, - aborted; - promise.abort = function () { - aborted = true; - if (jqXHR) { - return jqXHR.abort(); - } - dfd.reject(null, 'abort', 'abort'); - return promise; - }; - this._getFileInputFiles(data.fileInput).always( - function (files) { - if (aborted) { - return; - } - data.files = files; - jqXHR = that._onSend(null, data).then( - function (result, textStatus, jqXHR) { - dfd.resolve(result, textStatus, jqXHR); - }, - function (jqXHR, textStatus, errorThrown) { - dfd.reject(jqXHR, textStatus, errorThrown); - } - ); - } - ); - return this._enhancePromise(promise); - } - data.files = $.makeArray(data.files); - if (data.files.length) { - return this._onSend(null, data); - } - } - return this._getXHRPromise(false, data && data.context); - } - - }); - -})); diff --git a/spec/dummy/vendor/assets/javascripts/jquery.iframe-transport.js b/spec/dummy/vendor/assets/javascripts/jquery.iframe-transport.js deleted file mode 100644 index 4749f469..00000000 --- a/spec/dummy/vendor/assets/javascripts/jquery.iframe-transport.js +++ /dev/null @@ -1,172 +0,0 @@ -/* - * jQuery Iframe Transport Plugin 1.5 - * https://github.com/blueimp/jQuery-File-Upload - * - * Copyright 2011, Sebastian Tschan - * https://blueimp.net - * - * Licensed under the MIT license: - * http://www.opensource.org/licenses/MIT - */ - -/*jslint unparam: true, nomen: true */ -/*global define, window, document */ - -(function (factory) { - 'use strict'; - if (typeof define === 'function' && define.amd) { - // Register as an anonymous AMD module: - define(['jquery'], factory); - } else { - // Browser globals: - factory(window.jQuery); - } -}(function ($) { - 'use strict'; - - // Helper variable to create unique names for the transport iframes: - var counter = 0; - - // The iframe transport accepts three additional options: - // options.fileInput: a jQuery collection of file input fields - // options.paramName: the parameter name for the file form data, - // overrides the name property of the file input field(s), - // can be a string or an array of strings. - // options.formData: an array of objects with name and value properties, - // equivalent to the return data of .serializeArray(), e.g.: - // [{name: 'a', value: 1}, {name: 'b', value: 2}] - $.ajaxTransport('iframe', function (options) { - if (options.async && (options.type === 'POST' || options.type === 'GET')) { - var form, - iframe; - return { - send: function (_, completeCallback) { - form = $('
'); - form.attr('accept-charset', options.formAcceptCharset); - // javascript:false as initial iframe src - // prevents warning popups on HTTPS in IE6. - // IE versions below IE8 cannot set the name property of - // elements that have already been added to the DOM, - // so we set the name along with the iframe HTML markup: - iframe = $( - '' - ).bind('load', function () { - var fileInputClones, - paramNames = $.isArray(options.paramName) ? - options.paramName : [options.paramName]; - iframe - .unbind('load') - .bind('load', function () { - var response; - // Wrap in a try/catch block to catch exceptions thrown - // when trying to access cross-domain iframe contents: - try { - response = iframe.contents(); - // Google Chrome and Firefox do not throw an - // exception when calling iframe.contents() on - // cross-domain requests, so we unify the response: - if (!response.length || !response[0].firstChild) { - throw new Error(); - } - } catch (e) { - response = undefined; - } - // The complete callback returns the - // iframe content document as response object: - completeCallback( - 200, - 'success', - {'iframe': response} - ); - // Fix for IE endless progress bar activity bug - // (happens on form submits to iframe targets): - $('') - .appendTo(form); - form.remove(); - }); - form - .prop('target', iframe.prop('name')) - .prop('action', options.url) - .prop('method', options.type); - if (options.formData) { - $.each(options.formData, function (index, field) { - $('') - .prop('name', field.name) - .val(field.value) - .appendTo(form); - }); - } - if (options.fileInput && options.fileInput.length && - options.type === 'POST') { - fileInputClones = options.fileInput.clone(); - // Insert a clone for each file input field: - options.fileInput.after(function (index) { - return fileInputClones[index]; - }); - if (options.paramName) { - options.fileInput.each(function (index) { - $(this).prop( - 'name', - paramNames[index] || options.paramName - ); - }); - } - // Appending the file input fields to the hidden form - // removes them from their original location: - form - .append(options.fileInput) - .prop('enctype', 'multipart/form-data') - // enctype must be set as encoding for IE: - .prop('encoding', 'multipart/form-data'); - } - form.submit(); - // Insert the file input fields at their original location - // by replacing the clones with the originals: - if (fileInputClones && fileInputClones.length) { - options.fileInput.each(function (index, input) { - var clone = $(fileInputClones[index]); - $(input).prop('name', clone.prop('name')); - clone.replaceWith(input); - }); - } - }); - form.append(iframe).appendTo(document.body); - }, - abort: function () { - if (iframe) { - // javascript:false as iframe src aborts the request - // and prevents warning popups on HTTPS in IE6. - // concat is used to avoid the "Script URL" JSLint error: - iframe - .unbind('load') - .prop('src', 'javascript'.concat(':false;')); - } - if (form) { - form.remove(); - } - } - }; - } - }); - - // The iframe transport returns the iframe content document as response. - // The following adds converters from iframe to text, json, html, and script: - $.ajaxSetup({ - converters: { - 'iframe text': function (iframe) { - return $(iframe[0].body).text(); - }, - 'iframe json': function (iframe) { - return $.parseJSON($(iframe[0].body).text()); - }, - 'iframe html': function (iframe) { - return $(iframe[0].body).html(); - }, - 'iframe script': function (iframe) { - return $.globalEval($(iframe[0].body).text()); - } - } - }); - -})); diff --git a/spec/dummy/vendor/assets/javascripts/jquery.ui.widget.js b/spec/dummy/vendor/assets/javascripts/jquery.ui.widget.js deleted file mode 100644 index 886aff69..00000000 --- a/spec/dummy/vendor/assets/javascripts/jquery.ui.widget.js +++ /dev/null @@ -1,528 +0,0 @@ -/* - * jQuery UI Widget 1.9.1+amd - * https://github.com/blueimp/jQuery-File-Upload - * - * Copyright 2012 jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/jQuery.widget/ - */ - -(function (factory) { - if (typeof define === "function" && define.amd) { - // Register as an anonymous AMD module: - define(["jquery"], factory); - } else { - // Browser globals: - factory(jQuery); - } -}(function( $, undefined ) { - -var uuid = 0, - slice = Array.prototype.slice, - _cleanData = $.cleanData; -$.cleanData = function( elems ) { - for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { - try { - $( elem ).triggerHandler( "remove" ); - // http://bugs.jquery.com/ticket/8235 - } catch( e ) {} - } - _cleanData( elems ); -}; - -$.widget = function( name, base, prototype ) { - var fullName, existingConstructor, constructor, basePrototype, - namespace = name.split( "." )[ 0 ]; - - name = name.split( "." )[ 1 ]; - fullName = namespace + "-" + name; - - if ( !prototype ) { - prototype = base; - base = $.Widget; - } - - // create selector for plugin - $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) { - return !!$.data( elem, fullName ); - }; - - $[ namespace ] = $[ namespace ] || {}; - existingConstructor = $[ namespace ][ name ]; - constructor = $[ namespace ][ name ] = function( options, element ) { - // allow instantiation without "new" keyword - if ( !this._createWidget ) { - return new constructor( options, element ); - } - - // allow instantiation without initializing for simple inheritance - // must use "new" keyword (the code above always passes args) - if ( arguments.length ) { - this._createWidget( options, element ); - } - }; - // extend with the existing constructor to carry over any static properties - $.extend( constructor, existingConstructor, { - version: prototype.version, - // copy the object used to create the prototype in case we need to - // redefine the widget later - _proto: $.extend( {}, prototype ), - // track widgets that inherit from this widget in case this widget is - // redefined after a widget inherits from it - _childConstructors: [] - }); - - basePrototype = new base(); - // we need to make the options hash a property directly on the new instance - // otherwise we'll modify the options hash on the prototype that we're - // inheriting from - basePrototype.options = $.widget.extend( {}, basePrototype.options ); - $.each( prototype, function( prop, value ) { - if ( $.isFunction( value ) ) { - prototype[ prop ] = (function() { - var _super = function() { - return base.prototype[ prop ].apply( this, arguments ); - }, - _superApply = function( args ) { - return base.prototype[ prop ].apply( this, args ); - }; - return function() { - var __super = this._super, - __superApply = this._superApply, - returnValue; - - this._super = _super; - this._superApply = _superApply; - - returnValue = value.apply( this, arguments ); - - this._super = __super; - this._superApply = __superApply; - - return returnValue; - }; - })(); - } - }); - constructor.prototype = $.widget.extend( basePrototype, { - // TODO: remove support for widgetEventPrefix - // always use the name + a colon as the prefix, e.g., draggable:start - // don't prefix for widgets that aren't DOM-based - widgetEventPrefix: basePrototype.widgetEventPrefix || name - }, prototype, { - constructor: constructor, - namespace: namespace, - widgetName: name, - // TODO remove widgetBaseClass, see #8155 - widgetBaseClass: fullName, - widgetFullName: fullName - }); - - // If this widget is being redefined then we need to find all widgets that - // are inheriting from it and redefine all of them so that they inherit from - // the new version of this widget. We're essentially trying to replace one - // level in the prototype chain. - if ( existingConstructor ) { - $.each( existingConstructor._childConstructors, function( i, child ) { - var childPrototype = child.prototype; - - // redefine the child widget using the same prototype that was - // originally used, but inherit from the new version of the base - $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto ); - }); - // remove the list of existing child constructors from the old constructor - // so the old child constructors can be garbage collected - delete existingConstructor._childConstructors; - } else { - base._childConstructors.push( constructor ); - } - - $.widget.bridge( name, constructor ); -}; - -$.widget.extend = function( target ) { - var input = slice.call( arguments, 1 ), - inputIndex = 0, - inputLength = input.length, - key, - value; - for ( ; inputIndex < inputLength; inputIndex++ ) { - for ( key in input[ inputIndex ] ) { - value = input[ inputIndex ][ key ]; - if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) { - // Clone objects - if ( $.isPlainObject( value ) ) { - target[ key ] = $.isPlainObject( target[ key ] ) ? - $.widget.extend( {}, target[ key ], value ) : - // Don't extend strings, arrays, etc. with objects - $.widget.extend( {}, value ); - // Copy everything else by reference - } else { - target[ key ] = value; - } - } - } - } - return target; -}; - -$.widget.bridge = function( name, object ) { - var fullName = object.prototype.widgetFullName; - $.fn[ name ] = function( options ) { - var isMethodCall = typeof options === "string", - args = slice.call( arguments, 1 ), - returnValue = this; - - // allow multiple hashes to be passed on init - options = !isMethodCall && args.length ? - $.widget.extend.apply( null, [ options ].concat(args) ) : - options; - - if ( isMethodCall ) { - this.each(function() { - var methodValue, - instance = $.data( this, fullName ); - if ( !instance ) { - return $.error( "cannot call methods on " + name + " prior to initialization; " + - "attempted to call method '" + options + "'" ); - } - if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) { - return $.error( "no such method '" + options + "' for " + name + " widget instance" ); - } - methodValue = instance[ options ].apply( instance, args ); - if ( methodValue !== instance && methodValue !== undefined ) { - returnValue = methodValue && methodValue.jquery ? - returnValue.pushStack( methodValue.get() ) : - methodValue; - return false; - } - }); - } else { - this.each(function() { - var instance = $.data( this, fullName ); - if ( instance ) { - instance.option( options || {} )._init(); - } else { - new object( options, this ); - } - }); - } - - return returnValue; - }; -}; - -$.Widget = function( /* options, element */ ) {}; -$.Widget._childConstructors = []; - -$.Widget.prototype = { - widgetName: "widget", - widgetEventPrefix: "", - defaultElement: "
", - options: { - disabled: false, - - // callbacks - create: null - }, - _createWidget: function( options, element ) { - element = $( element || this.defaultElement || this )[ 0 ]; - this.element = $( element ); - this.uuid = uuid++; - this.eventNamespace = "." + this.widgetName + this.uuid; - this.options = $.widget.extend( {}, - this.options, - this._getCreateOptions(), - options ); - - this.bindings = $(); - this.hoverable = $(); - this.focusable = $(); - - if ( element !== this ) { - // 1.9 BC for #7810 - // TODO remove dual storage - $.data( element, this.widgetName, this ); - $.data( element, this.widgetFullName, this ); - this._on( this.element, { - remove: function( event ) { - if ( event.target === element ) { - this.destroy(); - } - } - }); - this.document = $( element.style ? - // element within the document - element.ownerDocument : - // element is window or document - element.document || element ); - this.window = $( this.document[0].defaultView || this.document[0].parentWindow ); - } - - this._create(); - this._trigger( "create", null, this._getCreateEventData() ); - this._init(); - }, - _getCreateOptions: $.noop, - _getCreateEventData: $.noop, - _create: $.noop, - _init: $.noop, - - destroy: function() { - this._destroy(); - // we can probably remove the unbind calls in 2.0 - // all event bindings should go through this._on() - this.element - .unbind( this.eventNamespace ) - // 1.9 BC for #7810 - // TODO remove dual storage - .removeData( this.widgetName ) - .removeData( this.widgetFullName ) - // support: jquery <1.6.3 - // http://bugs.jquery.com/ticket/9413 - .removeData( $.camelCase( this.widgetFullName ) ); - this.widget() - .unbind( this.eventNamespace ) - .removeAttr( "aria-disabled" ) - .removeClass( - this.widgetFullName + "-disabled " + - "ui-state-disabled" ); - - // clean up events and states - this.bindings.unbind( this.eventNamespace ); - this.hoverable.removeClass( "ui-state-hover" ); - this.focusable.removeClass( "ui-state-focus" ); - }, - _destroy: $.noop, - - widget: function() { - return this.element; - }, - - option: function( key, value ) { - var options = key, - parts, - curOption, - i; - - if ( arguments.length === 0 ) { - // don't return a reference to the internal hash - return $.widget.extend( {}, this.options ); - } - - if ( typeof key === "string" ) { - // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } } - options = {}; - parts = key.split( "." ); - key = parts.shift(); - if ( parts.length ) { - curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] ); - for ( i = 0; i < parts.length - 1; i++ ) { - curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {}; - curOption = curOption[ parts[ i ] ]; - } - key = parts.pop(); - if ( value === undefined ) { - return curOption[ key ] === undefined ? null : curOption[ key ]; - } - curOption[ key ] = value; - } else { - if ( value === undefined ) { - return this.options[ key ] === undefined ? null : this.options[ key ]; - } - options[ key ] = value; - } - } - - this._setOptions( options ); - - return this; - }, - _setOptions: function( options ) { - var key; - - for ( key in options ) { - this._setOption( key, options[ key ] ); - } - - return this; - }, - _setOption: function( key, value ) { - this.options[ key ] = value; - - if ( key === "disabled" ) { - this.widget() - .toggleClass( this.widgetFullName + "-disabled ui-state-disabled", !!value ) - .attr( "aria-disabled", value ); - this.hoverable.removeClass( "ui-state-hover" ); - this.focusable.removeClass( "ui-state-focus" ); - } - - return this; - }, - - enable: function() { - return this._setOption( "disabled", false ); - }, - disable: function() { - return this._setOption( "disabled", true ); - }, - - _on: function( element, handlers ) { - var delegateElement, - instance = this; - // no element argument, shuffle and use this.element - if ( !handlers ) { - handlers = element; - element = this.element; - delegateElement = this.widget(); - } else { - // accept selectors, DOM elements - element = delegateElement = $( element ); - this.bindings = this.bindings.add( element ); - } - - $.each( handlers, function( event, handler ) { - function handlerProxy() { - // allow widgets to customize the disabled handling - // - disabled as an array instead of boolean - // - disabled class as method for disabling individual parts - if ( instance.options.disabled === true || - $( this ).hasClass( "ui-state-disabled" ) ) { - return; - } - return ( typeof handler === "string" ? instance[ handler ] : handler ) - .apply( instance, arguments ); - } - - // copy the guid so direct unbinding works - if ( typeof handler !== "string" ) { - handlerProxy.guid = handler.guid = - handler.guid || handlerProxy.guid || $.guid++; - } - - var match = event.match( /^(\w+)\s*(.*)$/ ), - eventName = match[1] + instance.eventNamespace, - selector = match[2]; - if ( selector ) { - delegateElement.delegate( selector, eventName, handlerProxy ); - } else { - element.bind( eventName, handlerProxy ); - } - }); - }, - - _off: function( element, eventName ) { - eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace; - element.unbind( eventName ).undelegate( eventName ); - }, - - _delay: function( handler, delay ) { - function handlerProxy() { - return ( typeof handler === "string" ? instance[ handler ] : handler ) - .apply( instance, arguments ); - } - var instance = this; - return setTimeout( handlerProxy, delay || 0 ); - }, - - _hoverable: function( element ) { - this.hoverable = this.hoverable.add( element ); - this._on( element, { - mouseenter: function( event ) { - $( event.currentTarget ).addClass( "ui-state-hover" ); - }, - mouseleave: function( event ) { - $( event.currentTarget ).removeClass( "ui-state-hover" ); - } - }); - }, - - _focusable: function( element ) { - this.focusable = this.focusable.add( element ); - this._on( element, { - focusin: function( event ) { - $( event.currentTarget ).addClass( "ui-state-focus" ); - }, - focusout: function( event ) { - $( event.currentTarget ).removeClass( "ui-state-focus" ); - } - }); - }, - - _trigger: function( type, event, data ) { - var prop, orig, - callback = this.options[ type ]; - - data = data || {}; - event = $.Event( event ); - event.type = ( type === this.widgetEventPrefix ? - type : - this.widgetEventPrefix + type ).toLowerCase(); - // the original event may come from any element - // so we need to reset the target on the new event - event.target = this.element[ 0 ]; - - // copy original event properties over to the new event - orig = event.originalEvent; - if ( orig ) { - for ( prop in orig ) { - if ( !( prop in event ) ) { - event[ prop ] = orig[ prop ]; - } - } - } - - this.element.trigger( event, data ); - return !( $.isFunction( callback ) && - callback.apply( this.element[0], [ event ].concat( data ) ) === false || - event.isDefaultPrevented() ); - } -}; - -$.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) { - $.Widget.prototype[ "_" + method ] = function( element, options, callback ) { - if ( typeof options === "string" ) { - options = { effect: options }; - } - var hasOptions, - effectName = !options ? - method : - options === true || typeof options === "number" ? - defaultEffect : - options.effect || defaultEffect; - options = options || {}; - if ( typeof options === "number" ) { - options = { duration: options }; - } - hasOptions = !$.isEmptyObject( options ); - options.complete = callback; - if ( options.delay ) { - element.delay( options.delay ); - } - if ( hasOptions && $.effects && ( $.effects.effect[ effectName ] || $.uiBackCompat !== false && $.effects[ effectName ] ) ) { - element[ method ]( options ); - } else if ( effectName !== method && element[ effectName ] ) { - element[ effectName ]( options.duration, options.easing, callback ); - } else { - element.queue(function( next ) { - $( this )[ method ](); - if ( callback ) { - callback.call( element[ 0 ] ); - } - next(); - }); - } - }; -}); - -// DEPRECATED -if ( $.uiBackCompat !== false ) { - $.Widget.prototype._getCreateOptions = function() { - return $.metadata && $.metadata.get( this.element[0] )[ this.widgetName ]; - }; -} - -})); From 7468566d58cf7945784c036a7cdafb8f23826560 Mon Sep 17 00:00:00 2001 From: Fabio Napoleoni Date: Mon, 2 Oct 2017 22:26:57 +0200 Subject: [PATCH 09/29] Moved dummy4 to dummy --- spec/{dummy4 => dummy}/.bowerrc | 0 spec/{dummy4 => dummy}/.gitignore | 0 spec/{dummy4 => dummy}/Gemfile | 0 spec/{dummy4 => dummy}/README.rdoc | 0 spec/{dummy4 => dummy}/Rakefile | 0 .../app/active_record/note.rb | 0 .../{dummy4 => dummy}/app/assets/images/.keep | 0 .../app/assets/javascripts/application.js | 0 .../app/assets/javascripts/notes.coffee | 0 .../app/assets/stylesheets/application.scss | 0 .../app/assets/stylesheets/notes.scss | 0 .../app/assets/stylesheets/scaffolds.scss | 0 .../app/controllers/application_controller.rb | 0 .../app/controllers/concerns/.keep | 0 .../app/controllers/notes_controller.rb | 0 .../app/helpers/application_helper.rb | 0 .../app/helpers/notes_helper.rb | 0 spec/{dummy4 => dummy}/app/mailers/.keep | 0 spec/{dummy4 => dummy}/app/models/.keep | 0 .../app/models/concerns/.keep | 0 spec/{dummy4 => dummy}/app/mongoid/note.rb | 0 .../app/views/layouts/application.html.erb | 0 .../app/views/notes/_form.html.erb | 0 .../app/views/notes/_form_builder.html.erb | 0 .../app/views/notes/_form_nojs.html.erb | 0 .../app/views/notes/_form_raw.html.erb | 0 .../views/notes/_form_simple_form.html.erb | 0 .../app/views/notes/_note.html.erb | 0 .../app/views/notes/edit.html.erb | 0 .../app/views/notes/index.html.erb | 0 .../app/views/notes/index.json.jbuilder | 0 .../app/views/notes/new.html.erb | 0 .../app/views/notes/show.html.erb | 0 .../app/views/notes/show.json.jbuilder | 0 spec/{dummy4 => dummy}/bower.json | 0 spec/{dummy4 => dummy}/config.ru | 0 spec/{dummy4 => dummy}/config/application.rb | 0 spec/{dummy4 => dummy}/config/boot.rb | 0 spec/{dummy4 => dummy}/config/database.yml | 0 spec/{dummy4 => dummy}/config/environment.rb | 0 .../config/environments/development.rb | 0 .../config/environments/production.rb | 0 .../config/environments/test.rb | 0 .../config/initializers/assets.rb | 0 .../config/initializers/attachinary.rb | 0 .../initializers/backtrace_silencers.rb | 0 .../config/initializers/cookies_serializer.rb | 0 .../initializers/filter_parameter_logging.rb | 0 .../config/initializers/inflections.rb | 0 .../config/initializers/mime_types.rb | 0 .../config/initializers/session_store.rb | 0 .../config/initializers/wrap_parameters.rb | 0 spec/{dummy4 => dummy}/config/locales/en.yml | 0 spec/{dummy4 => dummy}/config/mongoid.yml | 0 spec/{dummy4 => dummy}/config/routes.rb | 0 spec/{dummy4 => dummy}/config/secrets.yml | 0 spec/{dummy4 => dummy}/lib/assets/.keep | 0 spec/{dummy4 => dummy}/lib/tasks/.keep | 0 spec/{dummy4 => dummy}/log/.keep | 0 spec/{dummy4 => dummy}/public/404.html | 0 spec/{dummy4 => dummy}/public/422.html | 0 spec/{dummy4 => dummy}/public/500.html | 0 spec/{dummy4 => dummy}/public/favicon.ico | 0 spec/{dummy4 => dummy}/public/robots.txt | 0 spec/{dummy4 => dummy}/spec/rails_helper.rb | 0 spec/{dummy4 => dummy}/spec/spec_helper.rb | 0 spec/{dummy4 => dummy}/test/controllers/.keep | 0 .../test/controllers/notes_controller_test.rb | 0 spec/{dummy4 => dummy}/test/fixtures/.keep | 0 .../{dummy4 => dummy}/test/fixtures/notes.yml | 0 spec/{dummy4 => dummy}/test/helpers/.keep | 0 spec/{dummy4 => dummy}/test/integration/.keep | 0 spec/{dummy4 => dummy}/test/mailers/.keep | 0 spec/{dummy4 => dummy}/test/models/.keep | 0 .../test/models/note_test.rb | 0 spec/{dummy4 => dummy}/test/test_helper.rb | 0 spec/dummy4/Gemfile.lock | 306 ------------------ spec/dummy4/db/seeds.rb | 7 - spec/dummy4/vendor/assets/javascripts/.keep | 0 spec/dummy4/vendor/assets/stylesheets/.keep | 0 spec/rails_helper.rb | 2 +- 81 files changed, 1 insertion(+), 314 deletions(-) rename spec/{dummy4 => dummy}/.bowerrc (100%) rename spec/{dummy4 => dummy}/.gitignore (100%) rename spec/{dummy4 => dummy}/Gemfile (100%) rename spec/{dummy4 => dummy}/README.rdoc (100%) rename spec/{dummy4 => dummy}/Rakefile (100%) rename spec/{dummy4 => dummy}/app/active_record/note.rb (100%) rename spec/{dummy4 => dummy}/app/assets/images/.keep (100%) rename spec/{dummy4 => dummy}/app/assets/javascripts/application.js (100%) rename spec/{dummy4 => dummy}/app/assets/javascripts/notes.coffee (100%) rename spec/{dummy4 => dummy}/app/assets/stylesheets/application.scss (100%) rename spec/{dummy4 => dummy}/app/assets/stylesheets/notes.scss (100%) rename spec/{dummy4 => dummy}/app/assets/stylesheets/scaffolds.scss (100%) rename spec/{dummy4 => dummy}/app/controllers/application_controller.rb (100%) rename spec/{dummy4 => dummy}/app/controllers/concerns/.keep (100%) rename spec/{dummy4 => dummy}/app/controllers/notes_controller.rb (100%) rename spec/{dummy4 => dummy}/app/helpers/application_helper.rb (100%) rename spec/{dummy4 => dummy}/app/helpers/notes_helper.rb (100%) rename spec/{dummy4 => dummy}/app/mailers/.keep (100%) rename spec/{dummy4 => dummy}/app/models/.keep (100%) rename spec/{dummy4 => dummy}/app/models/concerns/.keep (100%) rename spec/{dummy4 => dummy}/app/mongoid/note.rb (100%) rename spec/{dummy4 => dummy}/app/views/layouts/application.html.erb (100%) rename spec/{dummy4 => dummy}/app/views/notes/_form.html.erb (100%) rename spec/{dummy4 => dummy}/app/views/notes/_form_builder.html.erb (100%) rename spec/{dummy4 => dummy}/app/views/notes/_form_nojs.html.erb (100%) rename spec/{dummy4 => dummy}/app/views/notes/_form_raw.html.erb (100%) rename spec/{dummy4 => dummy}/app/views/notes/_form_simple_form.html.erb (100%) rename spec/{dummy4 => dummy}/app/views/notes/_note.html.erb (100%) rename spec/{dummy4 => dummy}/app/views/notes/edit.html.erb (100%) rename spec/{dummy4 => dummy}/app/views/notes/index.html.erb (100%) rename spec/{dummy4 => dummy}/app/views/notes/index.json.jbuilder (100%) rename spec/{dummy4 => dummy}/app/views/notes/new.html.erb (100%) rename spec/{dummy4 => dummy}/app/views/notes/show.html.erb (100%) rename spec/{dummy4 => dummy}/app/views/notes/show.json.jbuilder (100%) rename spec/{dummy4 => dummy}/bower.json (100%) rename spec/{dummy4 => dummy}/config.ru (100%) rename spec/{dummy4 => dummy}/config/application.rb (100%) rename spec/{dummy4 => dummy}/config/boot.rb (100%) rename spec/{dummy4 => dummy}/config/database.yml (100%) rename spec/{dummy4 => dummy}/config/environment.rb (100%) rename spec/{dummy4 => dummy}/config/environments/development.rb (100%) rename spec/{dummy4 => dummy}/config/environments/production.rb (100%) rename spec/{dummy4 => dummy}/config/environments/test.rb (100%) rename spec/{dummy4 => dummy}/config/initializers/assets.rb (100%) rename spec/{dummy4 => dummy}/config/initializers/attachinary.rb (100%) rename spec/{dummy4 => dummy}/config/initializers/backtrace_silencers.rb (100%) rename spec/{dummy4 => dummy}/config/initializers/cookies_serializer.rb (100%) rename spec/{dummy4 => dummy}/config/initializers/filter_parameter_logging.rb (100%) rename spec/{dummy4 => dummy}/config/initializers/inflections.rb (100%) rename spec/{dummy4 => dummy}/config/initializers/mime_types.rb (100%) rename spec/{dummy4 => dummy}/config/initializers/session_store.rb (100%) rename spec/{dummy4 => dummy}/config/initializers/wrap_parameters.rb (100%) rename spec/{dummy4 => dummy}/config/locales/en.yml (100%) rename spec/{dummy4 => dummy}/config/mongoid.yml (100%) rename spec/{dummy4 => dummy}/config/routes.rb (100%) rename spec/{dummy4 => dummy}/config/secrets.yml (100%) rename spec/{dummy4 => dummy}/lib/assets/.keep (100%) rename spec/{dummy4 => dummy}/lib/tasks/.keep (100%) rename spec/{dummy4 => dummy}/log/.keep (100%) rename spec/{dummy4 => dummy}/public/404.html (100%) rename spec/{dummy4 => dummy}/public/422.html (100%) rename spec/{dummy4 => dummy}/public/500.html (100%) rename spec/{dummy4 => dummy}/public/favicon.ico (100%) rename spec/{dummy4 => dummy}/public/robots.txt (100%) rename spec/{dummy4 => dummy}/spec/rails_helper.rb (100%) rename spec/{dummy4 => dummy}/spec/spec_helper.rb (100%) rename spec/{dummy4 => dummy}/test/controllers/.keep (100%) rename spec/{dummy4 => dummy}/test/controllers/notes_controller_test.rb (100%) rename spec/{dummy4 => dummy}/test/fixtures/.keep (100%) rename spec/{dummy4 => dummy}/test/fixtures/notes.yml (100%) rename spec/{dummy4 => dummy}/test/helpers/.keep (100%) rename spec/{dummy4 => dummy}/test/integration/.keep (100%) rename spec/{dummy4 => dummy}/test/mailers/.keep (100%) rename spec/{dummy4 => dummy}/test/models/.keep (100%) rename spec/{dummy4 => dummy}/test/models/note_test.rb (100%) rename spec/{dummy4 => dummy}/test/test_helper.rb (100%) delete mode 100644 spec/dummy4/Gemfile.lock delete mode 100644 spec/dummy4/db/seeds.rb delete mode 100644 spec/dummy4/vendor/assets/javascripts/.keep delete mode 100644 spec/dummy4/vendor/assets/stylesheets/.keep diff --git a/spec/dummy4/.bowerrc b/spec/dummy/.bowerrc similarity index 100% rename from spec/dummy4/.bowerrc rename to spec/dummy/.bowerrc diff --git a/spec/dummy4/.gitignore b/spec/dummy/.gitignore similarity index 100% rename from spec/dummy4/.gitignore rename to spec/dummy/.gitignore diff --git a/spec/dummy4/Gemfile b/spec/dummy/Gemfile similarity index 100% rename from spec/dummy4/Gemfile rename to spec/dummy/Gemfile diff --git a/spec/dummy4/README.rdoc b/spec/dummy/README.rdoc similarity index 100% rename from spec/dummy4/README.rdoc rename to spec/dummy/README.rdoc diff --git a/spec/dummy4/Rakefile b/spec/dummy/Rakefile similarity index 100% rename from spec/dummy4/Rakefile rename to spec/dummy/Rakefile diff --git a/spec/dummy4/app/active_record/note.rb b/spec/dummy/app/active_record/note.rb similarity index 100% rename from spec/dummy4/app/active_record/note.rb rename to spec/dummy/app/active_record/note.rb diff --git a/spec/dummy4/app/assets/images/.keep b/spec/dummy/app/assets/images/.keep similarity index 100% rename from spec/dummy4/app/assets/images/.keep rename to spec/dummy/app/assets/images/.keep diff --git a/spec/dummy4/app/assets/javascripts/application.js b/spec/dummy/app/assets/javascripts/application.js similarity index 100% rename from spec/dummy4/app/assets/javascripts/application.js rename to spec/dummy/app/assets/javascripts/application.js diff --git a/spec/dummy4/app/assets/javascripts/notes.coffee b/spec/dummy/app/assets/javascripts/notes.coffee similarity index 100% rename from spec/dummy4/app/assets/javascripts/notes.coffee rename to spec/dummy/app/assets/javascripts/notes.coffee diff --git a/spec/dummy4/app/assets/stylesheets/application.scss b/spec/dummy/app/assets/stylesheets/application.scss similarity index 100% rename from spec/dummy4/app/assets/stylesheets/application.scss rename to spec/dummy/app/assets/stylesheets/application.scss diff --git a/spec/dummy4/app/assets/stylesheets/notes.scss b/spec/dummy/app/assets/stylesheets/notes.scss similarity index 100% rename from spec/dummy4/app/assets/stylesheets/notes.scss rename to spec/dummy/app/assets/stylesheets/notes.scss diff --git a/spec/dummy4/app/assets/stylesheets/scaffolds.scss b/spec/dummy/app/assets/stylesheets/scaffolds.scss similarity index 100% rename from spec/dummy4/app/assets/stylesheets/scaffolds.scss rename to spec/dummy/app/assets/stylesheets/scaffolds.scss diff --git a/spec/dummy4/app/controllers/application_controller.rb b/spec/dummy/app/controllers/application_controller.rb similarity index 100% rename from spec/dummy4/app/controllers/application_controller.rb rename to spec/dummy/app/controllers/application_controller.rb diff --git a/spec/dummy4/app/controllers/concerns/.keep b/spec/dummy/app/controllers/concerns/.keep similarity index 100% rename from spec/dummy4/app/controllers/concerns/.keep rename to spec/dummy/app/controllers/concerns/.keep diff --git a/spec/dummy4/app/controllers/notes_controller.rb b/spec/dummy/app/controllers/notes_controller.rb similarity index 100% rename from spec/dummy4/app/controllers/notes_controller.rb rename to spec/dummy/app/controllers/notes_controller.rb diff --git a/spec/dummy4/app/helpers/application_helper.rb b/spec/dummy/app/helpers/application_helper.rb similarity index 100% rename from spec/dummy4/app/helpers/application_helper.rb rename to spec/dummy/app/helpers/application_helper.rb diff --git a/spec/dummy4/app/helpers/notes_helper.rb b/spec/dummy/app/helpers/notes_helper.rb similarity index 100% rename from spec/dummy4/app/helpers/notes_helper.rb rename to spec/dummy/app/helpers/notes_helper.rb diff --git a/spec/dummy4/app/mailers/.keep b/spec/dummy/app/mailers/.keep similarity index 100% rename from spec/dummy4/app/mailers/.keep rename to spec/dummy/app/mailers/.keep diff --git a/spec/dummy4/app/models/.keep b/spec/dummy/app/models/.keep similarity index 100% rename from spec/dummy4/app/models/.keep rename to spec/dummy/app/models/.keep diff --git a/spec/dummy4/app/models/concerns/.keep b/spec/dummy/app/models/concerns/.keep similarity index 100% rename from spec/dummy4/app/models/concerns/.keep rename to spec/dummy/app/models/concerns/.keep diff --git a/spec/dummy4/app/mongoid/note.rb b/spec/dummy/app/mongoid/note.rb similarity index 100% rename from spec/dummy4/app/mongoid/note.rb rename to spec/dummy/app/mongoid/note.rb diff --git a/spec/dummy4/app/views/layouts/application.html.erb b/spec/dummy/app/views/layouts/application.html.erb similarity index 100% rename from spec/dummy4/app/views/layouts/application.html.erb rename to spec/dummy/app/views/layouts/application.html.erb diff --git a/spec/dummy4/app/views/notes/_form.html.erb b/spec/dummy/app/views/notes/_form.html.erb similarity index 100% rename from spec/dummy4/app/views/notes/_form.html.erb rename to spec/dummy/app/views/notes/_form.html.erb diff --git a/spec/dummy4/app/views/notes/_form_builder.html.erb b/spec/dummy/app/views/notes/_form_builder.html.erb similarity index 100% rename from spec/dummy4/app/views/notes/_form_builder.html.erb rename to spec/dummy/app/views/notes/_form_builder.html.erb diff --git a/spec/dummy4/app/views/notes/_form_nojs.html.erb b/spec/dummy/app/views/notes/_form_nojs.html.erb similarity index 100% rename from spec/dummy4/app/views/notes/_form_nojs.html.erb rename to spec/dummy/app/views/notes/_form_nojs.html.erb diff --git a/spec/dummy4/app/views/notes/_form_raw.html.erb b/spec/dummy/app/views/notes/_form_raw.html.erb similarity index 100% rename from spec/dummy4/app/views/notes/_form_raw.html.erb rename to spec/dummy/app/views/notes/_form_raw.html.erb diff --git a/spec/dummy4/app/views/notes/_form_simple_form.html.erb b/spec/dummy/app/views/notes/_form_simple_form.html.erb similarity index 100% rename from spec/dummy4/app/views/notes/_form_simple_form.html.erb rename to spec/dummy/app/views/notes/_form_simple_form.html.erb diff --git a/spec/dummy4/app/views/notes/_note.html.erb b/spec/dummy/app/views/notes/_note.html.erb similarity index 100% rename from spec/dummy4/app/views/notes/_note.html.erb rename to spec/dummy/app/views/notes/_note.html.erb diff --git a/spec/dummy4/app/views/notes/edit.html.erb b/spec/dummy/app/views/notes/edit.html.erb similarity index 100% rename from spec/dummy4/app/views/notes/edit.html.erb rename to spec/dummy/app/views/notes/edit.html.erb diff --git a/spec/dummy4/app/views/notes/index.html.erb b/spec/dummy/app/views/notes/index.html.erb similarity index 100% rename from spec/dummy4/app/views/notes/index.html.erb rename to spec/dummy/app/views/notes/index.html.erb diff --git a/spec/dummy4/app/views/notes/index.json.jbuilder b/spec/dummy/app/views/notes/index.json.jbuilder similarity index 100% rename from spec/dummy4/app/views/notes/index.json.jbuilder rename to spec/dummy/app/views/notes/index.json.jbuilder diff --git a/spec/dummy4/app/views/notes/new.html.erb b/spec/dummy/app/views/notes/new.html.erb similarity index 100% rename from spec/dummy4/app/views/notes/new.html.erb rename to spec/dummy/app/views/notes/new.html.erb diff --git a/spec/dummy4/app/views/notes/show.html.erb b/spec/dummy/app/views/notes/show.html.erb similarity index 100% rename from spec/dummy4/app/views/notes/show.html.erb rename to spec/dummy/app/views/notes/show.html.erb diff --git a/spec/dummy4/app/views/notes/show.json.jbuilder b/spec/dummy/app/views/notes/show.json.jbuilder similarity index 100% rename from spec/dummy4/app/views/notes/show.json.jbuilder rename to spec/dummy/app/views/notes/show.json.jbuilder diff --git a/spec/dummy4/bower.json b/spec/dummy/bower.json similarity index 100% rename from spec/dummy4/bower.json rename to spec/dummy/bower.json diff --git a/spec/dummy4/config.ru b/spec/dummy/config.ru similarity index 100% rename from spec/dummy4/config.ru rename to spec/dummy/config.ru diff --git a/spec/dummy4/config/application.rb b/spec/dummy/config/application.rb similarity index 100% rename from spec/dummy4/config/application.rb rename to spec/dummy/config/application.rb diff --git a/spec/dummy4/config/boot.rb b/spec/dummy/config/boot.rb similarity index 100% rename from spec/dummy4/config/boot.rb rename to spec/dummy/config/boot.rb diff --git a/spec/dummy4/config/database.yml b/spec/dummy/config/database.yml similarity index 100% rename from spec/dummy4/config/database.yml rename to spec/dummy/config/database.yml diff --git a/spec/dummy4/config/environment.rb b/spec/dummy/config/environment.rb similarity index 100% rename from spec/dummy4/config/environment.rb rename to spec/dummy/config/environment.rb diff --git a/spec/dummy4/config/environments/development.rb b/spec/dummy/config/environments/development.rb similarity index 100% rename from spec/dummy4/config/environments/development.rb rename to spec/dummy/config/environments/development.rb diff --git a/spec/dummy4/config/environments/production.rb b/spec/dummy/config/environments/production.rb similarity index 100% rename from spec/dummy4/config/environments/production.rb rename to spec/dummy/config/environments/production.rb diff --git a/spec/dummy4/config/environments/test.rb b/spec/dummy/config/environments/test.rb similarity index 100% rename from spec/dummy4/config/environments/test.rb rename to spec/dummy/config/environments/test.rb diff --git a/spec/dummy4/config/initializers/assets.rb b/spec/dummy/config/initializers/assets.rb similarity index 100% rename from spec/dummy4/config/initializers/assets.rb rename to spec/dummy/config/initializers/assets.rb diff --git a/spec/dummy4/config/initializers/attachinary.rb b/spec/dummy/config/initializers/attachinary.rb similarity index 100% rename from spec/dummy4/config/initializers/attachinary.rb rename to spec/dummy/config/initializers/attachinary.rb diff --git a/spec/dummy4/config/initializers/backtrace_silencers.rb b/spec/dummy/config/initializers/backtrace_silencers.rb similarity index 100% rename from spec/dummy4/config/initializers/backtrace_silencers.rb rename to spec/dummy/config/initializers/backtrace_silencers.rb diff --git a/spec/dummy4/config/initializers/cookies_serializer.rb b/spec/dummy/config/initializers/cookies_serializer.rb similarity index 100% rename from spec/dummy4/config/initializers/cookies_serializer.rb rename to spec/dummy/config/initializers/cookies_serializer.rb diff --git a/spec/dummy4/config/initializers/filter_parameter_logging.rb b/spec/dummy/config/initializers/filter_parameter_logging.rb similarity index 100% rename from spec/dummy4/config/initializers/filter_parameter_logging.rb rename to spec/dummy/config/initializers/filter_parameter_logging.rb diff --git a/spec/dummy4/config/initializers/inflections.rb b/spec/dummy/config/initializers/inflections.rb similarity index 100% rename from spec/dummy4/config/initializers/inflections.rb rename to spec/dummy/config/initializers/inflections.rb diff --git a/spec/dummy4/config/initializers/mime_types.rb b/spec/dummy/config/initializers/mime_types.rb similarity index 100% rename from spec/dummy4/config/initializers/mime_types.rb rename to spec/dummy/config/initializers/mime_types.rb diff --git a/spec/dummy4/config/initializers/session_store.rb b/spec/dummy/config/initializers/session_store.rb similarity index 100% rename from spec/dummy4/config/initializers/session_store.rb rename to spec/dummy/config/initializers/session_store.rb diff --git a/spec/dummy4/config/initializers/wrap_parameters.rb b/spec/dummy/config/initializers/wrap_parameters.rb similarity index 100% rename from spec/dummy4/config/initializers/wrap_parameters.rb rename to spec/dummy/config/initializers/wrap_parameters.rb diff --git a/spec/dummy4/config/locales/en.yml b/spec/dummy/config/locales/en.yml similarity index 100% rename from spec/dummy4/config/locales/en.yml rename to spec/dummy/config/locales/en.yml diff --git a/spec/dummy4/config/mongoid.yml b/spec/dummy/config/mongoid.yml similarity index 100% rename from spec/dummy4/config/mongoid.yml rename to spec/dummy/config/mongoid.yml diff --git a/spec/dummy4/config/routes.rb b/spec/dummy/config/routes.rb similarity index 100% rename from spec/dummy4/config/routes.rb rename to spec/dummy/config/routes.rb diff --git a/spec/dummy4/config/secrets.yml b/spec/dummy/config/secrets.yml similarity index 100% rename from spec/dummy4/config/secrets.yml rename to spec/dummy/config/secrets.yml diff --git a/spec/dummy4/lib/assets/.keep b/spec/dummy/lib/assets/.keep similarity index 100% rename from spec/dummy4/lib/assets/.keep rename to spec/dummy/lib/assets/.keep diff --git a/spec/dummy4/lib/tasks/.keep b/spec/dummy/lib/tasks/.keep similarity index 100% rename from spec/dummy4/lib/tasks/.keep rename to spec/dummy/lib/tasks/.keep diff --git a/spec/dummy4/log/.keep b/spec/dummy/log/.keep similarity index 100% rename from spec/dummy4/log/.keep rename to spec/dummy/log/.keep diff --git a/spec/dummy4/public/404.html b/spec/dummy/public/404.html similarity index 100% rename from spec/dummy4/public/404.html rename to spec/dummy/public/404.html diff --git a/spec/dummy4/public/422.html b/spec/dummy/public/422.html similarity index 100% rename from spec/dummy4/public/422.html rename to spec/dummy/public/422.html diff --git a/spec/dummy4/public/500.html b/spec/dummy/public/500.html similarity index 100% rename from spec/dummy4/public/500.html rename to spec/dummy/public/500.html diff --git a/spec/dummy4/public/favicon.ico b/spec/dummy/public/favicon.ico similarity index 100% rename from spec/dummy4/public/favicon.ico rename to spec/dummy/public/favicon.ico diff --git a/spec/dummy4/public/robots.txt b/spec/dummy/public/robots.txt similarity index 100% rename from spec/dummy4/public/robots.txt rename to spec/dummy/public/robots.txt diff --git a/spec/dummy4/spec/rails_helper.rb b/spec/dummy/spec/rails_helper.rb similarity index 100% rename from spec/dummy4/spec/rails_helper.rb rename to spec/dummy/spec/rails_helper.rb diff --git a/spec/dummy4/spec/spec_helper.rb b/spec/dummy/spec/spec_helper.rb similarity index 100% rename from spec/dummy4/spec/spec_helper.rb rename to spec/dummy/spec/spec_helper.rb diff --git a/spec/dummy4/test/controllers/.keep b/spec/dummy/test/controllers/.keep similarity index 100% rename from spec/dummy4/test/controllers/.keep rename to spec/dummy/test/controllers/.keep diff --git a/spec/dummy4/test/controllers/notes_controller_test.rb b/spec/dummy/test/controllers/notes_controller_test.rb similarity index 100% rename from spec/dummy4/test/controllers/notes_controller_test.rb rename to spec/dummy/test/controllers/notes_controller_test.rb diff --git a/spec/dummy4/test/fixtures/.keep b/spec/dummy/test/fixtures/.keep similarity index 100% rename from spec/dummy4/test/fixtures/.keep rename to spec/dummy/test/fixtures/.keep diff --git a/spec/dummy4/test/fixtures/notes.yml b/spec/dummy/test/fixtures/notes.yml similarity index 100% rename from spec/dummy4/test/fixtures/notes.yml rename to spec/dummy/test/fixtures/notes.yml diff --git a/spec/dummy4/test/helpers/.keep b/spec/dummy/test/helpers/.keep similarity index 100% rename from spec/dummy4/test/helpers/.keep rename to spec/dummy/test/helpers/.keep diff --git a/spec/dummy4/test/integration/.keep b/spec/dummy/test/integration/.keep similarity index 100% rename from spec/dummy4/test/integration/.keep rename to spec/dummy/test/integration/.keep diff --git a/spec/dummy4/test/mailers/.keep b/spec/dummy/test/mailers/.keep similarity index 100% rename from spec/dummy4/test/mailers/.keep rename to spec/dummy/test/mailers/.keep diff --git a/spec/dummy4/test/models/.keep b/spec/dummy/test/models/.keep similarity index 100% rename from spec/dummy4/test/models/.keep rename to spec/dummy/test/models/.keep diff --git a/spec/dummy4/test/models/note_test.rb b/spec/dummy/test/models/note_test.rb similarity index 100% rename from spec/dummy4/test/models/note_test.rb rename to spec/dummy/test/models/note_test.rb diff --git a/spec/dummy4/test/test_helper.rb b/spec/dummy/test/test_helper.rb similarity index 100% rename from spec/dummy4/test/test_helper.rb rename to spec/dummy/test/test_helper.rb diff --git a/spec/dummy4/Gemfile.lock b/spec/dummy4/Gemfile.lock deleted file mode 100644 index bc0019d5..00000000 --- a/spec/dummy4/Gemfile.lock +++ /dev/null @@ -1,306 +0,0 @@ -PATH - remote: ../.. - specs: - attachinary (1.3.1) - cloudinary (~> 1.1.0) - rails (>= 3.2) - -GEM - remote: https://rubygems.org/ - specs: - actionmailer (4.2.3) - actionpack (= 4.2.3) - actionview (= 4.2.3) - activejob (= 4.2.3) - mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.3) - actionview (= 4.2.3) - activesupport (= 4.2.3) - rack (~> 1.6) - rack-test (~> 0.6.2) - rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.3) - activesupport (= 4.2.3) - builder (~> 3.1) - erubis (~> 2.7.0) - rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - activejob (4.2.3) - activesupport (= 4.2.3) - globalid (>= 0.3.0) - activemodel (4.2.3) - activesupport (= 4.2.3) - builder (~> 3.1) - activerecord (4.2.3) - activemodel (= 4.2.3) - activesupport (= 4.2.3) - arel (~> 6.0) - activesupport (4.2.3) - i18n (~> 0.7) - json (~> 1.7, >= 1.7.7) - minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) - tzinfo (~> 1.1) - addressable (2.3.8) - arel (6.0.2) - autoprefixer-rails (5.2.1.1) - execjs - json - aws_cf_signer (0.1.3) - binding_of_caller (0.7.2) - debug_inspector (>= 0.0.1) - bootstrap-sass (3.3.5.1) - autoprefixer-rails (>= 5.0.0.1) - sass (>= 3.3.0) - bson (3.2.4) - builder (3.2.2) - byebug (5.0.0) - columnize (= 0.9.0) - capybara (2.5.0) - mime-types (>= 1.16) - nokogiri (>= 1.3.3) - rack (>= 1.0.0) - rack-test (>= 0.5.4) - xpath (~> 2.0) - capybara-webkit (1.7.1) - capybara (>= 2.3.0, < 2.6.0) - json - childprocess (0.5.6) - ffi (~> 1.0, >= 1.0.11) - cloudinary (1.1.0) - aws_cf_signer - rest-client - coderay (1.1.0) - coffee-rails (4.1.0) - coffee-script (>= 2.2.0) - railties (>= 4.0.0, < 5.0) - coffee-script (2.4.1) - coffee-script-source - execjs - coffee-script-source (1.9.1.1) - columnize (0.9.0) - database_cleaner (1.5.0) - debase (0.2.1) - debase-ruby_core_source - debase-ruby_core_source (0.7.10) - debug_inspector (0.0.2) - diff-lcs (1.2.5) - domain_name (0.5.24) - unf (>= 0.0.5, < 1.0.0) - erubis (2.7.0) - execjs (2.5.2) - factory_girl (4.5.0) - activesupport (>= 3.0.0) - factory_girl_rails (4.5.0) - factory_girl (~> 4.5.0) - railties (>= 3.0.0) - ffi (1.9.10) - formatador (0.2.5) - globalid (0.3.5) - activesupport (>= 4.1.0) - guard (2.13.0) - formatador (>= 0.2.4) - listen (>= 2.7, <= 4.0) - lumberjack (~> 1.0) - nenv (~> 0.1) - notiffany (~> 0.0) - pry (>= 0.9.12) - shellany (~> 0.0) - thor (>= 0.18.1) - guard-compat (1.2.1) - guard-rspec (4.6.4) - guard (~> 2.1) - guard-compat (~> 1.1) - rspec (>= 2.99.0, < 4.0) - http-cookie (1.0.2) - domain_name (~> 0.5) - i18n (0.7.0) - jbuilder (2.3.1) - activesupport (>= 3.0.0, < 5) - multi_json (~> 1.2) - jquery-rails (4.0.4) - rails-dom-testing (~> 1.0) - railties (>= 4.2.0) - thor (>= 0.14, < 2.0) - json (1.8.3) - launchy (2.4.3) - addressable (~> 2.3) - listen (3.0.3) - rb-fsevent (>= 0.9.3) - rb-inotify (>= 0.9) - loofah (2.0.2) - nokogiri (>= 1.5.9) - lumberjack (1.0.9) - mail (2.6.3) - mime-types (>= 1.16, < 3) - method_source (0.8.2) - mime-types (2.6.1) - mini_portile (0.6.2) - minitest (5.7.0) - mongo (2.1.1) - bson (~> 3.0) - mongoid (5.0.0) - activemodel (~> 4.0) - mongo (~> 2.1) - origin (~> 2.1) - tzinfo (>= 0.3.37) - multi_json (1.11.2) - nenv (0.2.0) - netrc (0.10.3) - nokogiri (1.6.6.2) - mini_portile (~> 0.6.0) - notiffany (0.0.8) - nenv (~> 0.1) - shellany (~> 0.0) - origin (2.1.1) - pry (0.10.2) - coderay (~> 1.1.0) - method_source (~> 0.8.1) - slop (~> 3.4) - rack (1.6.4) - rack-test (0.6.3) - rack (>= 1.0) - rails (4.2.3) - actionmailer (= 4.2.3) - actionpack (= 4.2.3) - actionview (= 4.2.3) - activejob (= 4.2.3) - activemodel (= 4.2.3) - activerecord (= 4.2.3) - activesupport (= 4.2.3) - bundler (>= 1.3.0, < 2.0) - railties (= 4.2.3) - sprockets-rails - rails-deprecated_sanitizer (1.0.3) - activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.6) - activesupport (>= 4.2.0.beta, < 5.0) - nokogiri (~> 1.6.0) - rails-deprecated_sanitizer (>= 1.0.1) - rails-html-sanitizer (1.0.2) - loofah (~> 2.0) - railties (4.2.3) - actionpack (= 4.2.3) - activesupport (= 4.2.3) - rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) - rake (10.4.2) - rb-fsevent (0.9.6) - rb-inotify (0.9.5) - ffi (>= 0.5.0) - rdoc (4.2.0) - json (~> 1.4) - rest-client (1.8.0) - http-cookie (>= 1.0.2, < 2.0) - mime-types (>= 1.16, < 3.0) - netrc (~> 0.7) - rspec (3.3.0) - rspec-core (~> 3.3.0) - rspec-expectations (~> 3.3.0) - rspec-mocks (~> 3.3.0) - rspec-core (3.3.2) - rspec-support (~> 3.3.0) - rspec-expectations (3.3.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.3.0) - rspec-mocks (3.3.2) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.3.0) - rspec-rails (3.3.3) - actionpack (>= 3.0, < 4.3) - activesupport (>= 3.0, < 4.3) - railties (>= 3.0, < 4.3) - rspec-core (~> 3.3.0) - rspec-expectations (~> 3.3.0) - rspec-mocks (~> 3.3.0) - rspec-support (~> 3.3.0) - rspec-support (3.3.0) - ruby-debug-ide (0.6.0) - rake (>= 0.8.1) - rubyzip (1.1.7) - sass (3.4.16) - sass-rails (5.0.3) - railties (>= 4.0.0, < 5.0) - sass (~> 3.1) - sprockets (>= 2.8, < 4.0) - sprockets-rails (>= 2.0, < 4.0) - tilt (~> 1.1) - sdoc (0.4.1) - json (~> 1.7, >= 1.7.7) - rdoc (~> 4.0) - selenium-webdriver (2.47.1) - childprocess (~> 0.5) - multi_json (~> 1.0) - rubyzip (~> 1.0) - websocket (~> 1.0) - shellany (0.0.1) - simple_form (3.2.0) - actionpack (~> 4.0) - activemodel (~> 4.0) - slop (3.6.0) - spring (1.3.6) - sprockets (3.2.0) - rack (~> 1.0) - sprockets-rails (2.3.2) - actionpack (>= 3.0) - activesupport (>= 3.0) - sprockets (>= 2.8, < 4.0) - sqlite3 (1.3.10) - thor (0.19.1) - thread_safe (0.3.5) - tilt (1.4.1) - turbolinks (2.5.3) - coffee-rails - tzinfo (1.2.2) - thread_safe (~> 0.1) - uglifier (2.7.1) - execjs (>= 0.3.0) - json (>= 1.8.0) - unf (0.1.4) - unf_ext - unf_ext (0.0.7.1) - valid_attribute (2.0.0) - web-console (2.2.1) - activemodel (>= 4.0) - binding_of_caller (>= 0.7.2) - railties (>= 4.0) - sprockets-rails (>= 2.0, < 4.0) - websocket (1.2.2) - xpath (2.0.0) - nokogiri (~> 1.3) - -PLATFORMS - ruby - -DEPENDENCIES - attachinary! - bootstrap-sass (~> 3.3.5) - byebug - capybara - capybara-webkit - cloudinary (~> 1.1) - coffee-rails (~> 4.1.0) - database_cleaner - debase - factory_girl_rails - guard-rspec - jbuilder (~> 2.0) - jquery-rails - launchy - mongoid - rails (= 4.2.3) - rb-fsevent (~> 0.9.1) - rspec-rails - ruby-debug-ide - sass-rails (~> 5.0) - sdoc (~> 0.4.0) - selenium-webdriver - simple_form - spring - sqlite3 - turbolinks - uglifier (>= 1.3.0) - valid_attribute - web-console (~> 2.0) diff --git a/spec/dummy4/db/seeds.rb b/spec/dummy4/db/seeds.rb deleted file mode 100644 index 4edb1e85..00000000 --- a/spec/dummy4/db/seeds.rb +++ /dev/null @@ -1,7 +0,0 @@ -# This file should contain all the record creation needed to seed the database with its default values. -# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). -# -# Examples: -# -# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) -# Mayor.create(name: 'Emanuel', city: cities.first) diff --git a/spec/dummy4/vendor/assets/javascripts/.keep b/spec/dummy4/vendor/assets/javascripts/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/spec/dummy4/vendor/assets/stylesheets/.keep b/spec/dummy4/vendor/assets/stylesheets/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 761caae9..5e48ee4d 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,7 +1,7 @@ # This file is copied to spec/ when you run 'rails generate rspec:install' require 'spec_helper' ENV['RAILS_ENV'] ||= 'test' -require File.expand_path('../dummy4/config/environment', __FILE__) +require File.expand_path('../dummy/config/environment', __FILE__) # Prevent database truncation if the environment is production abort('The Rails environment is running in production mode!') if Rails.env.production? require 'rspec/rails' From 935d2d591057e80da9e8c54475c67e56eb51499b Mon Sep 17 00:00:00 2001 From: Fabio Napoleoni Date: Mon, 2 Oct 2017 22:36:26 +0200 Subject: [PATCH 10/29] Generated database schema and migrations for dummy app --- db/migrate/20171002203528_create_notes.rb | 9 ++++++ spec/dummy/.gitignore | 1 - spec/dummy/db/schema.rb | 38 +++++++++++++++++++++++ spec/dummy/db/seeds.rb | 7 +++++ 4 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20171002203528_create_notes.rb create mode 100644 spec/dummy/db/schema.rb create mode 100644 spec/dummy/db/seeds.rb diff --git a/db/migrate/20171002203528_create_notes.rb b/db/migrate/20171002203528_create_notes.rb new file mode 100644 index 00000000..3b315cf1 --- /dev/null +++ b/db/migrate/20171002203528_create_notes.rb @@ -0,0 +1,9 @@ +class CreateNotes < ActiveRecord::Migration + def change + create_table :notes do |t| + t.text :body + + t.timestamps null: false + end + end +end diff --git a/spec/dummy/.gitignore b/spec/dummy/.gitignore index 8f742059..dc652263 100644 --- a/spec/dummy/.gitignore +++ b/spec/dummy/.gitignore @@ -17,4 +17,3 @@ /tmp */cloudinary.yml vendor/assets/ -db/ diff --git a/spec/dummy/db/schema.rb b/spec/dummy/db/schema.rb new file mode 100644 index 00000000..6b9e664b --- /dev/null +++ b/spec/dummy/db/schema.rb @@ -0,0 +1,38 @@ +# encoding: UTF-8 +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 20171002203528) do + + create_table "attachinary_files", force: :cascade do |t| + t.integer "attachinariable_id" + t.string "attachinariable_type" + t.string "scope" + t.string "public_id" + t.string "version" + t.integer "width" + t.integer "height" + t.string "format" + t.string "resource_type" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "attachinary_files", ["attachinariable_type", "attachinariable_id", "scope"], name: "by_scoped_parent" + + create_table "notes", force: :cascade do |t| + t.text "body" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + +end diff --git a/spec/dummy/db/seeds.rb b/spec/dummy/db/seeds.rb new file mode 100644 index 00000000..4edb1e85 --- /dev/null +++ b/spec/dummy/db/seeds.rb @@ -0,0 +1,7 @@ +# This file should contain all the record creation needed to seed the database with its default values. +# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). +# +# Examples: +# +# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) +# Mayor.create(name: 'Emanuel', city: cities.first) From 915c4f1603b7db13e79530dbca210ec6c109e5e7 Mon Sep 17 00:00:00 2001 From: Fabio Napoleoni Date: Mon, 2 Oct 2017 22:52:39 +0200 Subject: [PATCH 11/29] Refactored RSpec configuration --- spec/rails_helper.rb | 11 +++++++++-- spec/support/database_cleaner.rb | 34 ++++++++++++++++++++++++++++++++ spec/support/factory_girl.rb | 3 +++ spec/support/request_helpers.rb | 5 +++++ 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 spec/support/database_cleaner.rb create mode 100644 spec/support/factory_girl.rb diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 5e48ee4d..6d177445 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,11 +1,15 @@ # This file is copied to spec/ when you run 'rails generate rspec:install' require 'spec_helper' ENV['RAILS_ENV'] ||= 'test' +ATTACHINARY_ORM ||= (ENV['ATTACHINARY_ORM'] || :active_record).to_sym require File.expand_path('../dummy/config/environment', __FILE__) # Prevent database truncation if the environment is production abort('The Rails environment is running in production mode!') if Rails.env.production? require 'rspec/rails' # Add additional requires below this line. Rails is not loaded until this point! +require_relative 'factories' +# Define rails root as const +ENGINE_RAILS_ROOT = File.join(File.dirname(__FILE__), '../') # Requires supporting ruby files with custom matchers and macros, etc, in # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are @@ -19,8 +23,8 @@ # of increasing the boot-up time by auto-requiring all files in the support # directory. Alternatively, in the individual `*_spec.rb` files, manually # require only the support files necessary. -# -# Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } + +Dir[File.join(ENGINE_RAILS_ROOT, '../../spec/support/**/*.rb')].each {|f| require f } # Checks for pending migration and applies them before tests are run. # If you are not using ActiveRecord, you can remove this line. @@ -54,4 +58,7 @@ config.filter_rails_from_backtrace! # arbitrary gems may also be filtered via: # config.filter_gems_from_backtrace("gem name") + + # Factory girl integration + config.include FactoryGirl::Syntax::Methods end diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb new file mode 100644 index 00000000..2d5b53df --- /dev/null +++ b/spec/support/database_cleaner.rb @@ -0,0 +1,34 @@ +require 'database_cleaner' + +RSpec.configure do |config| + config.before(:suite) do + # @see https://github.com/DatabaseCleaner/database_cleaner/issues/445 + DatabaseCleaner.clean_with(:truncation, except: %w(ar_internal_metadata)) + end + + config.before(:each) do |example| + # Switch to truncation if example uses a javascript driver or required by example metadata + strategy = example.metadata[:strategy] if example.metadata[:strategy] + strategy ||= example.metadata[:js] ? :truncation : :transaction + DatabaseCleaner.strategy = strategy + DatabaseCleaner.start + end + + config.append_after(:each) do + DatabaseCleaner.clean + end + + config.after(:suite) do + print "\n\n Cleaning up uploaded files" + + begin + Cloudinary::Api.delete_resources_by_tag('test_env') + print ' (done)' + rescue Cloudinary::Api::RateLimited => e + print " (#{e.message})" + end + + print "\n\n" + end + +end diff --git a/spec/support/factory_girl.rb b/spec/support/factory_girl.rb new file mode 100644 index 00000000..eec437fb --- /dev/null +++ b/spec/support/factory_girl.rb @@ -0,0 +1,3 @@ +RSpec.configure do |config| + config.include FactoryGirl::Syntax::Methods +end diff --git a/spec/support/request_helpers.rb b/spec/support/request_helpers.rb index c93dc14c..de909358 100644 --- a/spec/support/request_helpers.rb +++ b/spec/support/request_helpers.rb @@ -14,3 +14,8 @@ def alert_message end end + +# Include module in features +RSpec.configure do |config| + config.include RequestHelpers, type: :feature +end \ No newline at end of file From c98502dae85aab7ba502885e65ebfaf0e1a0a918 Mon Sep 17 00:00:00 2001 From: Fabio Napoleoni Date: Mon, 2 Oct 2017 22:59:03 +0200 Subject: [PATCH 12/29] Convert specs to RSpec 3.6.0 syntax with Transpec This conversion is done by Transpec 3.3.0 with the following command: transpec -f * 38 conversions from: obj.should to: expect(obj).to * 19 conversions from: == expected to: eq(expected) * 6 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 4 conversions from: it { should_not ... } to: it { is_expected.not_to ... } * 2 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: it { should ... } to: it { is_expected.to ... } * 1 conversion from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 1 conversion from: obj.stub(:message) to: allow(obj).to receive(:message) For more details: https://github.com/yujinakayama/transpec#supported-conversions --- spec/features/notes_spec.rb | 24 ++++++------- spec/models/attachinary/file_spec.rb | 16 ++++----- spec/models/note_spec.rb | 52 ++++++++++++++-------------- 3 files changed, 46 insertions(+), 46 deletions(-) diff --git a/spec/features/notes_spec.rb b/spec/features/notes_spec.rb index 3ed2d24b..0ac65222 100644 --- a/spec/features/notes_spec.rb +++ b/spec/features/notes_spec.rb @@ -19,7 +19,7 @@ it 'disables input when first photo is uploaded', :js => true do within 'div.photo' do attach_file "note[photo]", "#{SPEC_ROOT}/support/A.gif" - page.should have_css 'input[disabled]' + expect(page).to have_css 'input[disabled]' end end @@ -28,35 +28,35 @@ attach_file "note[images][]", "#{SPEC_ROOT}/support/A.gif" value = find(:xpath, './/input[@name="note[images][]" and @type="hidden" and contains(@value, \'"A"\')]', :visible => false).value images = ActiveSupport::JSON.decode( value) - images.length.should be 1 - images.map{|i| i["original_filename"]}.should eq ["A"] + expect(images.length).to be 1 + expect(images.map{|i| i["original_filename"]}).to eq ["A"] attach_file "note[images][]", "#{SPEC_ROOT}/support/B.gif" value = find(:xpath, './/input[@name="note[images][]" and @type="hidden" and contains(@value, \'"B"\')]', :visible => false).value images = ActiveSupport::JSON.decode( value) - images.length.should be 2 - images.map{|i| i["original_filename"]}.sort.should eq ["A", "B"] + expect(images.length).to be 2 + expect(images.map{|i| i["original_filename"]}.sort).to eq ["A", "B"] end end it 'preserves uploaded photo across postbacks', :js => true do within 'div.photo' do attach_file "note[photo]", "#{SPEC_ROOT}/support/A.gif" - page.should have_css 'img' + expect(page).to have_css 'img' end - page.should have_button 'Create Note' # wait for it to appear + expect(page).to have_button 'Create Note' # wait for it to appear click_button 'Create Note' within 'div.photo' do - page.should have_css 'img' + expect(page).to have_css 'img' end end it 'validates presence of photo', :js => true do click_button 'Create Note' within 'div.photo' do - page.should have_content "can't be blank" + expect(page).to have_content "can't be blank" end end @@ -67,9 +67,9 @@ end click_button 'Create Note' - current_path.should == notes_path - page.should have_content 'My Note' - page.should have_css 'img' + expect(current_path).to eq(notes_path) + expect(page).to have_content 'My Note' + expect(page).to have_css 'img' end end diff --git a/spec/models/attachinary/file_spec.rb b/spec/models/attachinary/file_spec.rb index af7ab543..925bed47 100644 --- a/spec/models/attachinary/file_spec.rb +++ b/spec/models/attachinary/file_spec.rb @@ -13,9 +13,9 @@ subject { build(:file, public_id: 'id', version: '1', format: 'jpg', resource_type: 'image') } it 'allows you to pick format' do - subject.path.should == 'v1/id.jpg' - subject.path('png').should == 'v1/id.png' - subject.path(false).should == 'v1/id' + expect(subject.path).to eq('v1/id.jpg') + expect(subject.path('png')).to eq('v1/id.png') + expect(subject.path(false)).to eq('v1/id') end end @@ -23,19 +23,19 @@ subject { build(:file, public_id: 'id.txt', version: '1', format: '', resource_type: 'raw') } it 'ignores the format' do - subject.path.should == 'v1/id.txt' - subject.path('png').should == 'v1/id.txt' - subject.path(false).should == 'v1/id.txt' + expect(subject.path).to eq('v1/id.txt') + expect(subject.path('png')).to eq('v1/id.txt') + expect(subject.path(false)).to eq('v1/id.txt') end end end describe '#fullpath(options={})' do it 'delegates to Cloudinary' do - Cloudinary::Utils.stub(:cloudinary_url).with('v1/id1.png', {resource_type: "image"}).and_return('http_png') + allow(Cloudinary::Utils).to receive(:cloudinary_url).with('v1/id1.png', {resource_type: "image"}).and_return('http_png') subject.public_id = 'id1' subject.version = '1' - subject.fullpath(format: 'png').should == 'http_png' + expect(subject.fullpath(format: 'png')).to eq('http_png') end end diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index 9119219a..eb97190d 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -17,21 +17,21 @@ it "destroys attached files" do note = create(:note, photo: photo) - Cloudinary::Uploader.should_receive(:destroy).with(photo.public_id) + expect(Cloudinary::Uploader).to receive(:destroy).with(photo.public_id) note.destroy end it "keeps attached files if Cloudinary.config.attachinary_keep_remote == true" do Cloudinary.config.attachinary_keep_remote = true note = create(:note, photo: photo) - Cloudinary::Uploader.should_not_receive(:destroy).with(photo.public_id) + expect(Cloudinary::Uploader).not_to receive(:destroy).with(photo.public_id) note.destroy end end describe "after_create" do it "removes attachinary_tmp tag from files" do - Cloudinary::Uploader.should_receive(:remove_tag).with(Attachinary::TMPTAG, [photo.public_id]) + expect(Cloudinary::Uploader).to receive(:remove_tag).with(Attachinary::TMPTAG, [photo.public_id]) create(:note, photo: photo) end end @@ -42,36 +42,36 @@ it 'manages photo' do photo1 = build(:file) subject.photo = photo1 - subject.photo.should == photo1 + expect(subject.photo).to eq(photo1) photo2 = build(:file) subject.photo = photo2 - subject.photo.should == photo2 + expect(subject.photo).to eq(photo2) subject.photo = nil - subject.photo.should be_nil + expect(subject.photo).to be_nil end it 'accepts stringified JSON' do file = build(:file) subject.photo = file.to_json - subject.photo.public_id.should == file.public_id + expect(subject.photo.public_id).to eq(file.public_id) end it 'handles invalid JSON from bad browsers (IE)' do file = build(:file) subject.photo = "[null]" - subject.photo.should be_nil + expect(subject.photo).to be_nil end it 'accepts IO objects' do image = StringIO.new("") file = build(:file) expected_id = file.public_id - Cloudinary::Uploader.should_receive(:upload).with(image, resource_type: 'auto').and_return(file.attributes) + expect(Cloudinary::Uploader).to receive(:upload).with(image, resource_type: 'auto').and_return(file.attributes) subject.photo = image - subject.photo.public_id.should == expected_id + expect(subject.photo.public_id).to eq(expected_id) end end @@ -81,27 +81,27 @@ let(:json) { file.attributes.to_json } before do - Cloudinary::Uploader.should_receive(:upload).with(url, resource_type: 'auto').and_return(json) + expect(Cloudinary::Uploader).to receive(:upload).with(url, resource_type: 'auto').and_return(json) end it 'uploads photo via url' do subject.photo_url = url - subject.photo.public_id.should == file.public_id + expect(subject.photo.public_id).to eq(file.public_id) end end describe '#photo?' do it 'checks whether photo is present' do - subject.photo?.should be_truthy + expect(subject.photo?).to be_truthy subject.photo = nil - subject.photo?.should be_falsey + expect(subject.photo?).to be_falsey end end describe '#photo_metadata' do it 'returns association metadata' do - subject.photo_metadata[:maximum].should == 1 - subject.photo_metadata[:single].should == true + expect(subject.photo_metadata[:maximum]).to eq(1) + expect(subject.photo_metadata[:single]).to eq(true) end end end @@ -109,25 +109,25 @@ describe 'image attachments' do describe '#images' do it 'manages images' do - subject.images?.should be_falsey + expect(subject.images?).to be_falsey image1 = build(:file) subject.images << image1 - subject.images.should == [image1] + expect(subject.images).to eq([image1]) image2 = build(:file) subject.images << image2 - subject.images.should == [image1, image2] + expect(subject.images).to eq([image1, image2]) subject.images = nil - subject.images.should be_blank + expect(subject.images).to be_blank end it 'accepts stringified JSON' do file = build(:file) subject.images = file.to_json - subject.images.first.public_id.should == file.public_id + expect(subject.images.first.public_id).to eq(file.public_id) end it 'accepts IO objects' do @@ -136,11 +136,11 @@ files_ids = files.map(&:public_id) files.each.with_index do |file, index| - Cloudinary::Uploader.should_receive(:upload).with(images[index], resource_type: 'auto').and_return(file.attributes) + expect(Cloudinary::Uploader).to receive(:upload).with(images[index], resource_type: 'auto').and_return(file.attributes) end subject.images = images - subject.images.map(&:public_id).should =~ files_ids + expect(subject.images.map(&:public_id)).to match(files_ids) end end @@ -152,19 +152,19 @@ before do files_ids files.each.with_index do |file, index| - Cloudinary::Uploader.should_receive(:upload).with(urls[index], resource_type: 'auto').and_return(file.attributes) + expect(Cloudinary::Uploader).to receive(:upload).with(urls[index], resource_type: 'auto').and_return(file.attributes) end end it 'upload photos via urls' do subject.image_urls = urls - subject.images.map(&:public_id).should =~ files_ids + expect(subject.images.map(&:public_id)).to match(files_ids) end end describe '#images_metadata' do it 'returns association metadata' do - subject.images_metadata[:single].should == false + expect(subject.images_metadata[:single]).to eq(false) end end end From 8be0d3807ee66f12e75806036d0dc980dd0b36b6 Mon Sep 17 00:00:00 2001 From: Fabio Napoleoni Date: Mon, 2 Oct 2017 23:08:54 +0200 Subject: [PATCH 13/29] Fixed paths in rails helper --- spec/rails_helper.rb | 3 +-- spec/support/factory_girl.rb | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 6d177445..2a0b4aa8 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -7,7 +7,6 @@ abort('The Rails environment is running in production mode!') if Rails.env.production? require 'rspec/rails' # Add additional requires below this line. Rails is not loaded until this point! -require_relative 'factories' # Define rails root as const ENGINE_RAILS_ROOT = File.join(File.dirname(__FILE__), '../') @@ -24,7 +23,7 @@ # directory. Alternatively, in the individual `*_spec.rb` files, manually # require only the support files necessary. -Dir[File.join(ENGINE_RAILS_ROOT, '../../spec/support/**/*.rb')].each {|f| require f } +Dir[File.join(ENGINE_RAILS_ROOT, 'spec/support/**/*.rb')].each {|f| require f } # Checks for pending migration and applies them before tests are run. # If you are not using ActiveRecord, you can remove this line. diff --git a/spec/support/factory_girl.rb b/spec/support/factory_girl.rb index eec437fb..54f917db 100644 --- a/spec/support/factory_girl.rb +++ b/spec/support/factory_girl.rb @@ -1,3 +1,5 @@ +require_relative '../factories' + RSpec.configure do |config| config.include FactoryGirl::Syntax::Methods end From 2e09f807be085b544c00be0116fcfdb430ae2d14 Mon Sep 17 00:00:00 2001 From: Fabio Napoleoni Date: Mon, 2 Oct 2017 23:09:23 +0200 Subject: [PATCH 14/29] Configured capybara driver --- Gemfile | 2 ++ spec/support/capybara.rb | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 spec/support/capybara.rb diff --git a/Gemfile b/Gemfile index 507f3691..9bdeb918 100644 --- a/Gemfile +++ b/Gemfile @@ -22,10 +22,12 @@ group :mongoid do end group :development, :test do + gem 'pry' gem 'sqlite3' gem 'rspec-rails', '~> 3.5' gem 'valid_attribute' gem 'capybara' + gem 'capybara-screenshot' gem 'selenium-webdriver' gem 'factory_girl_rails' gem 'launchy' diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb new file mode 100644 index 00000000..ee944625 --- /dev/null +++ b/spec/support/capybara.rb @@ -0,0 +1,25 @@ +# Database cleaner should be loaded before capybara +require_relative 'database_cleaner' + +require 'capybara/rspec' +require 'capybara-screenshot/rspec' + +Capybara.asset_host = 'http://localhost:3000' + +Capybara.always_include_port = true +# Allow running integration tests on chrome +Capybara.register_driver :chrome do |app| + Capybara::Screenshot.registered_drivers[:chrome] = Capybara::Screenshot.registered_drivers[:selenium] + Capybara::Selenium::Driver.new(app, browser: :chrome) +end +# Chrome in headless mode +Capybara.register_driver(:headless_chrome) do |app| + Capybara::Screenshot.registered_drivers[:headless_chrome] = Capybara::Screenshot.registered_drivers[:selenium] + capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(chromeOptions: {args: %w[headless disable-gpu]}) + Capybara::Selenium::Driver.new(app, browser: :chrome, desired_capabilities: capabilities) +end +# Select javascript driver with env variable, using chrome by default +Capybara.javascript_driver = ENV['JAVASCRIPT_DRIVER'].try(:to_sym) || :headless_chrome + +# Keep up to the number of screenshots specified in the hash +Capybara::Screenshot.prune_strategy = {keep: 5} From 5e91e5877374ec50e7e6183f48577f699fc64f1b Mon Sep 17 00:00:00 2001 From: Fabio Napoleoni Date: Mon, 2 Oct 2017 23:27:09 +0200 Subject: [PATCH 15/29] Fix dummy application boot --- spec/dummy/config/boot.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spec/dummy/config/boot.rb b/spec/dummy/config/boot.rb index f6162e6d..5a1fb928 100644 --- a/spec/dummy/config/boot.rb +++ b/spec/dummy/config/boot.rb @@ -1,7 +1,9 @@ unless defined?(ATTACHINARY_ORM) - ATTACHINARY_ORM = (ENV["ATTACHINARY_ORM"] || :active_record).to_sym + ATTACHINARY_ORM = (ENV['ATTACHINARY_ORM'] || :active_record).to_sym end -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__) -require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) +$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__) From d43b1dcbb117ca0bf360ae72b8bbac45978567f0 Mon Sep 17 00:00:00 2001 From: Fabio Napoleoni Date: Mon, 2 Oct 2017 23:27:57 +0200 Subject: [PATCH 16/29] Cleanup dummy application --- spec/dummy/Gemfile | 62 ------------- spec/dummy/config/application.rb | 2 +- .../config/initializers/session_store.rb | 2 +- spec/dummy/config/routes.rb | 55 ----------- spec/dummy/spec/rails_helper.rb | 53 ----------- spec/dummy/spec/spec_helper.rb | 92 ------------------- spec/dummy/test/controllers/.keep | 0 .../test/controllers/notes_controller_test.rb | 49 ---------- spec/dummy/test/fixtures/.keep | 0 spec/dummy/test/fixtures/notes.yml | 7 -- spec/dummy/test/helpers/.keep | 0 spec/dummy/test/integration/.keep | 0 spec/dummy/test/mailers/.keep | 0 spec/dummy/test/models/.keep | 0 spec/dummy/test/models/note_test.rb | 7 -- spec/dummy/test/test_helper.rb | 10 -- 16 files changed, 2 insertions(+), 337 deletions(-) delete mode 100644 spec/dummy/Gemfile delete mode 100644 spec/dummy/spec/rails_helper.rb delete mode 100644 spec/dummy/spec/spec_helper.rb delete mode 100644 spec/dummy/test/controllers/.keep delete mode 100644 spec/dummy/test/controllers/notes_controller_test.rb delete mode 100644 spec/dummy/test/fixtures/.keep delete mode 100644 spec/dummy/test/fixtures/notes.yml delete mode 100644 spec/dummy/test/helpers/.keep delete mode 100644 spec/dummy/test/integration/.keep delete mode 100644 spec/dummy/test/mailers/.keep delete mode 100644 spec/dummy/test/models/.keep delete mode 100644 spec/dummy/test/models/note_test.rb delete mode 100644 spec/dummy/test/test_helper.rb diff --git a/spec/dummy/Gemfile b/spec/dummy/Gemfile deleted file mode 100644 index 23c7b0ac..00000000 --- a/spec/dummy/Gemfile +++ /dev/null @@ -1,62 +0,0 @@ -source 'https://rubygems.org' - - -# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '~> 4.2.3' -# Use sqlite3 as the database for Active Record -gem 'sqlite3' -# Use SCSS for stylesheets -gem 'sass-rails', '~> 5.0' -# Use Uglifier as compressor for JavaScript assets -gem 'uglifier', '>= 1.3.0' -# Use CoffeeScript for .coffee assets and views -gem 'coffee-rails', '~> 4.1.0' -# See https://github.com/rails/execjs#readme for more supported runtimes -# gem 'therubyracer', platforms: :ruby - -# Use jquery as the JavaScript library -gem 'jquery-rails' -# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks -gem 'turbolinks' -# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder -gem 'jbuilder', '~> 2.0' -# bundle exec rake doc:rails generates the API under doc/api. -gem 'sdoc', '~> 0.4.0', group: :doc - -# Use ActiveModel has_secure_password -# gem 'bcrypt', '~> 3.1.7' - -# Use Unicorn as the app server -# gem 'unicorn' - -# Use Capistrano for deployment -# gem 'capistrano-rails', group: :development - -group :development, :test do - # Call 'byebug' anywhere in the code to stop execution and get a debugger console - gem 'byebug' - - # Access an IRB console on exception pages or by using <%= console %> in views - gem 'web-console', '~> 2.0' - - # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring - gem 'spring' - gem 'rspec-rails' - gem 'ruby-debug-ide' - gem 'debase' - gem 'valid_attribute' - gem 'capybara' - gem 'capybara-webkit' - gem 'selenium-webdriver' - gem 'factory_girl_rails' - gem 'launchy' - gem 'database_cleaner' - gem 'rb-fsevent', '~> 0.9.1' - gem 'guard-rspec' -end - -gem 'mongoid' -gem 'cloudinary', '~> 1.1' -gem 'attachinary', :path => '../..' -gem 'bootstrap-sass', '~> 3.3.5' -gem 'simple_form' \ No newline at end of file diff --git a/spec/dummy/config/application.rb b/spec/dummy/config/application.rb index 4f24558d..6ffa5227 100644 --- a/spec/dummy/config/application.rb +++ b/spec/dummy/config/application.rb @@ -12,7 +12,7 @@ require "attachinary" -module Dummy4 +module Dummy class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers diff --git a/spec/dummy/config/initializers/session_store.rb b/spec/dummy/config/initializers/session_store.rb index 6822d5e1..e766b67b 100644 --- a/spec/dummy/config/initializers/session_store.rb +++ b/spec/dummy/config/initializers/session_store.rb @@ -1,3 +1,3 @@ # Be sure to restart your server when you modify this file. -Rails.application.config.session_store :cookie_store, key: '_dummy4_session' +Rails.application.config.session_store :cookie_store, key: '_dummy_session' diff --git a/spec/dummy/config/routes.rb b/spec/dummy/config/routes.rb index a52ead51..dcf061f0 100644 --- a/spec/dummy/config/routes.rb +++ b/spec/dummy/config/routes.rb @@ -2,59 +2,4 @@ mount Attachinary::Engine => "/attachinary" resources :notes root to: 'notes#index' - - # The priority is based upon order of creation: first created -> highest priority. - # See how all your routes lay out with "rake routes". - - # You can have the root of your site routed with "root" - # root 'welcome#index' - - # Example of regular route: - # get 'products/:id' => 'catalog#view' - - # Example of named route that can be invoked with purchase_url(id: product.id) - # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase - - # Example resource route (maps HTTP verbs to controller actions automatically): - # resources :products - - # Example resource route with options: - # resources :products do - # member do - # get 'short' - # post 'toggle' - # end - # - # collection do - # get 'sold' - # end - # end - - # Example resource route with sub-resources: - # resources :products do - # resources :comments, :sales - # resource :seller - # end - - # Example resource route with more complex sub-resources: - # resources :products do - # resources :comments - # resources :sales do - # get 'recent', on: :collection - # end - # end - - # Example resource route with concerns: - # concern :toggleable do - # post 'toggle' - # end - # resources :posts, concerns: :toggleable - # resources :photos, concerns: :toggleable - - # Example resource route within a namespace: - # namespace :admin do - # # Directs /admin/products/* to Admin::ProductsController - # # (app/controllers/admin/products_controller.rb) - # resources :products - # end end diff --git a/spec/dummy/spec/rails_helper.rb b/spec/dummy/spec/rails_helper.rb deleted file mode 100644 index cfc75d18..00000000 --- a/spec/dummy/spec/rails_helper.rb +++ /dev/null @@ -1,53 +0,0 @@ -# This file is copied to spec/ when you run 'rails generate rspec:install' -ENV['RAILS_ENV'] ||= 'test' -require File.expand_path('../../config/environment', __FILE__) -# Prevent database truncation if the environment is production -abort("The Rails environment is running in production mode!") if Rails.env.production? -require 'spec_helper' -require 'rspec/rails' -# Add additional requires below this line. Rails is not loaded until this point! - -# Requires supporting ruby files with custom matchers and macros, etc, in -# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are -# run as spec files by default. This means that files in spec/support that end -# in _spec.rb will both be required and run as specs, causing the specs to be -# run twice. It is recommended that you do not name files matching this glob to -# end with _spec.rb. You can configure this pattern with the --pattern -# option on the command line or in ~/.rspec, .rspec or `.rspec-local`. -# -# The following line is provided for convenience purposes. It has the downside -# of increasing the boot-up time by auto-requiring all files in the support -# directory. Alternatively, in the individual `*_spec.rb` files, manually -# require only the support files necessary. -# -# Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } - -# Checks for pending migrations before tests are run. -# If you are not using ActiveRecord, you can remove this line. -ActiveRecord::Migration.maintain_test_schema! - -RSpec.configure do |config| - # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = "#{::Rails.root}/spec/fixtures" - - # If you're not using ActiveRecord, or you'd prefer not to run each of your - # examples within a transaction, remove the following line or assign false - # instead of true. - config.use_transactional_fixtures = true - - # RSpec Rails can automatically mix in different behaviours to your tests - # based on their file location, for example enabling you to call `get` and - # `post` in specs under `spec/controllers`. - # - # You can disable this behaviour by removing the line below, and instead - # explicitly tag your specs with their type, e.g.: - # - # RSpec.describe UsersController, :type => :controller do - # # ... - # end - # - # The different available types are documented in the features, such as in - # https://relishapp.com/rspec/rspec-rails/docs - config.infer_spec_type_from_file_location! -end -require '../spec_helper.rb' \ No newline at end of file diff --git a/spec/dummy/spec/spec_helper.rb b/spec/dummy/spec/spec_helper.rb deleted file mode 100644 index 913e28a6..00000000 --- a/spec/dummy/spec/spec_helper.rb +++ /dev/null @@ -1,92 +0,0 @@ -# This file was generated by the `rails generate rspec:install` command. Conventionally, all -# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. -# The generated `.rspec` file contains `--require spec_helper` which will cause -# this file to always be loaded, without a need to explicitly require it in any -# files. -# -# Given that it is always loaded, you are encouraged to keep this file as -# light-weight as possible. Requiring heavyweight dependencies from this file -# will add to the boot time of your test suite on EVERY test run, even for an -# individual file that may not need all of that loaded. Instead, consider making -# a separate helper file that requires the additional dependencies and performs -# the additional setup, and require it from the spec files that actually need -# it. -# -# The `.rspec` file also contains a few flags that are not defaults but that -# users commonly want. -# -# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration -RSpec.configure do |config| - # rspec-expectations config goes here. You can use an alternate - # assertion/expectation library such as wrong or the stdlib/minitest - # assertions if you prefer. - config.expect_with :rspec do |expectations| - # This option will default to `true` in RSpec 4. It makes the `description` - # and `failure_message` of custom matchers include text for helper methods - # defined using `chain`, e.g.: - # be_bigger_than(2).and_smaller_than(4).description - # # => "be bigger than 2 and smaller than 4" - # ...rather than: - # # => "be bigger than 2" - expectations.include_chain_clauses_in_custom_matcher_descriptions = true - end - - # rspec-mocks config goes here. You can use an alternate test double - # library (such as bogus or mocha) by changing the `mock_with` option here. - config.mock_with :rspec do |mocks| - # Prevents you from mocking or stubbing a method that does not exist on - # a real object. This is generally recommended, and will default to - # `true` in RSpec 4. - mocks.verify_partial_doubles = true - end - -# The settings below are suggested to provide a good initial experience -# with RSpec, but feel free to customize to your heart's content. -=begin - # These two settings work together to allow you to limit a spec run - # to individual examples or groups you care about by tagging them with - # `:focus` metadata. When nothing is tagged with `:focus`, all examples - # get run. - config.filter_run :focus - config.run_all_when_everything_filtered = true - - # Allows RSpec to persist some state between runs in order to support - # the `--only-failures` and `--next-failure` CLI options. We recommend - # you configure your source control system to ignore this file. - config.example_status_persistence_file_path = "spec/examples.txt" - - # Limits the available syntax to the non-monkey patched syntax that is - # recommended. For more details, see: - # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax - # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ - # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching - config.disable_monkey_patching! - - # Many RSpec users commonly either run the entire suite or an individual - # file, and it's useful to allow more verbose output when running an - # individual spec file. - if config.files_to_run.one? - # Use the documentation formatter for detailed output, - # unless a formatter has already been configured - # (e.g. via a command-line flag). - config.default_formatter = 'doc' - end - - # Print the 10 slowest examples and example groups at the - # end of the spec run, to help surface which specs are running - # particularly slow. - config.profile_examples = 10 - - # Run specs in random order to surface order dependencies. If you find an - # order dependency and want to debug it, you can fix the order by providing - # the seed, which is printed after each run. - # --seed 1234 - config.order = :random - - # Seed global randomization in this process using the `--seed` CLI option. - # Setting this allows you to use `--seed` to deterministically reproduce - # test failures related to randomization by passing the same `--seed` value - # as the one that triggered the failure. - Kernel.srand config.seed -=end -end diff --git a/spec/dummy/test/controllers/.keep b/spec/dummy/test/controllers/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/spec/dummy/test/controllers/notes_controller_test.rb b/spec/dummy/test/controllers/notes_controller_test.rb deleted file mode 100644 index 76db60fc..00000000 --- a/spec/dummy/test/controllers/notes_controller_test.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'test_helper' - -class NotesControllerTest < ActionController::TestCase - setup do - @note = notes(:one) - end - - test "should get index" do - get :index - assert_response :success - assert_not_nil assigns(:notes) - end - - test "should get new" do - get :new - assert_response :success - end - - test "should create note" do - assert_difference('Note.count') do - post :create, note: { body: @note.body } - end - - assert_redirected_to note_path(assigns(:note)) - end - - test "should show note" do - get :show, id: @note - assert_response :success - end - - test "should get edit" do - get :edit, id: @note - assert_response :success - end - - test "should update note" do - patch :update, id: @note, note: { body: @note.body } - assert_redirected_to note_path(assigns(:note)) - end - - test "should destroy note" do - assert_difference('Note.count', -1) do - delete :destroy, id: @note - end - - assert_redirected_to notes_path - end -end diff --git a/spec/dummy/test/fixtures/.keep b/spec/dummy/test/fixtures/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/spec/dummy/test/fixtures/notes.yml b/spec/dummy/test/fixtures/notes.yml deleted file mode 100644 index 5bbe4159..00000000 --- a/spec/dummy/test/fixtures/notes.yml +++ /dev/null @@ -1,7 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html - -one: - body: MyString - -two: - body: MyString diff --git a/spec/dummy/test/helpers/.keep b/spec/dummy/test/helpers/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/spec/dummy/test/integration/.keep b/spec/dummy/test/integration/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/spec/dummy/test/mailers/.keep b/spec/dummy/test/mailers/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/spec/dummy/test/models/.keep b/spec/dummy/test/models/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/spec/dummy/test/models/note_test.rb b/spec/dummy/test/models/note_test.rb deleted file mode 100644 index 7bbab537..00000000 --- a/spec/dummy/test/models/note_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class NoteTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/spec/dummy/test/test_helper.rb b/spec/dummy/test/test_helper.rb deleted file mode 100644 index 92e39b2d..00000000 --- a/spec/dummy/test/test_helper.rb +++ /dev/null @@ -1,10 +0,0 @@ -ENV['RAILS_ENV'] ||= 'test' -require File.expand_path('../../config/environment', __FILE__) -require 'rails/test_help' - -class ActiveSupport::TestCase - # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. - fixtures :all - - # Add more helper methods to be used by all tests here... -end From e42d910bad84337d308d41d035a995c8ab54330e Mon Sep 17 00:00:00 2001 From: Fabio Napoleoni Date: Mon, 2 Oct 2017 23:41:35 +0200 Subject: [PATCH 17/29] Installed gems needed to boot the dummy application --- Gemfile | 9 +++++++-- spec/dummy/.bowerrc | 3 --- .../app/assets/javascripts/application.js | 1 - .../app/views/layouts/application.html.erb | 4 ++-- spec/dummy/bower.json | 20 ------------------- spec/rails_helper.rb | 4 ++++ 6 files changed, 13 insertions(+), 28 deletions(-) delete mode 100644 spec/dummy/.bowerrc delete mode 100644 spec/dummy/bower.json diff --git a/Gemfile b/Gemfile index 9bdeb918..665c66d8 100644 --- a/Gemfile +++ b/Gemfile @@ -13,8 +13,13 @@ gem 'jquery-rails' gem 'cloudinary' gem 'simple_form' -group :assets do - gem 'coffee-rails' +# Assets gems used in dummy application +gem 'coffee-rails' +gem 'sass-rails' +gem 'bootstrap-sass', '~> 3.3.5' + +source 'https://rails-assets.org' do + gem 'rails-assets-blueimp-file-upload', '7.2.1' end group :mongoid do diff --git a/spec/dummy/.bowerrc b/spec/dummy/.bowerrc deleted file mode 100644 index 69fbc34f..00000000 --- a/spec/dummy/.bowerrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "directory": "vendor/assets/components" -} diff --git a/spec/dummy/app/assets/javascripts/application.js b/spec/dummy/app/assets/javascripts/application.js index ecd496c9..88f71180 100644 --- a/spec/dummy/app/assets/javascripts/application.js +++ b/spec/dummy/app/assets/javascripts/application.js @@ -12,7 +12,6 @@ // //= require jquery //= require jquery_ujs -//= require turbolinks //= require bootstrap-sprockets //= require blueimp-file-upload/js/vendor/jquery.ui.widget //= require blueimp-file-upload/js/jquery.iframe-transport diff --git a/spec/dummy/app/views/layouts/application.html.erb b/spec/dummy/app/views/layouts/application.html.erb index b38f4c1f..1d6d26bd 100644 --- a/spec/dummy/app/views/layouts/application.html.erb +++ b/spec/dummy/app/views/layouts/application.html.erb @@ -2,8 +2,8 @@ Dummy4 - <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> - <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> + <%= stylesheet_link_tag 'application', media: 'all' %> + <%= javascript_include_tag 'application' %> <%= cloudinary_js_config %> <%= csrf_meta_tags %> diff --git a/spec/dummy/bower.json b/spec/dummy/bower.json deleted file mode 100644 index 248ee3b3..00000000 --- a/spec/dummy/bower.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "dummy4", - "version": "1.2.6", - "homepage": "https://github.com/assembler/attachinary", - "authors": [ - "Amir Tocker " - ], - "license": "MIT", - "ignore": [ - "**/.*", - "node_modules", - "bower_components", - "test", - "tests" - ], - "dependencies": { - "jquery": ">=1.6", - "blueimp-file-upload": ">=7.2.1" - } -} diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 2a0b4aa8..8b23cbb9 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -9,6 +9,10 @@ # Add additional requires below this line. Rails is not loaded until this point! # Define rails root as const ENGINE_RAILS_ROOT = File.join(File.dirname(__FILE__), '../') +# Define const used in features and require appropriate orm configuration +SPEC_ROOT = File.realpath(File.join(ENGINE_RAILS_ROOT, 'spec')) +require "#{SPEC_ROOT}/orm/#{ATTACHINARY_ORM}" +require 'valid_attribute' # Requires supporting ruby files with custom matchers and macros, etc, in # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are From 9842dfacf76f493d0413db29cba70a5a3696ad81 Mon Sep 17 00:00:00 2001 From: Fabio Napoleoni Date: Mon, 2 Oct 2017 23:50:03 +0200 Subject: [PATCH 18/29] Working feature specs with latest capybara gem --- Gemfile | 2 +- spec/support/request_helpers.rb | 21 --------------------- 2 files changed, 1 insertion(+), 22 deletions(-) delete mode 100644 spec/support/request_helpers.rb diff --git a/Gemfile b/Gemfile index 665c66d8..60269009 100644 --- a/Gemfile +++ b/Gemfile @@ -31,7 +31,7 @@ group :development, :test do gem 'sqlite3' gem 'rspec-rails', '~> 3.5' gem 'valid_attribute' - gem 'capybara' + gem 'capybara', '>= 2.15.2' gem 'capybara-screenshot' gem 'selenium-webdriver' gem 'factory_girl_rails' diff --git a/spec/support/request_helpers.rb b/spec/support/request_helpers.rb deleted file mode 100644 index de909358..00000000 --- a/spec/support/request_helpers.rb +++ /dev/null @@ -1,21 +0,0 @@ -module RequestHelpers - - def handle_alert - page.execute_script "window.original_alert_function = window.alert" - page.execute_script "window.alert_message = null" - page.execute_script "window.alert = function(msg) { window.alert_message = msg; }" - yield - ensure - page.execute_script "window.alert = window.original_alert_function" - end - - def alert_message - page.evaluate_script "window.alert_message" - end - -end - -# Include module in features -RSpec.configure do |config| - config.include RequestHelpers, type: :feature -end \ No newline at end of file From e67c0f14a427de8db7c532fe0ec3997b4cc281c7 Mon Sep 17 00:00:00 2001 From: Fabio Napoleoni Date: Tue, 3 Oct 2017 00:30:09 +0200 Subject: [PATCH 19/29] VCR testing to avoid actual interactions with cloudinary remote api in CI --- Gemfile | 2 + .../after_destroy/destroys_attached_files.yml | 109 ++++++++++++++++++ ...ry_config_attachinary_keep_remote_true.yml | 55 +++++++++ .../saves_the_record.yml | 56 +++++++++ .../saves_the_record.yml | 56 +++++++++ .../saves_the_record.yml | 56 +++++++++ spec/features/notes_spec.rb | 4 +- spec/models/note_spec.rb | 6 +- .../support/cloudinary-sample-credentials.yml | 7 ++ spec/support/database_cleaner.rb | 14 --- spec/support/vcr.rb | 16 +++ 11 files changed, 361 insertions(+), 20 deletions(-) create mode 100644 spec/cassettes/Note/callbacks/after_destroy/destroys_attached_files.yml create mode 100644 spec/cassettes/Note/callbacks/after_destroy/keeps_attached_files_if_Cloudinary_config_attachinary_keep_remote_true.yml create mode 100644 spec/cassettes/Notes/Creating_new_note/builder_form/behaves_like_any_form/saves_the_record.yml create mode 100644 spec/cassettes/Notes/Creating_new_note/raw_form/behaves_like_any_form/saves_the_record.yml create mode 100644 spec/cassettes/Notes/Creating_new_note/simple_form/behaves_like_any_form/saves_the_record.yml create mode 100644 spec/support/cloudinary-sample-credentials.yml create mode 100644 spec/support/vcr.rb diff --git a/Gemfile b/Gemfile index 60269009..0317ec17 100644 --- a/Gemfile +++ b/Gemfile @@ -37,6 +37,8 @@ group :development, :test do gem 'factory_girl_rails' gem 'launchy' gem 'database_cleaner' + gem 'vcr' + gem 'webmock' end diff --git a/spec/cassettes/Note/callbacks/after_destroy/destroys_attached_files.yml b/spec/cassettes/Note/callbacks/after_destroy/destroys_attached_files.yml new file mode 100644 index 00000000..2a0d4a95 --- /dev/null +++ b/spec/cassettes/Note/callbacks/after_destroy/destroys_attached_files.yml @@ -0,0 +1,109 @@ +--- +http_interactions: +- request: + method: post + uri: https://api.cloudinary.com/v1_1//image/tags + body: + encoding: UTF-8 + string: timestamp=1506982870&tag=attachinary_tmp&public_ids[]=id7&command=remove&signature=b7ec00290190989be00e351c224232873ba06d03&api_key= + headers: + Accept: + - "*/*; q=0.5, application/xml" + Accept-Encoding: + - gzip, deflate + User-Agent: + - cld-ruby-1.1.0 + Content-Length: + - '147' + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Content-Encoding: + - gzip + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 02 Oct 2017 22:21:11 GMT + Etag: + - W/"7bd9202622f9de0e2f09217fcdc4d855" + Server: + - cloudinary + Status: + - 200 OK + X-Request-Id: + - b723a839f0c1f0d9 + X-Ua-Compatible: + - IE=Edge,chrome=1 + X-Xss-Protection: + - 1; mode=block + Transfer-Encoding: + - chunked + Connection: + - keep-alive + body: + encoding: ASCII-8BIT + string: !binary |- + H4sIAAAAAAAAAwAAAP//qlYqKE3KyUyOz0wpVrKKjq0FAAAA//8DANqCv0cR + AAAA + http_version: + recorded_at: Mon, 02 Oct 2017 22:21:11 GMT +- request: + method: post + uri: https://api.cloudinary.com/v1_1//image/destroy + body: + encoding: UTF-8 + string: timestamp=1506982871&public_id=id7&signature=b43d538e93d5eba1e946af0f0def4e8ebc5251f7&api_key= + headers: + Accept: + - "*/*; q=0.5, application/xml" + Accept-Encoding: + - gzip, deflate + User-Agent: + - cld-ruby-1.1.0 + Content-Length: + - '109' + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Content-Encoding: + - gzip + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 02 Oct 2017 22:21:11 GMT + Etag: + - W/"33747e3f086d5dd0aef7ac1fde8cf595" + Server: + - cloudinary + Status: + - 200 OK + X-Request-Id: + - 4d4d7b28287ac804 + X-Ua-Compatible: + - IE=Edge,chrome=1 + X-Xss-Protection: + - 1; mode=block + Content-Length: + - '48' + Connection: + - keep-alive + body: + encoding: ASCII-8BIT + string: !binary |- + H4sIAAAAAAAAA6pWKkotLs0pUbJSyssvUUjLL81LUaoFAAAA//8DAPI2A+8W + AAAA + http_version: + recorded_at: Mon, 02 Oct 2017 22:21:11 GMT +recorded_with: VCR 3.0.3 diff --git a/spec/cassettes/Note/callbacks/after_destroy/keeps_attached_files_if_Cloudinary_config_attachinary_keep_remote_true.yml b/spec/cassettes/Note/callbacks/after_destroy/keeps_attached_files_if_Cloudinary_config_attachinary_keep_remote_true.yml new file mode 100644 index 00000000..1a2a9a62 --- /dev/null +++ b/spec/cassettes/Note/callbacks/after_destroy/keeps_attached_files_if_Cloudinary_config_attachinary_keep_remote_true.yml @@ -0,0 +1,55 @@ +--- +http_interactions: +- request: + method: post + uri: https://api.cloudinary.com/v1_1//image/tags + body: + encoding: UTF-8 + string: timestamp=1506982869&tag=attachinary_tmp&public_ids[]=id6&command=remove&signature=a1184f17147d67ae680e20835a8a63f6517a8312&api_key= + headers: + Accept: + - "*/*; q=0.5, application/xml" + Accept-Encoding: + - gzip, deflate + User-Agent: + - cld-ruby-1.1.0 + Content-Length: + - '147' + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Content-Encoding: + - gzip + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 02 Oct 2017 22:21:10 GMT + Etag: + - W/"7bd9202622f9de0e2f09217fcdc4d855" + Server: + - cloudinary + Status: + - 200 OK + X-Request-Id: + - 8951c2b4856d195f + X-Ua-Compatible: + - IE=Edge,chrome=1 + X-Xss-Protection: + - 1; mode=block + Content-Length: + - '43' + Connection: + - keep-alive + body: + encoding: ASCII-8BIT + string: !binary |- + H4sIAAAAAAAAA6pWKihNyslMjs9MKVayio6tBQAAAP//AwDagr9HEQAAAA== + http_version: + recorded_at: Mon, 02 Oct 2017 22:21:10 GMT +recorded_with: VCR 3.0.3 diff --git a/spec/cassettes/Notes/Creating_new_note/builder_form/behaves_like_any_form/saves_the_record.yml b/spec/cassettes/Notes/Creating_new_note/builder_form/behaves_like_any_form/saves_the_record.yml new file mode 100644 index 00000000..f5788edf --- /dev/null +++ b/spec/cassettes/Notes/Creating_new_note/builder_form/behaves_like_any_form/saves_the_record.yml @@ -0,0 +1,56 @@ +--- +http_interactions: +- request: + method: post + uri: https://api.cloudinary.com/v1_1//image/tags + body: + encoding: UTF-8 + string: timestamp=1506983277&tag=attachinary_tmp&public_ids[]=tbxznuxsw67yhwjasnue&command=remove&signature=84df14b35dba3da27e7408236dac17340641ac08&api_key= + headers: + Accept: + - "*/*; q=0.5, application/xml" + Accept-Encoding: + - gzip, deflate + User-Agent: + - cld-ruby-1.1.0 + Content-Length: + - '164' + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Content-Encoding: + - gzip + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 02 Oct 2017 22:27:57 GMT + Etag: + - W/"083321b588a6675f8d8e5abbef98310e" + Server: + - cloudinary + Status: + - 200 OK + X-Request-Id: + - bdf707e4712db3f2 + X-Ua-Compatible: + - IE=Edge,chrome=1 + X-Xss-Protection: + - 1; mode=block + Content-Length: + - '65' + Connection: + - keep-alive + body: + encoding: ASCII-8BIT + string: !binary |- + H4sIAAAAAAAAA6pWKihNyslMjs9MKVayilYqSaqoyiutKC43M6/MKM9KLM4r + TVWKrQUAAAD//wMAbSg3QScAAAA= + http_version: + recorded_at: Mon, 02 Oct 2017 22:27:57 GMT +recorded_with: VCR 3.0.3 diff --git a/spec/cassettes/Notes/Creating_new_note/raw_form/behaves_like_any_form/saves_the_record.yml b/spec/cassettes/Notes/Creating_new_note/raw_form/behaves_like_any_form/saves_the_record.yml new file mode 100644 index 00000000..a937747b --- /dev/null +++ b/spec/cassettes/Notes/Creating_new_note/raw_form/behaves_like_any_form/saves_the_record.yml @@ -0,0 +1,56 @@ +--- +http_interactions: +- request: + method: post + uri: https://api.cloudinary.com/v1_1//image/tags + body: + encoding: UTF-8 + string: timestamp=1506983290&tag=attachinary_tmp&public_ids[]=immj14ntcithzcgsqzoo&command=remove&signature=8bddabb253a5a3b748939992b2996885f77bbe5e&api_key= + headers: + Accept: + - "*/*; q=0.5, application/xml" + Accept-Encoding: + - gzip, deflate + User-Agent: + - cld-ruby-1.1.0 + Content-Length: + - '164' + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Content-Encoding: + - gzip + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 02 Oct 2017 22:28:10 GMT + Etag: + - W/"732bdb6cb6721e2f23d28e39dc7ee3c6" + Server: + - cloudinary + Status: + - 200 OK + X-Request-Id: + - 2f3a4c56327587b4 + X-Ua-Compatible: + - IE=Edge,chrome=1 + X-Xss-Protection: + - 1; mode=block + Content-Length: + - '65' + Connection: + - keep-alive + body: + encoding: ASCII-8BIT + string: !binary |- + H4sIAAAAAAAAA6pWKihNyslMjs9MKVayilbKzM3NMjTJK0nOLMmoSk4vLqzK + z1eKrQUAAAD//wMASrueUScAAAA= + http_version: + recorded_at: Mon, 02 Oct 2017 22:28:10 GMT +recorded_with: VCR 3.0.3 diff --git a/spec/cassettes/Notes/Creating_new_note/simple_form/behaves_like_any_form/saves_the_record.yml b/spec/cassettes/Notes/Creating_new_note/simple_form/behaves_like_any_form/saves_the_record.yml new file mode 100644 index 00000000..5d59f124 --- /dev/null +++ b/spec/cassettes/Notes/Creating_new_note/simple_form/behaves_like_any_form/saves_the_record.yml @@ -0,0 +1,56 @@ +--- +http_interactions: +- request: + method: post + uri: https://api.cloudinary.com/v1_1//image/tags + body: + encoding: UTF-8 + string: timestamp=1506983283&tag=attachinary_tmp&public_ids[]=dkzhr7qiuhiwoqc0mrdi&command=remove&signature=bfbfd9e6ff24e5ea8b856338aaff6e3aba2fbd6b&api_key= + headers: + Accept: + - "*/*; q=0.5, application/xml" + Accept-Encoding: + - gzip, deflate + User-Agent: + - cld-ruby-1.1.0 + Content-Length: + - '164' + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Cache-Control: + - max-age=0, private, must-revalidate + Content-Encoding: + - gzip + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 02 Oct 2017 22:28:04 GMT + Etag: + - W/"f83bc72543f26e16e6b5d5a8471ce4fb" + Server: + - cloudinary + Status: + - 200 OK + X-Request-Id: + - f57f8a2c28ed5518 + X-Ua-Compatible: + - IE=Edge,chrome=1 + X-Xss-Protection: + - 1; mode=block + Content-Length: + - '65' + Connection: + - keep-alive + body: + encoding: ASCII-8BIT + string: !binary |- + H4sIAAAAAAAAA6pWKihNyslMjs9MKVayilZKya7KKDIvzCzNyCzPL0w2yC1K + yVSKrQUAAAD//wMAucPwBCcAAAA= + http_version: + recorded_at: Mon, 02 Oct 2017 22:28:04 GMT +recorded_with: VCR 3.0.3 diff --git a/spec/features/notes_spec.rb b/spec/features/notes_spec.rb index 0ac65222..92bdbf27 100644 --- a/spec/features/notes_spec.rb +++ b/spec/features/notes_spec.rb @@ -1,6 +1,4 @@ RSpec.describe 'Notes' do - Capybara.default_wait_time = 15 - describe 'Creating new note' do shared_examples_for "any form" do @@ -60,7 +58,7 @@ end end - it 'saves the record', :js => true do + it 'saves the record', :js, :vcr do fill_in 'note[body]', with: 'My Note' within 'div.photo' do attach_file "note[photo]", "#{SPEC_ROOT}/support/A.gif" diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index eb97190d..e094c773 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -15,13 +15,13 @@ Cloudinary.config.delete_field(:attachinary_keep_remote) if Cloudinary.config.respond_to?(:attachinary_keep_remote) end - it "destroys attached files" do + it "destroys attached files", :vcr do note = create(:note, photo: photo) - expect(Cloudinary::Uploader).to receive(:destroy).with(photo.public_id) + expect(Cloudinary::Uploader).to receive(:destroy).with(photo.public_id).and_call_original note.destroy end - it "keeps attached files if Cloudinary.config.attachinary_keep_remote == true" do + it "keeps attached files if Cloudinary.config.attachinary_keep_remote == true", :vcr do Cloudinary.config.attachinary_keep_remote = true note = create(:note, photo: photo) expect(Cloudinary::Uploader).not_to receive(:destroy).with(photo.public_id) diff --git a/spec/support/cloudinary-sample-credentials.yml b/spec/support/cloudinary-sample-credentials.yml new file mode 100644 index 00000000..1952110b --- /dev/null +++ b/spec/support/cloudinary-sample-credentials.yml @@ -0,0 +1,7 @@ +--- +test: + cloud_name: somename + api_key: '1234567890' + api_secret: FooBarBaz123 + enhance_image_tag: true + static_image_support: false diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb index 2d5b53df..33373977 100644 --- a/spec/support/database_cleaner.rb +++ b/spec/support/database_cleaner.rb @@ -17,18 +17,4 @@ config.append_after(:each) do DatabaseCleaner.clean end - - config.after(:suite) do - print "\n\n Cleaning up uploaded files" - - begin - Cloudinary::Api.delete_resources_by_tag('test_env') - print ' (done)' - rescue Cloudinary::Api::RateLimited => e - print " (#{e.message})" - end - - print "\n\n" - end - end diff --git a/spec/support/vcr.rb b/spec/support/vcr.rb new file mode 100644 index 00000000..4155e28a --- /dev/null +++ b/spec/support/vcr.rb @@ -0,0 +1,16 @@ +require 'vcr' + +VCR.configure do |c| + c.cassette_library_dir = 'spec/cassettes' + c.hook_into :webmock + c.configure_rspec_metadata! + c.ignore_localhost = true + # Rerecord cassettes if requested with env variable + c.default_cassette_options = {record: :all} if ENV['VCR_REGENERATE'] + # Do not store cloudinary authentication in cassettes + c.filter_sensitive_data('') { Cloudinary.config.cloud_name } + c.filter_sensitive_data('') { Cloudinary.config.api_key } + c.filter_sensitive_data('') { Cloudinary.config.api_secret } + # Ignore signatures passed to cloudinary when matching requests + c.default_cassette_options = {match_requests_on: [:method, VCR.request_matchers.uri_without_param(:signature)]} +end \ No newline at end of file From 077222b75b09aadc31913664f99170b1db8045d4 Mon Sep 17 00:00:00 2001 From: Fabio Napoleoni Date: Tue, 3 Oct 2017 00:39:33 +0200 Subject: [PATCH 20/29] Travis configuration to automatically spec the project --- .travis.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..4b7fca6a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,18 @@ +language: ruby +rvm: + - 2.3.1 +# Enable headless testing with chrome +dist: trusty +addons: + chrome: stable +before_install: + - # start your web application and listen on `localhost` + - google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost & + +# Copy sample credentials to expected path +before_script: + - cp spec/support/cloudinary-sample-credentials.yml spec/dummy/config/cloudinary.yml + - bundle exec rake db:setup +# Run RSpec +script: + bundle exec rake From ba5d418b01f5e129c0de3fe3417d23201d5ce836 Mon Sep 17 00:00:00 2001 From: Fabio Napoleoni Date: Tue, 3 Oct 2017 00:50:02 +0200 Subject: [PATCH 21/29] Install chrome driver before running specs --- .travis.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4b7fca6a..5fd2b811 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,10 +5,13 @@ rvm: dist: trusty addons: chrome: stable +# Install ChromeDriver (64bits). before_install: - - # start your web application and listen on `localhost` - - google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost & - + - wget -N http://chromedriver.storage.googleapis.com/2.32/chromedriver_linux64.zip -P ~/ + - unzip ~/chromedriver_linux64.zip -d ~/ + - rm ~/chromedriver_linux64.zip + - sudo mv -f ~/chromedriver /usr/local/bin + - sudo chmod +x /usr/local/bin/chromedriver # Copy sample credentials to expected path before_script: - cp spec/support/cloudinary-sample-credentials.yml spec/dummy/config/cloudinary.yml From 40c29ffad8cb26022d49f02393d2b2b6b47a4c92 Mon Sep 17 00:00:00 2001 From: Fabio Napoleoni Date: Tue, 3 Oct 2017 01:02:10 +0200 Subject: [PATCH 22/29] Start browser in background before executing specs --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5fd2b811..194d2a29 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,11 @@ rvm: dist: trusty addons: chrome: stable -# Install ChromeDriver (64bits). +# Headless test setup before_install: + - # start your web application and listen on `localhost` + - google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost & + # Install ChromeDriver (64bits). - wget -N http://chromedriver.storage.googleapis.com/2.32/chromedriver_linux64.zip -P ~/ - unzip ~/chromedriver_linux64.zip -d ~/ - rm ~/chromedriver_linux64.zip From 589fdb548eadf8f1eff1c5105dd90ce11ff8407f Mon Sep 17 00:00:00 2001 From: Fabio Napoleoni Date: Tue, 3 Oct 2017 01:13:26 +0200 Subject: [PATCH 23/29] Regenerated mongoid configuration, since previous one wasn't working --- spec/dummy/config/mongoid.yml | 152 +++++++++++++--------------------- 1 file changed, 59 insertions(+), 93 deletions(-) diff --git a/spec/dummy/config/mongoid.yml b/spec/dummy/config/mongoid.yml index 52c373b6..494201d2 100644 --- a/spec/dummy/config/mongoid.yml +++ b/spec/dummy/config/mongoid.yml @@ -1,101 +1,62 @@ development: - # Configure available database clients. (required) - clients: - # Defines the default client. (required) + # Configure available database sessions. (required) + sessions: + # Defines the default session. (required) default: # Defines the name of the default database that Mongoid can connect to. # (required). - database: dummy4_development - # Provides the hosts the default client can connect to. Must be an array + database: dummy_development + # Provides the hosts the default session can connect to. Must be an array # of host:port pairs. (required) hosts: - localhost:27017 options: # Change the default write concern. (default = { w: 1 }) # write: - # w: 1 - - # Change the default read preference. Valid options for mode are: :secondary, - # :secondary_preferred, :primary, :primary_preferred, :nearest - # (default: primary) - # read: - # mode: :secondary_preferred - - # The name of the user for authentication. - # user: 'user' - - # The password of the user for authentication. - # password: 'password' - - # The user's database roles. - # roles: - # - 'dbOwner' - - # Change the default authentication mechanism. Valid options are: :scram, - # :mongodb_cr, :mongodb_x509, and :plain. (default on 3.0 is :scram, default - # on 2.4 and 2.6 is :plain) - # auth_mech: :scram - - # The database or source to authenticate the user against. (default: admin) - # auth_source: admin - - # Force a the driver cluster to behave in a certain manner instead of auto- - # discovering. Can be one of: :direct, :replica_set, :sharded. Set to :direct - # when connecting to hidden members of a replica set. - # connect: :direct - - # Changes the default time in seconds the server monitors refresh their status - # via ismaster commands. (default: 10) - # heartbeat_frequency: 10 - - # The time in seconds for selecting servers for a near read preference. (default: 5) - # local_threshold: 5 - - # The timeout in seconds for selecting a server for an operation. (default: 30) - # server_selection_timeout: 30 - - # The maximum number of connections in the connection pool. (default: 5) - # max_pool_size: 5 - - # The minimum number of connections in the connection pool. (default: 1) - # min_pool_size: 1 - - # The time to wait, in seconds, in the connection pool for a connection - # to be checked in before timing out. (default: 5) - # wait_queue_timeout: 5 - - # The time to wait to establish a connection before timing out, in seconds. - # (default: 5) - # connect_timeout: 5 - - # The timeout to wait to execute operations on a socket before raising an error. - # (default: 5) - # socket_timeout: 5 - - # The name of the replica set to connect to. Servers provided as seeds that do - # not belong to this replica set will be ignored. - # replica_set: name - - # Whether to connect to the servers via ssl. (default: false) - # ssl: true - - # The certificate file used to identify the connection against MongoDB. - # ssl_cert: /path/to/my.cert - - # The private keyfile used to identify the connection against MongoDB. - # Note that even if the key is stored in the same file as the certificate, - # both need to be explicitly specified. - # ssl_key: /path/to/my.key - - # A passphrase for the private key. - # ssl_key_pass_phrase: password - - # Whether or not to do peer certification validation. (default: false) - # ssl_verify: true - - # The file containing a set of concatenated certification authority certifications - # used to validate certs passed from the other end of the connection. - # ssl_ca_cert: /path/to/ca.cert + # w: 1 + + # Change the default consistency model to primary, secondary. + # 'secondary' will send reads to secondaries, 'primary' sends everything + # to master. (default: primary) + # read: secondary_preferred + + # How many times Moped should attempt to retry an operation after + # failure. (default: The number of nodes in the cluster) + # max_retries: 20 + + # The time in seconds that Moped should wait before retrying an + # operation on failure. (default: 0.25) + # retry_interval: 0.25 + + # The connection pool size per-node. This should match or exceed the + # number of threads for a multi-threaded application. (default: 5) + # pool_size: 5 + + # The time in seconds that Moped should wait for the pool to provide + # an available connection. This number should probably remain at the + # default, unless for some reason you absolutely need to limit the + # pool_size, as this wait is only used when the pool is saturated. + # (default: 0.5) + # pool_timeout: 0.5 + + # The time in seconds before Moped will timeout connection and node + # operations. (default: 5) + # timeout: 5 + + # The amount of time in seconds between forced refreshes of node + # information including the discovery of new peers. (default: 300) + # refresh_interval: 300 + + # The amount of time in seconds that a node will be flagged as down. + # (default: 30) + # down_interval: 30 + + # Whether connections should use SSL. (default: nil/false) + # ssl: false + + # Whether Moped will use the existing seeds/nodes to find other peers. + # (default: true) + # auto_discover: true # Configure Mongoid specific options. (optional) @@ -110,6 +71,9 @@ development: # inheritance. (default: false) # preload_models: false + # Protect id and type from mass assignment. (default: true) + # protect_sensitive_fields: true + # Raise an error when performing a #find and the document is not found. # (default: true) # raise_not_found_error: true @@ -124,12 +88,14 @@ development: # Ensure all times are UTC in the app side. (default: false) # use_utc: false test: - clients: + sessions: default: - database: dummy4_test + database: dummy_test hosts: - localhost:27017 options: -# read: -# mode: primary - max_pool_size: 1 + read: primary + # In the test environment we lower the retries and retry interval to + # low amounts for fast failures. + max_retries: 1 + retry_interval: 0 From ed4f61eaa68f42fdb17f1fa78e6935279f006267 Mon Sep 17 00:00:00 2001 From: Fabio Napoleoni Date: Tue, 3 Oct 2017 01:30:12 +0200 Subject: [PATCH 24/29] Test mongoid using env variables in travis and disable features running in travis until I found a working config for headless testing --- .travis.yml | 7 +++++++ Rakefile | 29 +++++++++-------------------- spec/dummy/config/mongoid.yml | 2 +- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/.travis.yml b/.travis.yml index 194d2a29..a102fe2d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,13 @@ language: ruby rvm: - 2.3.1 +# For testing mongoid integration +services: + - mongodb +# Test both integrations +env: + - ATTACHINARY_ORM=active_record + - ATTACHINARY_ORM=mongoid # Enable headless testing with chrome dist: trusty addons: diff --git a/Rakefile b/Rakefile index 7eccbc95..9e2de802 100644 --- a/Rakefile +++ b/Rakefile @@ -27,26 +27,15 @@ load 'rails/tasks/engine.rake' Bundler::GemHelper.install_tasks -#require 'rake/spectask' - -# Spec::Rake::SpecTask.new(:spec) do |t| -# t.libs << 'lib' -# t.libs << 'spec' -# t.pattern = 'spec/**/*_spec.rb' -# t.verbose = false -# end - -require 'rspec/core/rake_task' -RSpec::Core::RakeTask.new(:spec) - - -desc 'Run Devise tests for all ORMs.' -task :spec_all_orms do - Dir[File.join(File.dirname(__FILE__), 'spec', 'orm', '*.rb')].each do |file| - orm = File.basename(file).split(".").first - puts "\n\n-------- ORM: #{orm}\n\n" - exit 1 unless system "rake spec ATTACHINARY_ORM=#{orm}" +# Configure rspec rake task +begin + require 'rspec/core/rake_task' + RSpec::Core::RakeTask.new(:spec) do |t| + t.rspec_opts = '--tag ~js' end +rescue LoadError + # no rspec available end -task :default => :spec_all_orms +# Configure default task +task :default => :spec \ No newline at end of file diff --git a/spec/dummy/config/mongoid.yml b/spec/dummy/config/mongoid.yml index 494201d2..4e2b1893 100644 --- a/spec/dummy/config/mongoid.yml +++ b/spec/dummy/config/mongoid.yml @@ -92,7 +92,7 @@ test: default: database: dummy_test hosts: - - localhost:27017 + - <%= ENV.fetch('MONGO_HOST', 'localhost') %>:<%= ENV.fetch('MONGO_PORT', '27017') %> options: read: primary # In the test environment we lower the retries and retry interval to From 1c19d8a20d57d8a8ec095353ad1a19484edf7a21 Mon Sep 17 00:00:00 2001 From: Fabio Napoleoni Date: Tue, 3 Oct 2017 01:50:38 +0200 Subject: [PATCH 25/29] Restored localhost configuration for mongodb connection --- spec/dummy/config/mongoid.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/dummy/config/mongoid.yml b/spec/dummy/config/mongoid.yml index 4e2b1893..494201d2 100644 --- a/spec/dummy/config/mongoid.yml +++ b/spec/dummy/config/mongoid.yml @@ -92,7 +92,7 @@ test: default: database: dummy_test hosts: - - <%= ENV.fetch('MONGO_HOST', 'localhost') %>:<%= ENV.fetch('MONGO_PORT', '27017') %> + - localhost:27017 options: read: primary # In the test environment we lower the retries and retry interval to From f500537cd6541733f3590140fb7492d06f56ecc9 Mon Sep 17 00:00:00 2001 From: Fabio Napoleoni Date: Tue, 3 Oct 2017 01:52:10 +0200 Subject: [PATCH 26/29] Cache bundler dependencies across builds --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index a102fe2d..5c869c16 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,8 @@ language: ruby rvm: - 2.3.1 +# Cache bundler dependencies +cache: bundler # For testing mongoid integration services: - mongodb From 855c1283932800d7f8ce2a9ab9e375020acfd336 Mon Sep 17 00:00:00 2001 From: Fabio Napoleoni Date: Tue, 3 Oct 2017 01:58:24 +0200 Subject: [PATCH 27/29] Fixed mongoid version to avoid connections issues --- Gemfile | 5 +- spec/dummy/config/mongoid.yml | 163 ++++++++++++++++++++++------------ 2 files changed, 106 insertions(+), 62 deletions(-) diff --git a/Gemfile b/Gemfile index 0317ec17..a5cdad2d 100644 --- a/Gemfile +++ b/Gemfile @@ -22,9 +22,8 @@ source 'https://rails-assets.org' do gem 'rails-assets-blueimp-file-upload', '7.2.1' end -group :mongoid do - gem 'mongoid' -end +# Stick with a working configuration +gem 'mongoid', '~> 5.0' group :development, :test do gem 'pry' diff --git a/spec/dummy/config/mongoid.yml b/spec/dummy/config/mongoid.yml index 494201d2..a993014d 100644 --- a/spec/dummy/config/mongoid.yml +++ b/spec/dummy/config/mongoid.yml @@ -1,62 +1,103 @@ development: - # Configure available database sessions. (required) - sessions: - # Defines the default session. (required) + # Configure available database clients. (required) + clients: + # Defines the default client. (required) default: # Defines the name of the default database that Mongoid can connect to. # (required). database: dummy_development - # Provides the hosts the default session can connect to. Must be an array + # Provides the hosts the default client can connect to. Must be an array # of host:port pairs. (required) hosts: - - localhost:27017 + - <%= ENV.fetch('MONGO_HOST', 'localhost') %>:<%= ENV.fetch('MONGO_PORT', '27017') %> options: # Change the default write concern. (default = { w: 1 }) # write: - # w: 1 - - # Change the default consistency model to primary, secondary. - # 'secondary' will send reads to secondaries, 'primary' sends everything - # to master. (default: primary) - # read: secondary_preferred - - # How many times Moped should attempt to retry an operation after - # failure. (default: The number of nodes in the cluster) - # max_retries: 20 - - # The time in seconds that Moped should wait before retrying an - # operation on failure. (default: 0.25) - # retry_interval: 0.25 - - # The connection pool size per-node. This should match or exceed the - # number of threads for a multi-threaded application. (default: 5) - # pool_size: 5 - - # The time in seconds that Moped should wait for the pool to provide - # an available connection. This number should probably remain at the - # default, unless for some reason you absolutely need to limit the - # pool_size, as this wait is only used when the pool is saturated. - # (default: 0.5) - # pool_timeout: 0.5 - - # The time in seconds before Moped will timeout connection and node - # operations. (default: 5) - # timeout: 5 - - # The amount of time in seconds between forced refreshes of node - # information including the discovery of new peers. (default: 300) - # refresh_interval: 300 - - # The amount of time in seconds that a node will be flagged as down. - # (default: 30) - # down_interval: 30 - - # Whether connections should use SSL. (default: nil/false) - # ssl: false - - # Whether Moped will use the existing seeds/nodes to find other peers. - # (default: true) - # auto_discover: true + # w: 1 + + # Change the default read preference. Valid options for mode are: :secondary, + # :secondary_preferred, :primary, :primary_preferred, :nearest + # (default: primary) + # read: + # mode: :secondary_preferred + # tag_sets: + # - use: web + + # The name of the user for authentication. + # user: 'user' + + # The password of the user for authentication. + # password: 'password' + + # The user's database roles. + # roles: + # - 'dbOwner' + + # Change the default authentication mechanism. Valid options are: :scram, + # :mongodb_cr, :mongodb_x509, and :plain. (default on 3.0 is :scram, default + # on 2.4 and 2.6 is :plain) + # auth_mech: :scram + + # The database or source to authenticate the user against. (default: admin) + # auth_source: admin + + # Force a the driver cluster to behave in a certain manner instead of auto- + # discovering. Can be one of: :direct, :replica_set, :sharded. Set to :direct + # when connecting to hidden members of a replica set. + # connect: :direct + + # Changes the default time in seconds the server monitors refresh their status + # via ismaster commands. (default: 10) + # heartbeat_frequency: 10 + + # The time in seconds for selecting servers for a near read preference. (default: 0.015) + # local_threshold: 0.015 + + # The timeout in seconds for selecting a server for an operation. (default: 30) + # server_selection_timeout: 30 + + # The maximum number of connections in the connection pool. (default: 5) + # max_pool_size: 5 + + # The minimum number of connections in the connection pool. (default: 1) + # min_pool_size: 1 + + # The time to wait, in seconds, in the connection pool for a connection + # to be checked in before timing out. (default: 5) + # wait_queue_timeout: 5 + + # The time to wait to establish a connection before timing out, in seconds. + # (default: 5) + # connect_timeout: 5 + + # The timeout to wait to execute operations on a socket before raising an error. + # (default: 5) + # socket_timeout: 5 + + # The name of the replica set to connect to. Servers provided as seeds that do + # not belong to this replica set will be ignored. + # replica_set: name + + # Whether to connect to the servers via ssl. (default: false) + # ssl: true + + # The certificate file used to identify the connection against MongoDB. + # ssl_cert: /path/to/my.cert + + # The private keyfile used to identify the connection against MongoDB. + # Note that even if the key is stored in the same file as the certificate, + # both need to be explicitly specified. + # ssl_key: /path/to/my.key + + # A passphrase for the private key. + # ssl_key_pass_phrase: password + + # Whether or not to do peer certification validation. (default: true) + # ssl_verify: true + + # The file containing a set of concatenated certification authority certifications + # used to validate certs passed from the other end of the connection. + # ssl_ca_cert: /path/to/ca.cert # Configure Mongoid specific options. (optional) @@ -71,9 +112,6 @@ development: # inheritance. (default: false) # preload_models: false - # Protect id and type from mass assignment. (default: true) - # protect_sensitive_fields: true - # Raise an error when performing a #find and the document is not found. # (default: true) # raise_not_found_error: true @@ -87,15 +125,22 @@ development: # Ensure all times are UTC in the app side. (default: false) # use_utc: false + + # Set the Mongoid and Ruby driver log levels when not in a Rails + # environment. The Mongoid logger will be set to the Rails logger + # otherwise.(default: :info) + # log_level: :info + + # Application name that is printed to the mongodb logs upon establishing a + # connection in server versions >= 3.4. Note that the name cannot exceed 128 bytes. + # app_name: MyApplicationName test: - sessions: + clients: default: database: dummy_test hosts: - - localhost:27017 + - <%= ENV.fetch('MONGO_HOST', 'localhost') %>:<%= ENV.fetch('MONGO_PORT', '27017') %> options: - read: primary - # In the test environment we lower the retries and retry interval to - # low amounts for fast failures. - max_retries: 1 - retry_interval: 0 + read: + mode: :primary + max_pool_size: 1 From 1315a6879ae0e9e6a9b5dfe88a38fd9390968bf3 Mon Sep 17 00:00:00 2001 From: Fabio Napoleoni Date: Tue, 3 Oct 2017 11:03:26 +0200 Subject: [PATCH 28/29] Travis configuration with encrypted credentials and run all features --- .travis.yml | 10 +++++----- Gemfile | 1 + Rakefile | 12 +++--------- cloudinary.yml.enc | 3 +++ spec/support/cloudinary-sample-credentials.yml | 7 ------- 5 files changed, 12 insertions(+), 21 deletions(-) create mode 100644 cloudinary.yml.enc delete mode 100644 spec/support/cloudinary-sample-credentials.yml diff --git a/.travis.yml b/.travis.yml index 5c869c16..05c9c8c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: ruby rvm: - - 2.3.1 + - 2.3.3 # Cache bundler dependencies cache: bundler # For testing mongoid integration @@ -24,10 +24,10 @@ before_install: - rm ~/chromedriver_linux64.zip - sudo mv -f ~/chromedriver /usr/local/bin - sudo chmod +x /usr/local/bin/chromedriver -# Copy sample credentials to expected path +# Decrypt cloudinary credentials before_script: - - cp spec/support/cloudinary-sample-credentials.yml spec/dummy/config/cloudinary.yml + - openssl aes-256-cbc -K $encrypted_b867c800090e_key -iv $encrypted_b867c800090e_iv + -in cloudinary.yml.enc -out spec/dummy/config/cloudinary.yml -d - bundle exec rake db:setup # Run RSpec -script: - bundle exec rake +script: bundle exec rake diff --git a/Gemfile b/Gemfile index a5cdad2d..26774a31 100644 --- a/Gemfile +++ b/Gemfile @@ -38,6 +38,7 @@ group :development, :test do gem 'database_cleaner' gem 'vcr' gem 'webmock' + gem 'travis' end diff --git a/Rakefile b/Rakefile index 9e2de802..660498d1 100644 --- a/Rakefile +++ b/Rakefile @@ -28,14 +28,8 @@ load 'rails/tasks/engine.rake' Bundler::GemHelper.install_tasks # Configure rspec rake task -begin - require 'rspec/core/rake_task' - RSpec::Core::RakeTask.new(:spec) do |t| - t.rspec_opts = '--tag ~js' - end -rescue LoadError - # no rspec available -end +require 'rspec/core/rake_task' +RSpec::Core::RakeTask.new(:spec) # Configure default task -task :default => :spec \ No newline at end of file +task default: :spec diff --git a/cloudinary.yml.enc b/cloudinary.yml.enc new file mode 100644 index 00000000..116de3a5 --- /dev/null +++ b/cloudinary.yml.enc @@ -0,0 +1,3 @@ +={Ոغ3Uz, 2 SS㑧fwy[WR\ppbE1rY(:qV|iLEzK1O|8 + 6lCnU=H*iix7BMB'Cla3Y/9lYAI'%T&˶\/04wq抙 +[_X2.EU@nm"ypBN:]sR$'\3TDžth)jQ݂zE]r[oN,K PiBsazb\ZvݻOC1@nĹ7T2/fWM_E}Э@&=z?&f5ݧWKGʀΖ _d[K俆b0+ b7KYN{39REKYRj<_x \ No newline at end of file diff --git a/spec/support/cloudinary-sample-credentials.yml b/spec/support/cloudinary-sample-credentials.yml deleted file mode 100644 index 1952110b..00000000 --- a/spec/support/cloudinary-sample-credentials.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -test: - cloud_name: somename - api_key: '1234567890' - api_secret: FooBarBaz123 - enhance_image_tag: true - static_image_support: false From f64ff8048838640ce283961f39d2a32355ab638e Mon Sep 17 00:00:00 2001 From: Fabio Napoleoni Date: Tue, 3 Oct 2017 10:53:20 +0200 Subject: [PATCH 29/29] Cleanup after specs --- .travis.yml | 2 ++ Rakefile | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/.travis.yml b/.travis.yml index 05c9c8c1..e58b543e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,3 +31,5 @@ before_script: - bundle exec rake db:setup # Run RSpec script: bundle exec rake +# Cleanup cloudinary +after_script: bundle exec rake cleanup diff --git a/Rakefile b/Rakefile index 660498d1..1c0a886a 100644 --- a/Rakefile +++ b/Rakefile @@ -33,3 +33,14 @@ RSpec::Core::RakeTask.new(:spec) # Configure default task task default: :spec + +# Remove cloudinary files created during spec executions +task cleanup: :environment do + begin + print "Cleaning up created resources in cloud #{Cloudinary.config.cloud_name}..." + Cloudinary::Api.delete_resources_by_tag('test_env') + print ' (done)' + rescue Cloudinary::Api::RateLimited => e + print " (#{e.message})" + end +end