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

ruby 3.2 and rails 7 compatible #81

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ source "http://rubygems.org"
# Specify your gem's dependencies in ruby_odata.gemspec
gemspec

gem 'faraday_middleware', github: 'lostisland/faraday_middleware'
gem 'faraday_middleware', github: 'lostisland/faraday_middleware', ref: 'main'
12 changes: 3 additions & 9 deletions lib/ruby_odata/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,23 @@ def post(payload, additional_headers={})
@conn.post do |req|
req.url url
req.headers = (headers || {}).merge(additional_headers)
req.body = prepare_payload payload
req.body = payload
end
end

def put(payload, additional_headers={})
@conn.put do |req|
req.url url
req.headers = (headers || {}).merge(additional_headers)
req.body = prepare_payload payload
req.body = payload
end
end

def patch(payload, additional_headers={})
@conn.patch do |req|
req.url url
req.headers = (headers || {}).merge(additional_headers)
req.body = prepare_payload payload
req.body = payload
end
end

Expand Down Expand Up @@ -143,11 +143,5 @@ def concat_urls(url, suburl) # :nodoc:
"#{url}/#{suburl}"
end
end

def prepare_payload payload
JSON.generate(payload)
rescue JSON::GeneratorError
payload
end
end
end
5 changes: 2 additions & 3 deletions lib/ruby_odata/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,6 @@ def build_batch_operation(operation, changeset_num)
if operation.kind == "Add"
save_uri = "#{@uri}/#{operation.klass_name}"
json_klass = operation.klass.to_json(:type => :add)

content << "POST #{save_uri} HTTP/1.1\n"
content << accept_headers
content << json_klass
Expand Down Expand Up @@ -794,7 +793,7 @@ def parse_value(content, property_type = nil, property_null = nil)

# Parses a value into the proper type based on a specified return type
def parse_primative_type(value, return_type)
return value.to_i if return_type == Fixnum
return value.to_i if return_type == Integer
return value.to_d if return_type == Float
return parse_date(value.to_s) if return_type == Time
return value.to_s
Expand All @@ -803,7 +802,7 @@ def parse_primative_type(value, return_type)
# Converts an edm type (string) to a ruby type
def edm_to_ruby_type(edm_type)
return String if edm_type =~ /Edm.String/
return Fixnum if edm_type =~ /^Edm.Int/
return Integer if edm_type =~ /^Edm.Int/
return Float if edm_type =~ /Edm.Decimal/
return Time if edm_type =~ /Edm.DateTime/
return String
Expand Down
12 changes: 6 additions & 6 deletions ruby_odata.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ Gem::Specification.new do |s|
s.add_dependency("addressable", ">= 2.3.4")
s.add_dependency("i18n", ">= 0.7.0")
s.add_dependency("activesupport", ">= 3.0.0")
s.add_dependency("excon", "~> 0.45.3")
s.add_dependency("excon", ">= 0.45.3")
s.add_dependency("faraday_middleware")
s.add_dependency("faraday", ">= 0.9.1")
s.add_dependency("nokogiri", ">= 1.4.2")

s.add_development_dependency("rake", ">= 12.0.0")
s.add_development_dependency("rspec", ">= 3.4.4")
s.add_development_dependency("rspec-its", "~> 1.2.0")
s.add_development_dependency("cucumber", "~> 2.0.0")
s.add_development_dependency("cucumber", "~> 8.0.0")
s.add_development_dependency("pickle", "~> 0.5.1")
s.add_development_dependency("machinist", "~> 2.0")
s.add_development_dependency("webmock", "~> 1.21.0")
s.add_development_dependency("guard", "~> 2.12.5")
s.add_development_dependency("guard-rspec", "~> 4.5.0")
s.add_development_dependency("guard-cucumber", "~> 1.6.0")
s.add_development_dependency("webmock", "~> 3.0")
s.add_development_dependency("guard", "~> 2.18.0")
s.add_development_dependency("guard-rspec", "~> 4.7.0")
s.add_development_dependency("guard-cucumber", "~> 3.0.0")
s.add_development_dependency("vcr", "~> 2.9.3")
s.add_development_dependency("simplecov", "~> 0.7.1")
s.add_development_dependency("coveralls", "~> 0.6.7")
Expand Down
2 changes: 1 addition & 1 deletion spec/revised_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ module OData
end
it "should return a single primitive type" do
result = subject.FirstCategoryId
result.should be_a Fixnum
result.should be_a Integer
result.should eq 1
end
end
Expand Down
5 changes: 3 additions & 2 deletions spec/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,8 @@ module OData
svc.save_changes
a_request(:post, "http://test.com/test.svc/Categories(1)/$links/Products").
with(:body => { "uri" => "http://test.com/test.svc/Products(1)" },
:headers => DEFAULT_HEADERS.merge({'Content-Type' => 'application/json'})).should have_been_made
:headers => DEFAULT_HEADERS.merge({'Content-Type' => 'application/json'})
).should have_been_made
end

it "should add the child to the parent's navigation property on a single_save" do
Expand Down Expand Up @@ -762,7 +763,7 @@ module OData
it "should perform a post with the correct URL and body on a batch_save" do
WebMock.should have_requested(:post, "http://test.com/test.svc/$batch").with { |request|
request.body.include? "POST http://test.com/test.svc/Categories(1)/$links/Products HTTP/1.1"
request.body.include? '{"uri":"http://test.com/test.svc/Products(1)"}'
request.body.include?({uri: "http://test.com/test.svc/Products(1)"}.to_json)
}
end
context "child is a part of the parent's collection" do
Expand Down