diff --git a/Gemfile b/Gemfile index d22621df..70a83485 100644 --- a/Gemfile +++ b/Gemfile @@ -9,12 +9,17 @@ group :development, :test do gem 'pry-byebug' unless ENV['CI'] end -# We allow testing under multiple versions of Rails by setting ENV RAILS_VERSION, -# used in CI, can be used locally too. Make sure to delete your Gemfile.lock after -# changing a local RAILS_VERSION +# == Extra dependencies for dummy test app == +# +# Extra dependencies for dummy test app are in .gemspec as a development dependency +# where possible. But when dependencies vary for different versions +# of Rails, rails-version-specific dependencies are here, behind conditionals, for now. # # TODO switch to use appraisal gem instead, encapsulating these different additional # dependencies per Rails version, as well as method of choosing operative rails version. +# +# We allow testing under multiple versions of Rails by setting ENV RAILS_VERSION, +# used in CI, can be used locally too. # Set a default RAILS_VERSION so we make sure to get extra dependencies for it... @@ -44,7 +49,6 @@ if ENV['RAILS_VERSION'] gem "mail", ">= 2.8.0.rc1" when /^6\.0\./ gem 'sass-rails', '>= 6' - gem 'webpacker', '~> 4.0' when /^5\.[12]\./ gem 'sass-rails', '~> 5.0' gem 'sprockets', '~> 3.7' diff --git a/README.md b/README.md index 62a44421..ba76745e 100644 --- a/README.md +++ b/README.md @@ -284,9 +284,7 @@ Or individually, `bundle exec rubocop`, `bundle exec rspec`. You can test with different versions of rails by setting ENV variable `RAILS_VERSION` to a specific version like `"6.1.2"` or `"7.0.0"`, perhaps by `export RAILS_ENV=7.0.0` to set it in your shell session. -Tests by default will be run with bootstrap-4 integration. You can test with bootstrap-3 by setting ENV varaible `TEST_BOOTSTRAP=3`. - -After changing `RAILS_VERSION` or `TEST_BOOTSTRAP` you may have to run `rm Gemfile.lock` and `bundle install` again. If you get a `Bundler could not find compatible versions...` error, for instance. +After changing `RAILS_VERSION` you may have to run `rm Gemfile.lock` and `bundle install` again. If you get a `Bundler could not find compatible versions...` error, for instance. # Help diff --git a/browse-everything.gemspec b/browse-everything.gemspec index 19d3a220..b6250ddd 100644 --- a/browse-everything.gemspec +++ b/browse-everything.gemspec @@ -29,11 +29,17 @@ Gem::Specification.new do |spec| spec.add_dependency 'signet', '~> 0.8' spec.add_dependency 'typhoeus' + # Development dependencies include dependencies necessary for running + # the dummy test app at ./spec/dummy_test_app + spec.add_development_dependency 'bixby', '~> 5.0' + spec.add_development_dependency 'bootstrap', "~> 4.0" # we do not support bootstrap 5 spec.add_development_dependency 'bundler', '>= 1.3' spec.add_development_dependency 'capybara' spec.add_development_dependency 'factory_bot_rails' + spec.add_development_dependency 'jquery-rails' spec.add_development_dependency 'pry-byebug' + spec.add_development_dependency 'puma' spec.add_development_dependency 'rails-controller-testing' spec.add_development_dependency 'rake' spec.add_development_dependency 'rspec', '~> 3.0' @@ -41,8 +47,10 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rspec-rails' spec.add_development_dependency 'rspec_junit_formatter' spec.add_development_dependency 'rubocop-rspec' + spec.add_development_dependency 'sass-rails' spec.add_development_dependency 'selenium-webdriver' spec.add_development_dependency 'sqlite3' + spec.add_development_dependency 'turbolinks' spec.add_development_dependency 'webdrivers' spec.add_development_dependency 'webmock' end diff --git a/spec/dummy_test_app/app/assets/config/manifest.js b/spec/dummy_test_app/app/assets/config/manifest.js index c8e290cd..1983ee4e 100644 --- a/spec/dummy_test_app/app/assets/config/manifest.js +++ b/spec/dummy_test_app/app/assets/config/manifest.js @@ -1,4 +1,3 @@ - //= link_tree ../images -//= link_directory ../javascripts .js -//= link_directory ../stylesheets .css +//= link application.css +//= link application.js diff --git a/spec/dummy_test_app/app/assets/javascripts/application.js b/spec/dummy_test_app/app/assets/javascripts/application.js index e54c6461..650abb23 100644 --- a/spec/dummy_test_app/app/assets/javascripts/application.js +++ b/spec/dummy_test_app/app/assets/javascripts/application.js @@ -10,4 +10,16 @@ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details // about supported directives. // + +// We want to test with turbolinks, which our code also requires rails-ujs to deal with: + +//= require rails-ujs +//= require turbolinks + +// Actual stack required for current browse-everything JS + +//= require jquery3 +//= require bootstrap +//= require browse_everything + //= require_tree . diff --git a/spec/dummy_test_app/app/assets/stylesheets/application.css b/spec/dummy_test_app/app/assets/stylesheets/application.scss similarity index 90% rename from spec/dummy_test_app/app/assets/stylesheets/application.css rename to spec/dummy_test_app/app/assets/stylesheets/application.scss index 0ebd7fe8..59543e08 100644 --- a/spec/dummy_test_app/app/assets/stylesheets/application.css +++ b/spec/dummy_test_app/app/assets/stylesheets/application.scss @@ -13,3 +13,6 @@ *= require_tree . *= require_self */ + +@import "bootstrap"; +@import "browse_everything/browse_everything_bootstrap4"; diff --git a/spec/dummy_test_app/app/controllers/file_handler_controller.rb b/spec/dummy_test_app/app/controllers/file_handler_controller.rb new file mode 100644 index 00000000..0000269e --- /dev/null +++ b/spec/dummy_test_app/app/controllers/file_handler_controller.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class FileHandlerController < ApplicationController + def index; end + + def main; end + + def update + render json: params[:selected_files].to_json + end +end diff --git a/spec/dummy_test_app/app/views/file_handler/index.html.erb b/spec/dummy_test_app/app/views/file_handler/index.html.erb new file mode 100644 index 00000000..7ae1c43a --- /dev/null +++ b/spec/dummy_test_app/app/views/file_handler/index.html.erb @@ -0,0 +1,10 @@ +
+
+ Enter Test App (Turbolinks) + + <%# this doesn't REALLY test no Turbolinks, as there will still be a `window.Turbolinks` object, + and a `turbolinks:load` event. It just tests as if the page we are navigating to were the FIRST + page loaded under turbolinks %> + Enter Test App (No Turbolinks) +
+
diff --git a/spec/dummy_test_app/app/views/file_handler/main.html.erb b/spec/dummy_test_app/app/views/file_handler/main.html.erb new file mode 100644 index 00000000..9478bc53 --- /dev/null +++ b/spec/dummy_test_app/app/views/file_handler/main.html.erb @@ -0,0 +1,25 @@ +
+

