Skip to content

Commit

Permalink
Fixing rubocop errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jonibar committed Aug 3, 2018
1 parent f133dd3 commit 546af86
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ Style/IfUnlessModifier:
- 'etda_utilities-0.3.0/lib/etda_utilities/partner.rb'
- 'lib/etda_utilities/partner.rb'

Style/MissingRespondToMissing:
# Offense count: 2
Style/MethodMissing:
Exclude:
- 'etda_utilities-0.3.0/lib/etda_utilities/access_level.rb'
- 'lib/etda_utilities/access_level.rb'
Expand Down
2 changes: 1 addition & 1 deletion etda_utilities.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

lib = File.expand_path("../lib", __FILE__)
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "etda_utilities/version"

Expand Down
4 changes: 4 additions & 0 deletions spec/lib/etda_utilities_access_level_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
expect(described_class::ACCESS_LEVEL_KEYS).to match_array(['open_access', 'restricted_to_institution', 'restricted', ''])
end
end

context '#paper_access_level_keys' do
it '#paper_access_level_keys returns an array of access_levels' do
expect(described_class::ACCESS_LEVEL_KEYS).to match_array(described_class.paper_access_level_keys)
end
end

context '#partner_access_level' do
it 'returns access level information from a yml file' do
yml_level = described_class.partner_access_levels['access_level']
Expand All @@ -26,13 +28,15 @@
expect(described_class.valid_levels).to match_array(described_class.paper_access_level_keys)
end
end

context 'given an invalid level' do
it 'returns nil values' do
bad_level = described_class.new('bogusvalue')
expect(bad_level.attributes).to be_nil
expect(bad_level.current_access_level).to eq('')
end
end

context 'given valid levels' do
it 'returns current_access_level and attribute' do
open_access = described_class.new('open_access')
Expand Down
5 changes: 5 additions & 0 deletions spec/lib/etda_utilities_etda_file_paths_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
expect(described_class.new.explore_base_path).to eql('tmp/')
end
end

context 'workflow uploads' do
it 'returns final-files path' do
expect(subject.workflow_upload_final_files_path).to eql('tmp/final_submission_files/')
Expand All @@ -18,11 +19,13 @@
expect(subject.workflow_upload_format_review_path).to eql('tmp/format_review_files/')
end
end

context '#workflow_restricted' do
it 'returns path of published restricted files' do
expect(subject.workflow_restricted).to eql('tmp/restricted/')
end
end

context 'explore published paths' do
it 'returns path of restricted to institution files' do
expect(subject.explore_psu_only).to eql('tmp/restricted_institution/')
Expand All @@ -31,6 +34,7 @@
expect(subject.explore_open).to eql('tmp/open_access/')
end
end

context '#detailed_file_path' do
it 'uses database record id to build the file path' do
id = 2
Expand All @@ -45,6 +49,7 @@
expect(subject.detailed_file_path(id)).to eq('57/19857/')
end
end

context '#explore_download_file_path' do
file_id = 345
filename = 'myfile.pdf'
Expand Down
9 changes: 9 additions & 0 deletions spec/lib/etda_utilities_partner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
before do
partner_set_env('graduate')
end

it 'sets current.id to graduate' do
expect(described_class.current.id).to eql('graduate')
expect(described_class.current.id).not_to eql('honors')
Expand All @@ -17,10 +18,12 @@
expect(described_class.current).not_to be_milsch
end
end

context "when ENV['PARTNER'] is honors" do
before do
partner_set_env('honors')
end

it 'sets current.id to honors' do
expect(described_class.current.id).to eql('honors')
expect(described_class.current.id).not_to eql('graduate')
Expand All @@ -32,10 +35,12 @@
expect(described_class.current).not_to be_milsch
end
end

context "when ENV['PARTNER'] is milsch" do
before do
partner_set_env('milsch')
end

it 'sets current.id to milsch' do
expect(described_class.current.id).to eql('milsch')
expect(described_class.current.id).not_to eql('graduate')
Expand All @@ -47,18 +52,22 @@
expect(described_class.current).not_to be_honors
end
end

context "when ENV['PARTNER'] is not a valid partner" do
before do
partner_set_env('boguspartner')
end

it 'reports an error' do
expect { described_class.current.id }.to raise_error(ArgumentError)
end
end

context "when ENV['PARTNER'] is not set" do
before do
ENV.delete('PARTNER')
end

it 'defaults to graduate' do
expect(described_class.current.id).to eql('graduate')
end
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)

require "bundler/setup"
require "etda_utilities"
Expand Down

0 comments on commit 546af86

Please sign in to comment.