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

Feature/ignore custom route #54

Merged
merged 8 commits into from
Aug 29, 2024

Conversation

Metalzoid
Copy link
Contributor

Adding =

  • initializer : config.ignored_paths = [] with docs
  • configuration : @ignored_paths = [] && :ignored_paths
  • route_extraction :
  • creating method ignore_custom_paths. Sanitize api_path, and check route with AND without api_path. Support controller#action AND controller (for ignoring all actions in this controller)

I hope the code is clean enough, don't hesitate to correct and explain to me if it doesn't suit you so that I can improve :)

@a-chacon
Copy link
Owner

Hey! Thank you! Again, I can review this at the end of the day. But at the first look I see it is ok. You can run rubocop in your local before upload the changes, so you can be sure you fix it ;)

@a-chacon
Copy link
Owner

And, please. Can you make a simple test for this feature? Like add a route to excluded paths, then check that your function returns what you expected? The file does not exist, so you should be create it. Something like /tests/lib/oas_rails/extractores/oas_route_extractor_test.rb. You can check the others files too.

@Metalzoid
Copy link
Contributor Author

And, please. Can you make a simple test for this feature? Like add a route to excluded paths, then check that your function returns what you expected? The file does not exist, so you should be create it. Something like /tests/lib/oas_rails/extractores/oas_route_extractor_test.rb. You can check the others files too.

I can try, but i never write a test ahah. I'm going how make that 👯‍♂️

@a-chacon
Copy link
Owner

Don't worry, just look the others tests and you will know how to make it

@Metalzoid
Copy link
Contributor Author

I couldn't do make the tests, because it's necessary to reload the app every time you modify the config file.. sorry

@a-chacon
Copy link
Owner

a-chacon commented Aug 29, 2024

mm I don't understand. If you show me what you try then I can help you. But I mean, you can do a simple test like this seudo code:

      def test_ignored_paths
        OasRails.config.ignored_paths = ["usersController#index"]
        assert Extractors::RouteExtractor.ignore_custom_paths("/users")
        assert_not Extractors::RouteExtractor.ignore_custom_paths("/projects")

        # then you can reset to default if needed
        OasRails.config.ignored_paths = []
      end

And try to test every branch in the method.

You can look this

Is it what you can't do?

@Metalzoid
Copy link
Contributor Author

Metalzoid commented Aug 29, 2024

It's a private method. I can use it ?

And I going rename because is not for path, is for ignore controller#action

@a-chacon
Copy link
Owner

aa ok, I am sorry, I didn't see that. Then you can test it with the host_routes method, maybe? And use clear_cache method if it is needed for reset the variable?

@a-chacon a-chacon linked an issue Aug 29, 2024 that may be closed by this pull request
@a-chacon a-chacon assigned a-chacon and Metalzoid and unassigned a-chacon Aug 29, 2024
@a-chacon a-chacon added the enhancement New feature or request label Aug 29, 2024
@a-chacon a-chacon self-requested a review August 29, 2024 16:28
@Metalzoid
Copy link
Contributor Author

it's all done 🤟

Copy link
Owner

@a-chacon a-chacon left a comment

Choose a reason for hiding this comment

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

After resolve this, we are ok with your feature! Thanks again!

CHANGELOG.md Outdated
Copy link
Owner

Choose a reason for hiding this comment

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

hey! This file is created automatically. There is no need for touch it. I think you open it and your code editor formatted it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i don't touch that, idk?? I restore from main that file

@a-chacon a-chacon merged commit e34b3ee into a-chacon:main Aug 29, 2024
4 checks passed
@a-chacon
Copy link
Owner

hey @Metalzoid thank you! I will release a new version at the night.

@a-chacon
Copy link
Owner

a-chacon commented Aug 29, 2024

We have problems :( Why it fails in main and not here?

Run options: --seed 56473
# Running:
.........................F
Failure:
OasRails::Builders::RouteExtractorTest#test_with_custom_controllers_actions [test/lib/oas_rails/extractors/route_extractor_test.rb:14]:
Expected: 13
  Actual: 14
bin/rails test test/lib/oas_rails/extractors/route_extractor_test.rb:11
F
Failure:
OasRails::Builders::RouteExtractorTest#test_with_custom_controller_only [test/lib/oas_rails/extractors/route_extractor_test.rb:21]:
Expected: 8
  Actual: 14
bin/rails test test/lib/oas_rails/extractors/route_extractor_test.rb:18
.
Finished in 0.067122s, 417.1500 runs/s, 849.1981 assertions/s.
28 runs, 57 assertions, 2 failures, 0 errors, 0 skips

Do you know what could be happening here?

https://github.com/a-chacon/oas_rails/actions/runs/10620740013/job/29441251829?pr=53

@Metalzoid
Copy link
Contributor Author

Oh yes, I see. M'y bad ! The test works with test environment (route you are created on the test environment). The result is write in brut, not auto calculated.
I try to fix it tomorrow ok ?

@a-chacon
Copy link
Owner

yes! don't worry. We leave the release for the weekend. I really appreciate your interest in helping with this.

About the failing tests. Mm give it a look. All the tests run with the test environment, so could be another thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Excluding customs routes ?
2 participants