Welcome!

+ +

Please click the button below to start pickin' files!

+ + <%= form_tag('/file', id: 'main_form', method: 'post') do %> + <%= button_tag("Browse", type: 'button', class: 'btn btn-large btn-success', id: "browse-btn", + 'data-toggle' => 'browse-everything', 'data-route' => browse_everything_engine.root_path, + 'data-target' => '#main_form') %> + <%= button_tag("Submit", type: 'submit', class: 'btn btn-large btn-primary', id: "submit-btn") %> + <% end %> + +

0 items selected

+ + +
diff --git a/spec/dummy_test_app/config/application.rb b/spec/dummy_test_app/config/application.rb index 7c35c770..ab8e2442 100644 --- a/spec/dummy_test_app/config/application.rb +++ b/spec/dummy_test_app/config/application.rb @@ -5,6 +5,14 @@ Bundler.require(*Rails.groups) require "browse_everything" +# Since we don't actually have an app-specific Gemfile, +# Some development dependencies listed in .gemspec need to be required here, +# that would ordinarily be auto-required by being in a Gemfile instead of gemspec. +require 'bootstrap' +require 'sprockets/railtie' +require 'jquery-rails' +require 'turbolinks' + module Dummy class Application < Rails::Application # ~Initialize configuration defaults for originally generated Rails version.~ diff --git a/spec/dummy_test_app/config/routes.rb b/spec/dummy_test_app/config/routes.rb index fe2d33b8..7a9bc627 100644 --- a/spec/dummy_test_app/config/routes.rb +++ b/spec/dummy_test_app/config/routes.rb @@ -1,4 +1,9 @@ Rails.application.routes.draw do # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html mount BrowseEverything::Engine => '/browse' + + # Custom actions we use for feature testing + root :to => "file_handler#index" + get '/main', :to => "file_handler#main" + post '/file', :to => "file_handler#update" end diff --git a/spec/features/select_files_spec.rb b/spec/features/select_files_spec.rb index 4ae171a0..8a29f365 100644 --- a/spec/features/select_files_spec.rb +++ b/spec/features/select_files_spec.rb @@ -7,7 +7,7 @@ shared_examples 'browseable files' do # This is a work-around until the support for Webpacker is resolved - xit 'selects files from the filesystem' do + it 'selects files from the filesystem' do click_button('Browse') wait_for_ajax diff --git a/spec/features/test_compiling_stylesheets_spec.rb b/spec/features/test_compiling_stylesheets_spec.rb index 1cbf3ca9..200b71fc 100644 --- a/spec/features/test_compiling_stylesheets_spec.rb +++ b/spec/features/test_compiling_stylesheets_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true describe 'Compiling the stylesheets', type: :feature, js: true do - xit 'does not raise errors' do + it 'does not raise errors' do visit '/' expect(page).not_to have_content 'Sass::SyntaxError' end