Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actually get dummy test app running properly and passing feature tests #407

Merged
merged 5 commits into from
Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
version: 2.1
orbs:
samvera: samvera/circleci-orb@1.0
browser-tools: circleci/browser-tools@1.1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


jobs:
build:
Expand All @@ -19,6 +20,8 @@ jobs:
environment:
RAILS_VERSION: << parameters.rails_version >>
steps:
- browser-tools/install-chrome
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


- samvera/cached_checkout

- run:
Expand Down
6 changes: 6 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ AllCops:
- 'spec/dummy_test_app/**/*'
- 'bin/rails'

Style/GuardClause:
Enabled: false

StyleI/IfUnlessModifier:
Enabled: false

Bundler/DuplicatedGem:
Exclude:
- 'Gemfile'
Expand Down
12 changes: 8 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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...

Expand Down Expand Up @@ -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'
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions browse-everything.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,28 @@ 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'
spec.add_development_dependency 'rspec-its'
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
17 changes: 15 additions & 2 deletions lib/browse_everything/driver/file_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ def icon

def validate_config
raise BrowseEverything::InitializationError, 'FileSystem driver requires a :home argument' if config[:home].blank?

unless config[:home].start_with?("/") || config[:allow_relative_home] == true
raise BrowseEverything::InitializationError, 'FileSystem driver :home argument must be absolute unless :allow_relative_home is set'
end
end

# Retrieve the contents of a directory
# @param path [String] the path to a file system resource
# @return [Array<BrowseEverything::FileEntry>]
def contents(path = '')
real_path = File.join(config[:home], path)
real_path = File.join(home_path, path)
values = if File.directory?(real_path)
make_directory_entry real_path
else
Expand Down Expand Up @@ -55,6 +59,15 @@ def details(path, display = File.basename(path))

private

def home_path
@home_path ||= if config[:allow_relative_home] == true
# expand relative to Rails.root, mainly test CI use-case
File.expand_path(config[:home], Rails.root)
else
config[:home]
end
end

# Construct an array of FileEntry objects for the contents of a
# directory
# @param real_path [String] path to the file system directory
Expand All @@ -65,7 +78,7 @@ def make_directory_entry(real_path)
end

def make_pathname(path)
Pathname.new(File.expand_path(path)).relative_path_from(Pathname.new(config[:home]))
Pathname.new(File.expand_path(path)).relative_path_from(Pathname.new(home_path))
end

def file_size(path)
Expand Down
5 changes: 2 additions & 3 deletions spec/dummy_test_app/app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

//= link_tree ../images
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css
//= link application.css
//= link application.js
12 changes: 12 additions & 0 deletions spec/dummy_test_app/app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
*= require_tree .
*= require_self
*/

@import "bootstrap";
@import "browse_everything/browse_everything_bootstrap4";
8 changes: 8 additions & 0 deletions spec/dummy_test_app/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.~
Expand Down
3 changes: 2 additions & 1 deletion spec/dummy_test_app/config/browse_everything_providers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# The file_system provider can be a path to any directory on the server where your application is running.
#
file_system:
home: /Users/jrochkind/code/browse-everything/.internal_test_app
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sorry for missing this line within a previous pull request review.

allow_relative_home: true
home: ./
# dropbox:
# client_id: YOUR_DROPBOX_APP_KEY
# client_secret: YOUR_DROPBOX_APP_SECRET
Expand Down
5 changes: 5 additions & 0 deletions spec/dummy_test_app/config/routes.rb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion spec/features/select_files_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

click_button('Browse')
wait_for_ajax

Expand Down
2 changes: 1 addition & 1 deletion spec/features/test_compiling_stylesheets_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

visit '/'
expect(page).not_to have_content 'Sass::SyntaxError'
end
Expand Down