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

feat: Add Faraday 2.0 support #591

Merged
merged 2 commits into from
Apr 27, 2022
Merged

Conversation

tconst
Copy link
Contributor

@tconst tconst commented Jan 20, 2022

Adds support for Faraday 2.x while maintaining backwards compatibility with older versions.

Checklist

  • I acknowledge that all my contributions will be made under the project's license
  • I have made a material change to the repo (functionality, testing, spelling, grammar)
  • I have read the Contribution Guidelines and my PR follows them
  • I have titled the PR appropriately
  • I have updated my branch with the main branch
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation about the functionality in the appropriate .md file
  • I have added inline documentation to the code I modified

If you have questions, please file a support ticket, or create a GitHub Issue in this repository.

@hosamaly
Copy link

hosamaly commented Mar 7, 2022

Hi, @JenniferMah. I noticed that you approved some pull requests in this repository recently. Do you think we can move this one forward? It would be helpful to get rid of the deprecation warnings when using twilio-ruby with faraday 1.x.

@tremulaes
Copy link

i use twilio in a rails app and this compatibility issue is blocking my upgrade to rails 7- would be great to get this fix out :)

@ismasan
Copy link

ismasan commented Mar 23, 2022

Hi. Could I help to move this forward? The following is a test for Twilio::HTTP::Client to check that the Basic Authentication middleware is registered correctly depending on Faraday version (which is what this PR is about).

  context 'with different Faraday versions' do
    let(:connection) { Faraday.new }

    before do
      allow(Faraday).to receive(:new).and_return(connection).and_yield(connection)
      allow(connection).to receive(:request)
      allow(connection).to receive(:send).and_return(double('response', status: 301, body: {}, headers: {}))
    end

    it 'should set basic authorization with Faraday 1.x' do
      stub_const('Faraday::VERSION', '1.5')
      issue_request_with_auth('a', 'b')
      expect(connection).to have_received(:request).with(:basic_auth, 'a', 'b')
      expect(connection).not_to have_received(:request).with(:authorization, :basic, 'a', 'b')
    end

    it 'should set basic authorization with Faraday 2.x' do
      stub_const('Faraday::VERSION', '2.2')
      issue_request_with_auth('a', 'b')
      expect(connection).to have_received(:request).with(:authorization, :basic, 'a', 'b')
      expect(connection).not_to have_received(:request).with(:basic_auth, 'a', 'b')
    end

    def issue_request_with_auth(username, pwd)
      @client.request('host', 'port', 'GET', 'url', {}, {}, {}, [username, pwd], nil)
    end
  end

If helpful, let me know if you prefer this in patch form, or as a pull request to this branch.

@tconst
Copy link
Contributor Author

tconst commented Mar 24, 2022

It looks like rubocop is flagging the method length with this change, is there any preference on how you all would like me to resolve?

@ismasan
Copy link

ismasan commented Mar 24, 2022

Those methods flagged by Rubocop weren't changed in this PR, so perhaps that should be dealt with separately? Otherwise it risks widening the scope of this change. I agree that those argument lists are a bit unwieldy at the moment.

@chrismanderson
Copy link

Any updates on getting this PR completed and released? Even a stab at timing would be appreciated - this is the last gem my applications need an update to support Rails 7.

@BrianHawley
Copy link

BrianHawley commented Apr 7, 2022

@tconst the current rubocop complaint is definitely related to the method being changed. Since it's a method length complaint, you could just add disabling pragma comments around that method definition:

# rubocop:disable Metrics/MethodLength
def _request(request)
  # ...
end
# rubocop:enable Metrics/MethodLength

@tconst
Copy link
Contributor Author

tconst commented Apr 7, 2022

@BrianHawley Yea I was hoping to get a response from the maintainers on this, I can either disable the cop or move the conditional out into another method. I'll go ahead and disable for now.

@michalkorzawski
Copy link

Hey @JenniferMah, could you or anyone please merge this PR? I'm working on rails 7 app and this faraday thing it's totally blocking my work

@v-kumar
Copy link

v-kumar commented Apr 23, 2022

We are also waiting on the same and it is blocking our upgrade to Faraday 2.0 and Rails 7.0

Copy link
Contributor

@childish-sambino childish-sambino left a comment

Choose a reason for hiding this comment

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

LGTM

@childish-sambino childish-sambino changed the title chore: Add Faraday 2.0 support feat: Add Faraday 2.0 support Apr 27, 2022
@childish-sambino childish-sambino merged commit 4a7a7f2 into twilio:main Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants