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

Bring tests from jupiter into oaisys with required changes/additions #58

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 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
15 changes: 15 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ jobs:
- 5432:5432
env:
POSTGRES_PASSWORD: mysecretpassword
redis:
image: redis:alpine
ports:
- 6379/tcp
volumes:
- redis:/data

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -40,13 +46,22 @@ jobs:
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Setup redis
Copy link
Member

Choose a reason for hiding this comment

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

What is redis required for?

uses: supercharge/[email protected]
with:
redis-version: 4

- uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-





- name: Run Tests
env:
RAILS_ENV: test
Expand Down
18 changes: 17 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ AllCops:
DisplayStyleGuide: true
Exclude:
- 'db/**/*'
- 'test/dummy/db/**/*'
- 'tmp/**/*'
- 'vendor/**/*'
ExtraDetails: true
TargetRubyVersion: 2.5
TargetRubyVersion: 2.6.6

# readability is Actually Good
Layout/EmptyLinesAroundClassBody:
Expand Down Expand Up @@ -63,6 +64,9 @@ Metrics/PerceivedComplexity:

Metrics/ParameterLists:
Max: 6 # default 5
Exclude:
- test/dummy/app/models/jupiter_core/search.rb
- test/dummy/app/models/jupiter_core/solr_services/deferred_faceted_solr_query.rb

Naming/FileName:
Exclude:
Expand Down Expand Up @@ -133,3 +137,15 @@ Style/WordArray:

Performance/TimesMap:
Enabled: false

Naming/MethodParameterName:
Exclude:
- test/dummy/app/models/jupiter_core//solr_services/deferred_faceted_solr_query.rb
- test/dummy/app/models/jupiter_core/search.rb

Naming/MemoizedInstanceVariableName:
Exclude:
- test/dummy/app/models/jupiter_core//solr_services/deferred_faceted_solr_query.rb

Naming/VariableNumber:
Enabled: false
15 changes: 15 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,18 @@ gemspec
# RDF stuff
gem 'acts_as_rdfable', github: 'ualbertalib/acts_as_rdfable', tag: 'v0.2.4'
gem 'builder_deferred_tagging', github: 'ualbertalib/builder_deferred_tagging', tag: 'v0.01'

group :development, :test do
gem 'aasm' # state-machine management
gem 'paper_trail' # Track object changes
Comment on lines +22 to +23
Copy link
Member

Choose a reason for hiding this comment

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

Are these necessary for oaisys?

gem 'rdf', '~> 3.1.15'
gem 'redis', '~> 4.1'
gem 'rubocop', '~> 1.22.1', require: false
end

