Skip to content
Merged
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
26 changes: 26 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: tests

on:
push:
branches: [master]
pull_request:

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
gemfile: [rails_7_2, rails_8_0, rails_8_1]
env:
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
steps:
- uses: actions/checkout@v4
# reads the ruby version from .ruby-version
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- run: bundle exec rake
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.9.3
3.3.13
2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# mirrors .ruby-version so mise loads the repo-local version; keep the two in sync
ruby 3.3.13
26 changes: 0 additions & 26 deletions .travis.yml

This file was deleted.

10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

**Please Note**: This change log only covers v1.3 forwards - apologies for anything missing prior to that.

## Version 1.13.3 (cloud66 fork)

* Support for Rails 8.1: removed the unused `protected_instance_variables` setting, which relied on `config_accessor`, and the `api` / `rocket_pants` routes helper now passes its options to `scope` as keywords.
* **Breaking:** JSONP support is removed. It has not worked since Rails 5.1, and calling `jsonp` now raises `NotImplementedError` when the controller class is loaded.
* `RocketPants::Client` accepts the response object returned by current HTTParty versions again.
* The gemspec now requires Ruby 3.3 or newer and Rails 7.2 or newer, which is what the fork is tested on.
* The `api` / `rocket_pants` routes helper accepts string-keyed options.
* `RocketPants::Client` raises `RocketPants::Error` for a malformed JSON body.
* The specs run against Rails 7.2, 8.0 and 8.1 (see "Running the tests" in the README), including a suite that boots a real Rails application, and raise on any Rails deprecation.

## Version 1.13.1

* Bug fix to bugsnag, thanks to [DamirSvrtan](https://github.com/DamirSvrtan).
Expand Down
22 changes: 2 additions & 20 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,7 @@
source 'https://rubygems.org'

# Allow testing multiple versions with Travis.
rails_version = ENV['RAILS_VERSION']
if rails_version && rails_version.length > 0
puts "Testing Rails Version = #{rails_version}"
# Override the specific versions
gem 'railties', rails_version
gem 'actionpack', rails_version
gem 'activerecord', rails_version
end

if (moneta_version = ENV["MONETA_VERSION"])
gem 'moneta', moneta_version
end

# the supported rails versions each have their own gemfile under gemfiles/; see the README.
gem 'rspec'

if (wp_version = ENV['WILL_PAGINATE_VERSION'])
gem 'will_paginate', wp_version
end

gem 'active_model_serializers', ENV['AMS_VERSION'] || '> 0.0'
gem 'active_model_serializers', '> 0.0'

gemspec
40 changes: 22 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,7 @@ with the `Etag` header set.

#### JSONP

If you want to enable JSONP support, it's as simple as calling `jsonp` in your class method:

```ruby
class MyController < RocketPants::Base
jsonp
end
```

By default this will use the `callback` parameter, e.g. `GET /1/my?callback=console.log`.
To change this parameter, specify the `parameter` option like so:

```ruby
class MyController < RocketPants::Base
jsonp :parameter => :jsonp
end
```

Finally, to disable it in a subclass, simple call `jsonp` in the child and pass `:enable => false` as an option.
JSONP is **not supported** in this fork. The original implementation relied on controller callbacks that Rails removed in 5.1, so it has not worked for a long time. Calling `jsonp` in a controller now raises `NotImplementedError` as soon as the class is loaded, with a message naming the controller, so it cannot be switched on by mistake.

#### Header Metadata

Expand Down Expand Up @@ -696,6 +679,27 @@ Inside the `RSpec.configure do |config|` block.

If you're not on this list and thing you should be, let @Sutto know.

## Running the tests

This fork is tested against Rails 7.2, 8.0 and 8.1 on the Ruby version in `.ruby-version`. Each Rails version has its own gemfile under `gemfiles/`. GitHub Actions runs all three on every pull request (`.github/workflows/tests.yml`), and `bin/test` does the same locally, refusing to run on a different Ruby version:

```bash
bin/test
```

To run against one Rails version:

```bash
export BUNDLE_GEMFILE=gemfiles/rails_8_1.gemfile
bundle install
bundle exec rake spec # the main suite
bundle exec rake spec:smoke # boots a real Rails application around the gem
```

The `smoke` specs run in their own process because Rails has to be loaded before the gem for its Railtie to be set up. Every Rails deprecation is raised as an error in both suites.

The kaminari and RSpec matcher integration specs (`spec/integration`) are not maintained in this fork and currently fail.

## Contributing

We encourage all community contributions. Keeping this in mind, please follow these general guidelines when contributing:
Expand Down
10 changes: 9 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ desc "Run all specs in spec directory (excluding plugin specs)"
RSpec::Core::RakeTask.new(:spec)

INTEGRATION_LIBS = %w(will_paginate kaminari active_record active_model_serializers rspec)
# kaminari and the rspec matchers are not maintained in this fork, and their specs fail.
MAINTAINED_INTEGRATION_LIBS = INTEGRATION_LIBS - %w(kaminari rspec)

namespace :spec do

Expand All @@ -25,6 +27,12 @@ namespace :spec do

end

# separate process: rails must be loaded before rocket_pants for the railtie to exist.
desc "Run the specs that boot a real Rails application"
RSpec::Core::RakeTask.new(:smoke) do |t|
t.pattern = "./smoke/*_spec.rb"
end

desc "Run all specs with rcov"
RSpec::Core::RakeTask.new(:rcov) do |t|
t.rcov = true
Expand All @@ -33,4 +41,4 @@ namespace :spec do
end
end

task :default => ([:spec] + INTEGRATION_LIBS.map { |l| "spec:integration:#{l}" })
task :default => ([:spec, "spec:smoke"] + MAINTAINED_INTEGRATION_LIBS.map { |l| "spec:integration:#{l}" })
18 changes: 18 additions & 0 deletions bin/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
# runs the default rake task (specs, smoke and maintained integrations) on every supported rails version.
set -euo pipefail
cd "$(dirname "$0")/.."

wanted="$(cat .ruby-version)"
actual="$(ruby -e 'print RUBY_VERSION')"
if [ "${actual}" != "${wanted}" ]; then
echo "bin/test needs ruby ${wanted} but found ${actual}; try: mise exec -- bin/test" >&2
exit 1
fi

for gemfile in gemfiles/rails_*.gemfile; do
echo "== ${gemfile}"
export BUNDLE_GEMFILE="${gemfile}"
bundle install --quiet
bundle exec rake
done
13 changes: 13 additions & 0 deletions gemfiles/rails_7_2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
source "https://rubygems.org"

gemspec path: ".."

gem "railties", "~> 7.2.0"
gem "actionpack", "~> 7.2.0"
gem "activerecord", "~> 7.2.0"

gem "rspec"
gem "active_model_serializers", "> 0.0"

# central locks json 2.21.x; on rails 8.1 that selects active support's newer json encoder
gem "json", "~> 2.21"
Loading
Loading