Skip to content

Commit

Permalink
Test on latest ruby and rails versions (#147)
Browse files Browse the repository at this point in the history
* Test on latest ruby and rails versions

* Use circleci convenience images matching samvera orb

* Drop ruby 2.4 and jruby from test matrix

* Fix tests for ruby 3.x
  • Loading branch information
cjcolvar authored Jan 25, 2023
1 parent debba92 commit 1bac22d
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 115 deletions.
203 changes: 103 additions & 100 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
rails_version:
type: string
docker:
- image: circleci/<< parameters.ruby_type >>:<< parameters.ruby_version >>-node-browsers-legacy
- image: cimg/<< parameters.ruby_type >>:<< parameters.ruby_version >>-browsers
- image: samveralabs/fcrepo3:latest
environment:
BUNDLE_PATH: vendor/bundle
Expand Down Expand Up @@ -56,85 +56,87 @@ workflows:
version: 2
ci:
jobs:
# Rails 7.0
- test:
name: "ruby3-2_rails7-0"
ruby_version: 3.2.0
rails_version: 7.0.4.1
- test:
name: "ruby3-1_rails7-0"
ruby_version: 3.1.3
rails_version: 7.0.4.1
- test:
name: "ruby3-0_rails7-0"
ruby_version: 3.0.5
rails_version: 7.0.4.1
# Rails 6.1
- test:
name: "ruby3-2_rails6-1"
ruby_version: 3.2.0
rails_version: 6.1.7.1
- test:
name: "ruby3-1_rails6-1"
ruby_version: 3.1.3
rails_version: 6.1.7.1
- test:
name: "ruby3-0_rails6-1"
ruby_version: 3.0.5
rails_version: 6.1.7.1
- test:
name: "ruby2-7_rails6-1"
ruby_version: 2.7.5
bundler_version: 2.0.2
rails_version: 6.1.6.1
ruby_version: 2.7.7
rails_version: 6.1.7.1
# Rails 6.0
- test:
name: "ruby3-2_rails6-0"
ruby_version: 3.2.0
rails_version: 6.0.6.1
- test:
name: "ruby3-1_rails6-1"
ruby_version: 3.1.3
rails_version: 6.0.6.1
- test:
name: "ruby3-0_rails6-1"
ruby_version: 3.0.5
rails_version: 6.0.6.1
- test:
name: "ruby2-7_rails6-0"
ruby_version: 2.7.5
bundler_version: 2.0.2
rails_version: 6.0.2
ruby_version: 2.7.7
rails_version: 6.0.6.1
- test:
name: "ruby2-6_rails6-0"
ruby_version: 2.6.9
bundler_version: 2.0.2
rails_version: 6.0.2
ruby_version: 2.6.10
rails_version: 6.0.6.1
- test:
name: "ruby2-5_rails6-0"
ruby_version: 2.5.9
bundler_version: 2.0.2
rails_version: 6.0.2
- test:
name: "jruby9-2_rails6-0"
ruby_type: "jruby"
ruby_version: 9.2.0.0
bundler_version: 2.0.2
rails_version: 6.0.2

rails_version: 6.0.6.1
# Rails 5.2
- test:
name: "ruby2-7_rails5-2"
ruby_version: 2.7.5
bundler_version: 2.0.2
rails_version: 5.2.4
ruby_version: 2.7.7
rails_version: 5.2.8.1
- test:
name: "ruby2-6_rails5-2"
ruby_version: 2.6.9
bundler_version: 2.0.2
rails_version: 5.2.4
ruby_version: 2.6.10
rails_version: 5.2.8.1
- test:
name: "ruby2-5_rails5-2"
ruby_version: 2.5.9
bundler_version: 2.0.2
rails_version: 5.2.4
- test:
name: "ruby2-4_rails5-2"
ruby_version: 2.4.6
bundler_version: 2.0.2
rails_version: 5.2.4
- test:
name: "jruby9-2_rails5-2"
ruby_type: "jruby"
ruby_version: 9.2.0.0
bundler_version: 2.0.2
rails_version: 5.2.4

rails_version: 5.2.8.1
# Rails 5.1
- test:
name: "ruby2-7_rails5-1"
ruby_version: 2.7.5
ruby_version: 2.7.7
rails_version: 5.1.7
- test:
name: "ruby2-6_rails5-1"
ruby_version: 2.6.9
ruby_version: 2.6.10
rails_version: 5.1.7
- test:
name: "ruby2-5_rails5-1"
ruby_version: 2.5.9
rails_version: 5.1.7
- test:
name: "ruby2-4_rails5-1"
ruby_version: 2.4.6
rails_version: 5.1.7
- test:
name: "jruby9-2_rails5-1"
ruby_type: "jruby"
ruby_version: 9.2.7.0
rails_version: 5.1.7

nightly:
triggers:
Expand All @@ -146,83 +148,84 @@ workflows:
- main

jobs:
# Rails 7.0
- test:
name: "ruby3-2_rails7-0"
ruby_version: 3.2.0
rails_version: 7.0.4.1
- test:
name: "ruby3-1_rails7-0"
ruby_version: 3.1.3
rails_version: 7.0.4.1
- test:
name: "ruby3-0_rails7-0"
ruby_version: 3.0.5
rails_version: 7.0.4.1
# Rails 6.1
- test:
name: "ruby3-2_rails6-1"
ruby_version: 3.2.0
rails_version: 6.1.7.1
- test:
name: "ruby3-1_rails6-1"
ruby_version: 3.1.3
rails_version: 6.1.7.1
- test:
name: "ruby3-0_rails6-1"
ruby_version: 3.0.5
rails_version: 6.1.7.1
- test:
name: "ruby2-7_rails6-1"
ruby_version: 2.7.5
bundler_version: 2.0.2
rails_version: 6.1.6.1
ruby_version: 2.7.7
rails_version: 6.1.7.1
# Rails 6.0
- test:
name: "ruby3-2_rails6-0"
ruby_version: 3.2.0
rails_version: 6.0.6.1
- test:
name: "ruby3-1_rails6-1"
ruby_version: 3.1.3
rails_version: 6.0.6.1
- test:
name: "ruby3-0_rails6-1"
ruby_version: 3.0.5
rails_version: 6.0.6.1
- test:
name: "ruby2-7_rails6-0"
ruby_version: 2.7.5
bundler_version: 2.0.2
rails_version: 6.0.2
ruby_version: 2.7.7
rails_version: 6.0.6.1
- test:
name: "ruby2-6_rails6-0"
ruby_version: 2.6.9
bundler_version: 2.0.2
rails_version: 6.0.2
ruby_version: 2.6.10
rails_version: 6.0.6.1
- test:
name: "ruby2-5_rails6-0"
ruby_version: 2.5.9
bundler_version: 2.0.2
rails_version: 6.0.2
- test:
name: "jruby9-2_rails6-0"
ruby_type: "jruby"
ruby_version: 9.2.0.0
bundler_version: 2.0.2
rails_version: 6.0.2

rails_version: 6.0.6.1
# Rails 5.2
- test:
name: "ruby2-7_rails5-2"
ruby_version: 2.7.5
bundler_version: 2.0.2
rails_version: 5.2.4
ruby_version: 2.7.7
rails_version: 5.2.8.1
- test:
name: "ruby2-6_rails5-2"
ruby_version: 2.6.9
bundler_version: 2.0.2
rails_version: 5.2.4
ruby_version: 2.6.10
rails_version: 5.2.8.1
- test:
name: "ruby2-5_rails5-2"
ruby_version: 2.5.9
bundler_version: 2.0.2
rails_version: 5.2.4
- test:
name: "ruby2-4_rails5-2"
ruby_version: 2.4.6
bundler_version: 2.0.2
rails_version: 5.2.4
- test:
name: "jruby9-2_rails5-2"
ruby_type: "jruby"
ruby_version: 9.2.0.0
bundler_version: 2.0.2
rails_version: 5.2.4

rails_version: 5.2.8.1
# Rails 5.1
- test:
name: "ruby2-7_rails5-1"
ruby_version: 2.7.5
ruby_version: 2.7.7
rails_version: 5.1.7
- test:
name: "ruby2-6_rails5-1"
ruby_version: 2.6.9
ruby_version: 2.6.10
rails_version: 5.1.7
- test:
name: "ruby2-5_rails5-1"
ruby_version: 2.5.9
rails_version: 5.1.7
- test:
name: "ruby2-4_rails5-1"
ruby_version: 2.4.6
rails_version: 5.1.7
- test:
name: "jruby9-2_rails5-1"
ruby_type: "jruby"
ruby_version: 9.2.7.0
rails_version: 5.1.7

2 changes: 1 addition & 1 deletion lib/rubydora/rest_api_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def modify_object(options = {})
query_options = options.dup
pid = query_options.delete(:pid)
run_hook :before_modify_object, :pid => pid, :options => options
ProfileParser.canonicalize_date_string(client[object_url(pid, query_options)].put(nil))
ProfileParser.canonicalize_date_string(client[object_url(pid, query_options)].put(nil).to_s)
rescue Exception => exception
rescue_with_handler(exception) || raise
end
Expand Down
24 changes: 12 additions & 12 deletions spec/lib/digital_object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
end

it "should convert object profile to a simple hash" do
@mock_api.should_receive(:object).with(:pid => 'pid').and_return("<objectProfile><a>1</a><b>2</b><objModels><model>3</model><model>4</model></objectProfile>")
@mock_api.should_receive(:object).with({ pid: 'pid' }).and_return("<objectProfile><a>1</a><b>2</b><objModels><model>3</model><model>4</model></objectProfile>")
h = @object.profile

h.should have_key("a")
Expand All @@ -25,19 +25,19 @@
end

it "should be frozen (to prevent modification)" do
@mock_api.should_receive(:object).with(:pid => 'pid').and_return("<objectProfile><a>1</a><b>2</b><objModels><model>3</model><model>4</model></objectProfile>")
@mock_api.should_receive(:object).with({ pid: 'pid' }).and_return("<objectProfile><a>1</a><b>2</b><objModels><model>3</model><model>4</model></objectProfile>")
h = @object.profile

expect { h['asdf'] = 'asdf' }.to raise_error
end

it "should return nil for empty profile fields" do
@mock_api.should_receive(:object).with(:pid => 'pid').and_return("<objectProfile><a></a></objectProfile>")
@mock_api.should_receive(:object).with({ pid: 'pid' }).and_return("<objectProfile><a></a></objectProfile>")
@object.profile['a'].should be_nil
end

it "should throw exceptions that arise" do
@mock_api.should_receive(:object).with(:pid => 'pid').and_raise(Net::HTTPBadResponse)
@mock_api.should_receive(:object).with({ pid: 'pid' }).and_raise(Net::HTTPBadResponse)
expect { @object.profile }.to raise_error(Net::HTTPBadResponse)
end
end
Expand Down Expand Up @@ -111,7 +111,7 @@
end

it "should allow other datastreams to be added" do
@mock_api.should_receive(:datastream).with(:pid => 'pid', :dsid => 'z').and_raise(RestClient::ResourceNotFound)
@mock_api.should_receive(:datastream).with({ pid: 'pid', dsid: 'z' }).and_raise(RestClient::ResourceNotFound)

@object.datastreams.length.should == 3

Expand Down Expand Up @@ -339,7 +339,7 @@ class MyCustomDatastreamClass < Rubydora::Datastream; end
end

it "should call the Fedora REST API" do
@mock_api.should_receive(:purge_object).with({:pid => 'pid'})
@mock_api.should_receive(:purge_object).with({ pid: 'pid' })
@object.delete
end
end
Expand Down Expand Up @@ -481,7 +481,7 @@ class MyCustomDatastreamClass < Rubydora::Datastream; end
end

it "should fall-back to the set of default attributes" do
@mock_api.should_receive(:object).with(:pid=>"pid").and_raise(RestClient::ResourceNotFound)
@mock_api.should_receive(:object).with({ pid: "pid" }).and_raise(RestClient::ResourceNotFound)
Rubydora::DigitalObject::OBJ_DEFAULT_ATTRIBUTES.should_receive(:[]).with(method.to_sym) { 'zxcv'}
subject.send(method).should == 'zxcv'
end
Expand All @@ -492,7 +492,7 @@ class MyCustomDatastreamClass < Rubydora::Datastream; end
subject.stub(:datastreams => [])
end
it "should mark the object as changed after setting" do
@mock_api.should_receive(:object).with(:pid=>"pid").and_raise(RestClient::ResourceNotFound)
@mock_api.should_receive(:object).with({ pid: "pid" }).and_raise(RestClient::ResourceNotFound)
subject.send("#{method}=", 'new_value')
subject.should be_changed
end
Expand All @@ -504,7 +504,7 @@ class MyCustomDatastreamClass < Rubydora::Datastream; end

it "should appear in the save request" do
@mock_api.should_receive(:ingest).with(hash_including(method.to_sym => 'new_value'))
@mock_api.should_receive(:object).with(:pid=>"pid").and_raise(RestClient::ResourceNotFound)
@mock_api.should_receive(:object).with({ pid: "pid" }).and_raise(RestClient::ResourceNotFound)
subject.send("#{method}=", 'new_value')
subject.save
end
Expand All @@ -526,7 +526,7 @@ class MyCustomDatastreamClass < Rubydora::Datastream; end
end

it "should fall-back to the set of default attributes" do
@mock_api.should_receive(:object).with(:pid=>"pid").and_raise(RestClient::ResourceNotFound)
@mock_api.should_receive(:object).with({ pid: "pid" }).and_raise(RestClient::ResourceNotFound)
Rubydora::DigitalObject::OBJ_DEFAULT_ATTRIBUTES.should_receive(:[]).with(:state) { 'zxcv'}
subject.state.should == 'zxcv'
end
Expand All @@ -537,7 +537,7 @@ class MyCustomDatastreamClass < Rubydora::Datastream; end
subject.stub(:datastreams => [])
end
it "should mark the object as changed after setting" do
@mock_api.should_receive(:object).with(:pid=>"pid").and_raise(RestClient::ResourceNotFound)
@mock_api.should_receive(:object).with({ pid: "pid" }).and_raise(RestClient::ResourceNotFound)
subject.state= 'D'
subject.should be_changed
end
Expand All @@ -554,7 +554,7 @@ class MyCustomDatastreamClass < Rubydora::Datastream; end

it "should appear in the save request" do
@mock_api.should_receive(:ingest).with(hash_including(:state => 'A'))
@mock_api.should_receive(:object).with(:pid=>"pid").and_raise(RestClient::ResourceNotFound)
@mock_api.should_receive(:object).with({ pid: "pid" }).and_raise(RestClient::ResourceNotFound)
subject.state='A'
subject.save
end
Expand Down
Loading

0 comments on commit 1bac22d

Please sign in to comment.