group :test do
gem 'bcrypt', '>= 3.1.13'
gem 'kaminari' # Pagination
gem 'rdf-n3', '~> 3.1.2'
gem 'rdf-vocab', '~> 3.1.14'
end
105 changes: 93 additions & 12 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ PATH
GEM
remote: https://rubygems.org/
specs:
aasm (5.2.0)
concurrent-ruby (~> 1.0)
actioncable (6.0.3.3)
actionpack (= 6.0.3.3)
nio4r (~> 2.0)
Expand Down Expand Up @@ -86,17 +88,43 @@ GEM
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2, >= 2.2.2)
ast (2.4.0)
amazing_print (1.4.0)
ast (2.4.2)
bcrypt (3.1.16)
builder (3.2.4)
coderay (1.1.2)
concurrent-ruby (1.1.7)
connection_pool (2.2.5)
crass (1.0.6)
ebnf (2.2.1)
amazing_print (~> 1.2)
htmlentities (~> 4.3)
rdf (~> 3.1)
scanf (~> 1.0)
sxp (~> 1.1)
unicode-types (~> 1.6)
erubi (1.9.0)
globalid (0.4.2)
activesupport (>= 4.2.0)
hamster (3.0.0)
concurrent-ruby (~> 1.0)
htmlentities (4.3.4)
i18n (1.8.5)
concurrent-ruby (~> 1.0)
jaro_winkler (1.5.4)
kaminari (1.2.1)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.2.1)
kaminari-activerecord (= 1.2.1)
kaminari-core (= 1.2.1)
kaminari-actionview (1.2.1)
actionview
kaminari-core (= 1.2.1)
kaminari-activerecord (1.2.1)
activerecord
kaminari-core (= 1.2.1)
kaminari-core (1.2.1)
link_header (0.0.8)
logger (1.4.4)
loofah (2.7.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
Expand All @@ -105,17 +133,24 @@ GEM
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (0.9.2)
mimemagic (0.3.5)
mimemagic (0.3.10)
nokogiri (~> 1)
rake
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.14.2)
nanoid (2.0.0)
net-http-persistent (4.0.1)
connection_pool (~> 2.2)
nio4r (2.5.3)
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
parallel (1.19.1)
parser (2.7.0.2)
ast (~> 2.4.0)
paper_trail (12.1.0)
activerecord (>= 5.2)
request_store (~> 1.1)
parallel (1.21.0)
parser (3.0.2.0)
ast (~> 2.4.1)
pg (1.2.2)
pry (0.12.2)
coderay (~> 1.1.0)
Expand Down Expand Up @@ -151,34 +186,71 @@ GEM
thor (>= 0.20.3, < 2.0)
rainbow (3.0.0)
rake (13.0.1)
rdf (3.1.15)
hamster (~> 3.0)
link_header (~> 0.0, >= 0.0.8)
rdf-aggregate-repo (3.1.0)
rdf (~> 3.1)
rdf-n3 (3.1.2)
ebnf (~> 2.1)
rdf (~> 3.1, >= 3.1.8)
sparql (~> 3.1, >= 3.1.4)
sxp (~> 1.1)
rdf-vocab (3.1.14)
rdf (~> 3.1, >= 3.1.12)
rdf-xsd (3.1.1)
rdf (~> 3.1)
rexml (~> 3.2)
redis (4.1.3)
regexp_parser (2.1.1)
request_store (1.4.1)
rack (>= 1.4)
rubocop (0.79.0)
jaro_winkler (~> 1.5.1)
rexml (3.2.5)
rubocop (1.22.2)
parallel (~> 1.10)
parser (>= 2.7.0.1)
parser (>= 3.0.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.12.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.12.0)
parser (>= 3.0.1.1)
rubocop-performance (1.5.2)
rubocop (>= 0.71.0)
rubocop-rails (2.4.1)
rack (>= 1.1)
rubocop (>= 0.72.0)
ruby-progressbar (1.10.1)
ruby-progressbar (1.11.0)
scanf (1.0.0)
sparql (3.1.8)
builder (~> 3.2)
ebnf (~> 2.1)
logger (~> 1.4)
rdf (~> 3.1, >= 3.1.14)
rdf-aggregate-repo (~> 3.1)
rdf-xsd (~> 3.1)
sparql-client (~> 3.1, >= 3.1.2)
sxp (~> 1.1)
sparql-client (3.1.2)
net-http-persistent (~> 4.0, >= 4.0.1)
rdf (~> 3.1)
sprockets (4.0.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sxp (1.1.0)
rdf (~> 3.1)
thor (1.0.1)
thread_safe (0.3.6)
tzinfo (1.2.7)
thread_safe (~> 0.1)
unicode-display_width (1.6.1)
unicode-display_width (2.1.0)
unicode-types (1.7.0)
websocket-driver (0.7.3)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
Expand All @@ -188,10 +260,19 @@ PLATFORMS
ruby

DEPENDENCIES
aasm
acts_as_rdfable!
bcrypt (>= 3.1.13)
builder_deferred_tagging!
kaminari
oaisys!
paper_trail
pry
rdf (~> 3.1.15)
rdf-n3 (~> 3.1.2)
rdf-vocab (~> 3.1.14)
redis (~> 4.1)
rubocop (~> 1.22.1)

BUNDLED WITH
2.1.4
6 changes: 3 additions & 3 deletions app/controllers/oaisys/pmh_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Oaisys::PMHController < Oaisys::ApplicationController
].freeze

def bad_verb
bad_verb = params.permit(:verb).to_h[:verb]
bad_verb = params.permit(:verb, :subdomain).to_h[:verb]
Copy link
Member

Choose a reason for hiding this comment

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

Is this a bug in the current release?

raise Oaisys::BadVerbError.new(bad_verb: bad_verb)
end

Expand All @@ -40,8 +40,8 @@ def list_sets

sets.map! do |top_level_sets_id, id, title, description|
top_level_set = top_level_sets.find { |a| a[0] == top_level_sets_id }[1]
full_set_id = top_level_sets_id + ':' + id
full_set_name = top_level_set + ' / ' + title
full_set_id = "#{top_level_sets_id}:#{id}"
full_set_name = "#{top_level_set} / #{title}"
[full_set_id, full_set_name, description]
end
resumption_token = resumption_token_from_params(parameters: parameters)
Expand Down
2 changes: 1 addition & 1 deletion app/views/oaisys/pmh/list_identifiers.xml.builder
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ xml.tag!('request', parameters, 'https://era.library.ualberta.ca/oai')
xml.ListIdentifiers do
identifiers.each do |identifier, date, sets|
xml.tag!('header') do
xml.identifier 'oai:era.library.ualberta.ca:' + identifier
xml.identifier "oai:era.library.ualberta.ca:#{identifier}"
xml.datestamp date.utc.xmlschema
sets.each do |set|
xml.setSpec set.tr('/', ':')
Expand Down
1 change: 1 addition & 0 deletions lib/oaisys/bad_argument_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class Oaisys::BadArgumentError < Oaisys::PMHError
attr_reader :parameters

def initialize(parameters:)
super
@parameters = parameters
end

Expand Down
1 change: 1 addition & 0 deletions lib/oaisys/bad_resumption_token_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class Oaisys::BadResumptionTokenError < Oaisys::PMHError
attr_reader :parameters

def initialize
super
@parameters = {}
end

Expand Down
1 change: 1 addition & 0 deletions lib/oaisys/bad_verb_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Oaisys::BadVerbError < Oaisys::PMHError

# Pass nil for bad_verb if verb parameter wasn't given.
def initialize(bad_verb:)
super
@parameters = {}
@bad_verb = bad_verb
end
Expand Down
1 change: 1 addition & 0 deletions lib/oaisys/cannot_disseminate_format_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class Oaisys::CannotDisseminateError < Oaisys::PMHError
attr_reader :parameters

def initialize(parameters:)
super
@parameters = parameters
end

Expand Down
1 change: 1 addition & 0 deletions lib/oaisys/id_does_not_exist_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class Oaisys::IdDoesNotExistError < Oaisys::PMHError
attr_reader :parameters

def initialize(parameters:)
super
@parameters = parameters
end

Expand Down
1 change: 1 addition & 0 deletions lib/oaisys/no_metadata_formats_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class Oaisys::NoMetadataFormatsError < Oaisys::PMHError
attr_reader :parameters

def initialize(parameters:)
super
@parameters = parameters
end

Expand Down
1 change: 1 addition & 0 deletions lib/oaisys/no_records_match_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class Oaisys::NoRecordsMatchError < Oaisys::PMHError
attr_reader :parameters

def initialize(parameters:)
super
@parameters = parameters
end

Expand Down
1 change: 1 addition & 0 deletions oaisys.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Gem::Specification.new do |spec|
spec.summary = 'OAI-PMH engine'
spec.description = "Jupiter's engine for Open Archives Initiative Protocol for Metadata Harvesting"
spec.license = 'MIT'
spec.required_ruby_version = '2.6.6'
Copy link
Member

Choose a reason for hiding this comment

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


# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
# to allow pushing to a single host or delete this section to allow pushing to any host.
Expand Down
11 changes: 11 additions & 0 deletions test/dummy/app/models/announcement.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Announcement < ApplicationRecord

belongs_to :user

validates :user, presence: true
validates :message, presence: true, length: { maximum: 500 }

scope :current, -> { where(removed_at: nil).order(created_at: :desc) }
scope :past, -> { where.not(removed_at: nil).order(removed_at: :desc) }

end
Loading