Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
2710ded
refactor!: rewrite the client for 2.0
mantas Nov 18, 2026
2e8ee95
feat: ship a test kit for code that calls this client
mantas Nov 18, 2026
30534e1
feat: add RBS signatures and check them with Steep
mantas Nov 18, 2026
374420b
ci: drive a live Zammad end to end and publish by tag
mantas Nov 18, 2026
8f7562d
docs: document 2.0 and the way up from 1.x
mantas Nov 18, 2026
be4d464
fix: refuse a record where a record id belongs
mantas Nov 18, 2026
d8f5d0f
fix: refuse one attribute given under two spellings
mantas Nov 18, 2026
6aa7163
fix: keep credentials out of a record's inspect
mantas Nov 18, 2026
f324a4d
fix: have the test kit retry a read as the client does
mantas Nov 18, 2026
8d5bedc
fix: read an index that does not page in one request
mantas Nov 18, 2026
3ef6175
refactor!: remove the names 1.x had for readers and add_article
mantas Nov 18, 2026
123bcf6
fix: redact a URL that has no host where the host belongs
mantas Nov 19, 2026
4b32dff
fix: log a request body as it is sent
mantas Nov 19, 2026
b5329ba
fix: redact a path query that is separated by semicolons
mantas Nov 19, 2026
9c62a30
fix: refuse what is not a Hash in assign_attributes
mantas Nov 19, 2026
8d476fd
fix: read strong parameters as the Hash they convert to
mantas Nov 19, 2026
01147ad
fix: refuse arguments given to an attribute reader
mantas Nov 19, 2026
ee735d6
fix: answer any? and none? with the request empty? makes
mantas Nov 19, 2026
3bfe28e
fix: keep an adapter the middleware callable sets
mantas Nov 19, 2026
7ae5ba5
test: read resources by their plural names in the live specs
mantas Nov 19, 2026
5187ada
fix: find a line break beside bytes invalid in the encoding
mantas Nov 19, 2026
6c46f3d
fix: redact the credentials Zammad filters from its own log
mantas Nov 19, 2026
035f454
fix: carry a derived config in the test kit's transport
mantas Nov 19, 2026
054dbe3
fix: refuse a request path that opens with a scheme
mantas Nov 19, 2026
9b7dcf2
fix: refuse a query value or a scope that is no value
mantas Nov 19, 2026
49b547b
fix: drop a constant the library no longer has from the sigs
mantas Nov 19, 2026
3f18eed
fix: refuse a body value that JSON has no type for
mantas Nov 20, 2026
846d106
fix: keep credentials out of to_json under ActiveSupport
mantas Nov 20, 2026
d1fa214
fix: refuse a raw request header name that is not one
mantas Nov 20, 2026
a3c28a7
fix: serve a stub declared after an earlier one answered
mantas Nov 20, 2026
4e79f0b
fix: raise for a response body cut short of its length
mantas Nov 20, 2026
310daa8
fix: refuse a query value that is no Integer or Float
mantas Nov 20, 2026
95acc4a
fix: leave deep_dup and presence to ActiveSupport
mantas Nov 20, 2026
635e89f
fix: refuse a logger whose debug requires an argument
mantas Nov 20, 2026
441cffe
fix: download an attachment uncompressed to check its length
mantas Nov 20, 2026
d5375fd
fix: raise ConfigurationError for a url that was left out
mantas Nov 20, 2026
25022e7
test: load the test kit in the client spec that uses it
mantas Nov 20, 2026
b81744c
fix: read Retry-After in base ten
mantas Nov 20, 2026
4c273fc
fix: declare the dependency on logger
mantas Nov 20, 2026
5626d5c
docs: drop the 1.x collection methods that never existed
mantas Nov 20, 2026
bf3146b
docs: match an expanded group by its name in the README
mantas Nov 20, 2026
6f06739
fix: read a Content-Length a middleware left as an Integer
mantas Nov 20, 2026
fcf8b96
fix: settle a record whose 2xx answer was cut short
mantas Nov 20, 2026
e571d27
fix: strip a line break from the end of a header value
mantas Nov 20, 2026
1d17b19
fix: read only: and except: in a record's as_json
mantas Nov 20, 2026
e8452d3
fix: blank a fragment where a request path is printed
mantas Nov 20, 2026
29eec34
chore: name irb in the bundle for bin/console
mantas Nov 20, 2026
2fca771
docs: say a retry wait can exceed timeout by the jitter
mantas Nov 20, 2026
7aaa7bd
docs: run the examples through Bundler from a checkout
mantas Nov 20, 2026
7dd9e93
ci: call the zammad_ref input a branch or a tag
mantas Nov 20, 2026
b2cd6f8
fix: quote no value where a body cannot be encoded
mantas Nov 20, 2026
4dd7ad6
fix: write no credential into a to_yaml
mantas Nov 20, 2026
7b64645
fix: sort by id last, so tied records keep their page
mantas Nov 20, 2026
a24cfb3
fix: refuse a url with no host before its port
mantas Nov 20, 2026
dc408fe
fix: refuse a timeout the HTTP stack cannot wait for
mantas Nov 20, 2026
80734b7
fix: refuse a Hash with no value in a query
mantas Nov 20, 2026
f93e2b2
fix: take a blank token for unset and refuse a non-String
mantas Nov 20, 2026
b023a50
test: compare what the preflight reads back from Zammad
mantas Nov 20, 2026
9628d3a
docs: say a create cut short has no id to reload by
mantas Nov 20, 2026
3c19f49
fix: ask again before calling a repeated page ignored
mantas Nov 23, 2026
bef37a9
fix: settle a save only on a 2xx that says it is JSON
mantas Nov 23, 2026
4a65630
fix: take no Authorization from Faraday's shared options
mantas Nov 23, 2026
76224bc
fix: redact a proxy the environment names from an error
mantas Nov 23, 2026
1167fe3
fix: answer exists? with false for a record with no id
mantas Nov 23, 2026
a3e65ac
docs: say the timeout cannot be turned off
mantas Nov 23, 2026
c5ac884
fix: follow a belongs_to declared after the first write
mantas Nov 23, 2026
19b32ac
docs: tell 1.x code of Symbol keys inside an Array
mantas Nov 23, 2026
3f02cfa
fix: read the records once for each_slice and each_cons
mantas Nov 23, 2026
08f4566
fix: keep a staged password out of the FrozenError
mantas Nov 23, 2026
3bcdd68
fix: settle a destroy only on a 2xx that is Zammad's
mantas Nov 23, 2026
d573762
docs: say that a record does not go through Marshal
mantas Nov 23, 2026
6e92b5a
fix: spend one stub on the count of a stubbed search
mantas Nov 23, 2026
7ac8ee9
chore: name csv in the bundle for the ticket report
mantas Nov 23, 2026
e117cd8
fix: read the record by its id for find_by(id:)
mantas Nov 23, 2026
c5971d4
fix: refuse a request path that climbs with a .. segment
mantas Nov 23, 2026
1861890
fix: hold a stubbed 2xx to its Content-Length
mantas Nov 23, 2026
a48c482
fix: take a user agent of only whitespace for unset
mantas Nov 23, 2026
de5109a
fix: use a proxy set for every Faraday connection
mantas Nov 24, 2026
2750f38
fix: make to_h of attributes plain at every depth
mantas Nov 24, 2026
6e90d92
fix: convert text of another encoding to UTF-8 for a URL
mantas Nov 24, 2026
d88f789
fix: send a GET again for a body cut short
mantas Nov 24, 2026
dc706dd
fix: serve a stubbed list by the page size asked for
mantas Nov 24, 2026
a09a8a8
fix: send binary-tagged UTF-8 text in a body as text
mantas Nov 24, 2026
b5d8915
fix: take a variable of only whitespace for unset
mantas Nov 24, 2026
882ed14
fix: read the name of an environment variable as bytes
mantas Nov 24, 2026
acbfefe
refactor!: simplify the client to straightforward API usage
mantas Nov 24, 2026
69e5d78
refactor!: drop the remaining edge-case guards
mantas Nov 24, 2026
82e27e2
refactor!: drop has_many and the open-timeout reclassification
mantas Nov 24, 2026
ce76b1f
docs: trim two examples to everyday scripts
mantas Nov 24, 2026
79bf3cd
refactor!: drop paginated and the argument and config checks
mantas Nov 25, 2026
f3c9cf3
refactor!: drop related and belongs_to
mantas Nov 25, 2026
40795e0
refactor: read Client#me through users.find
mantas Nov 25, 2026
66faa64
chore: drop the has_many exemption from the RuboCop config
mantas Nov 25, 2026
e1b737f
docs: drop cruft from the README, CHANGELOG and examples
mantas Nov 25, 2026
8996feb
refactor: drop the internal requires that lib/zammad_api.rb already m…
mantas Nov 26, 2026
85814c2
refactor: inline three one-caller hops
mantas Nov 26, 2026
d6cdd4e
refactor: refuse a blank on_behalf_of in Client#on_behalf_of itself
mantas Nov 26, 2026
4f7c1c8
refactor: drop the conversion-method list from Client#method_missing
mantas Nov 26, 2026
5cc2e7c
refactor: one Client constructor, and the test kit as a Faraday adapter
mantas Nov 26, 2026
352f986
test: drop the unit examples that assert nothing lib/ does any more
mantas Nov 26, 2026
88c2232
feat!: drop the test kit
mantas Nov 26, 2026
be1dc69
Docs: make the README readable from the top
mantas Nov 26, 2026
49460d6
Docs: add a features roadmap comparing Ruby 1.x, Ruby 2.0 and the PHP…
mantas Nov 26, 2026
4c4a0c0
Docs: add roles to the features roadmap
mantas Nov 26, 2026
4ce4dbf
Docs: fold the example scripts into the README
mantas Nov 26, 2026
1ca8c29
refactor: drop the symbolize_keys switch from DeepCopy.frozen_copy
mantas Nov 26, 2026
3b35a37
refactor: one redaction constant, and no constant for the 2xx range
mantas Nov 26, 2026
87e1eaa
Chore: drop four RuboCop exemptions nothing uses
mantas Nov 26, 2026
9ff9fd5
Refactor: forward the collection shorthands by hand
mantas Nov 26, 2026
05c6fab
Docs: drop three changelog entries that compare to a draft
mantas Nov 26, 2026
34f7c02
Docs: say that a raw request takes a String body
mantas Nov 26, 2026
057cfdd
Docs: list roles among what the README says is not modelled
mantas Nov 26, 2026
4d52699
Chore: describe the gem in the gemspec, not the release
mantas Nov 26, 2026
b455cd6
Chore: drop homepage_uri from the gemspec metadata
mantas Nov 26, 2026
ce753de
Docs: make the generated docs carry UPGRADING and live links
mantas Nov 26, 2026
d9aab06
Docs: describe each resource class, and VERSION
mantas Nov 26, 2026
8c406b0
Docs: leave the private API out of the generated reference
mantas Nov 26, 2026
76ad7f4
Docs: link each changelog version to its comparison
mantas Nov 26, 2026
9a22682
Chore: trim the comments that retell past bugs
mantas Nov 26, 2026
9023783
Update ROADMAP with requested features section
derpixler Nov 26, 2026
ebdd60d
Fix formatting for framework integration in roadmap
derpixler Nov 26, 2026
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
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,18 @@ updates:
directory: "/"
schedule:
interval: "weekly"
groups:
actions:
patterns: ["*"]
- package-ecosystem: "bundler"
directory: "/"
schedule:
interval: "weekly"
groups:
# Lint and type tooling churns often and never affects the shipped gem.
development:
dependency-type: "development"
patterns: ["*"]
runtime:
dependency-type: "production"
patterns: ["*"]
169 changes: 147 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,182 @@
name: CI

on:
push:
branches: [master]
pull_request:
schedule:
# Run every on Friday to ensure everything works as expected.
- cron: '0 6 * * 5'
# Weekly, to catch breakage from new Ruby or Zammad releases.
- cron: '0 6 * * 5'
workflow_dispatch:
inputs:
zammad_ref:
description: 'Zammad branch or tag to run the integration specs against (not a commit SHA)'
default: 'develop'
type: string

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

permissions:
contents: read

jobs:
lint:
name: RuboCop
runs-on: ubuntu-latest
container:
image: zammad/zammad-ci:latest
steps:
- uses: actions/checkout@v7
- name: Run lint actions
shell: bash
run: |
source /etc/profile.d/rvm.sh # ensure RVM is loaded
bundle update --bundler
bundle install -j $(nproc)
bundle exec rubocop
test:
- uses: ruby/setup-ruby@v1
with:
ruby-version: '4.0'
bundler-cache: true
- run: bundle exec rubocop --format github

types:
name: Steep
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: ruby/setup-ruby@v1
with:
ruby-version: '4.0'
bundler-cache: true
- run: bundle exec steep check
# sig/vendor is always on the load path here but never in the gem, so
# the published set is checked on its own as well.
- run: bundle exec rake rbs_published

unit:
name: Unit specs (Ruby ${{ matrix.ruby }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Stable releases only, from required_ruby_version up to the current
# stable line. There is no 3.5: that line became 4.0.
#
# 'head' is absent: it could not install the bundle when it was last
# tried, under a lockfile that named Bundler 2.6.9. The lockfile names
# Bundler 4 now, and head has not been retried since.
ruby: ['3.4', '4.0']
env:
# The unit specs do not need the type-checking toolchain, and skipping it
# keeps this job fast. The `types` job installs it separately.
BUNDLE_WITHOUT: development
steps:
- uses: actions/checkout@v7
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run unit specs
run: bundle exec rake spec:unit
env:
COVERAGE: 'true'

integration:
name: Integration specs (live Zammad)
runs-on: ubuntu-latest
# Booting Zammad costs far more runner time than the unit suite, so there
# is no point paying for it when the unit specs are already failing.
needs: unit
# A full Zammad boot takes many minutes; without a cap a hung boot would
# occupy a runner until the six hour default expires.
timeout-minutes: 45
container:
image: zammad/zammad-ci:latest
services:
postgresql:
image: postgres:17
image: postgres:18
env:
POSTGRES_USER: zammad
POSTGRES_PASSWORD: zammad
redis:
image: redis:7
env:
ZAMMAD_REF: ${{ inputs.zammad_ref || 'develop' }}
TEST_USER: admin@example.com
TEST_PASSWORD: test
steps:
- uses: actions/checkout@v7
- name: Set up Zammad

- name: Report the toolchain
shell: bash
run: |
git clone --depth 1 https://github.com/zammad/zammad.git
source /etc/profile.d/rvm.sh
# The gem requires Ruby >= 3.4; fail here with a clear message rather
# than inside a confusing bundler resolution error.
ruby -v
ruby -e 'abort "zammad-ci image ships Ruby #{RUBY_VERSION}, this gem needs >= 3.4" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("3.4")'

- name: Boot Zammad
shell: bash
run: |
# No `set -u`: /etc/profile.d/rvm.sh reads unset variables and aborts
# under nounset.
set -eo pipefail
git clone --depth 1 --branch "$ZAMMAD_REF" https://github.com/zammad/zammad.git
cd zammad
source /etc/profile.d/rvm.sh # ensure RVM is loaded
source /etc/profile.d/rvm.sh
bundle config set --local frozen 'true'
bundle config set --local path 'vendor'
bundle install -j $(nproc)
bundle install -j "$(nproc)"
bundle exec ruby .gitlab/configure_environment.rb
# Each workflow step runs in its own shell, so Zammad's generated
# environment has to be promoted to the job environment to survive.
sed -E 's/^export +//' .gitlab/environment.env \
| grep -E '^[A-Za-z_][A-Za-z0-9_]*=' >> "$GITHUB_ENV"
source .gitlab/environment.env
RAILS_ENV=test bundle exec rake db:create
cp contrib/auto_wizard_test.json auto_wizard.json
bundle exec rake zammad:ci:test:start
- name: Run Ruby API integration tests
echo "TEST_URL=http://localhost:${RAILS_PORT:-3000}/" >> "$GITHUB_ENV"

- name: Wait for Zammad to answer
shell: bash
run: |
probe="${TEST_URL%/}/api/v1/getting_started"
for attempt in $(seq 1 60); do
if curl -sSf --max-time 5 "$probe" >/dev/null 2>&1; then
echo "Zammad answered at $TEST_URL after ${attempt} attempt(s)"
exit 0
fi
sleep 5
done
echo "::error::Zammad never answered at $probe"
exit 1

- name: Install the gem's dependencies
shell: bash
run: |
source /etc/profile.d/rvm.sh
bundle install -j "$(nproc)"

- name: Drive Zammad with this gem
shell: bash
run: |
source /etc/profile.d/rvm.sh
bundle exec ruby script/check_connection.rb

- name: Run the integration specs
shell: bash
run: |
source /etc/profile.d/rvm.sh
bundle exec rake spec:integration

- name: Collect Zammad logs on failure
if: failure()
shell: bash
run: |
source /etc/profile.d/rvm.sh # ensure RVM is loaded
bundle update --bundler
bundle install -j $(nproc)
bundle exec rspec
echo '--- zammad/log ---'
tail -n 200 zammad/log/*.log 2>/dev/null || echo 'no logs found'

- name: Upload Zammad logs
if: failure()
uses: actions/upload-artifact@v7
with:
name: zammad-logs
path: zammad/log/
if-no-files-found: ignore
retention-days: 7
45 changes: 45 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Release

# Publishes to RubyGems via trusted publishing (OIDC), so no API key is
# stored in this repository. Configure the trusted publisher once at
# https://rubygems.org/gems/zammad_api/trusted_publishers
on:
push:
tags: ['v*']

permissions:
contents: read

jobs:
release:
name: Build and publish
runs-on: ubuntu-latest
environment: rubygems
permissions:
contents: write # create the GitHub release and push the tag commit
id-token: write # request the OIDC token for trusted publishing
steps:
- uses: actions/checkout@v7
- uses: ruby/setup-ruby@v1
with:
ruby-version: '4.0'
bundler-cache: true
# The tag is what triggers this workflow, and nothing downstream reads
# it: the gem is built from the gemspec, so a tag that disagrees with
# ZammadAPI::VERSION publishes a gem under a version nobody tagged and
# leaves a GitHub release pointing at one that does not exist.
- name: Check the tag against the gem version and the changelog
run: |
tagged="${GITHUB_REF_NAME#v}"
declared="$(ruby -Ilib -rzammad_api/version -e 'print ZammadAPI::VERSION')"
if [ "$tagged" != "$declared" ]; then
echo "::error::tag ${GITHUB_REF_NAME} does not match ZammadAPI::VERSION ($declared)"
exit 1
fi
if ! grep -q "^## \[${declared}\]" CHANGELOG.md; then
echo "::error::CHANGELOG.md has no '## [${declared}]' heading"
exit 1
fi
- name: Verify the release candidate
run: bundle exec rake spec:unit rubocop steep rbs_published
- uses: rubygems/release-gem@v1
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/.bundle/
/.ruby-version
/.yardoc
/.steep/
/.yardoc/
/_yardoc/
/coverage/
/doc/
Expand Down
50 changes: 20 additions & 30 deletions .overcommit.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,23 @@
# Use this file to configure the Overcommit hooks you wish to use. This will
# extend the default configuration defined in:
# https://github.com/sds/overcommit/blob/master/config/default.yml
# See https://github.com/sds/overcommit#configuration
#
# At the topmost level of this YAML file is a key representing type of hook
# being run (e.g. pre-commit, commit-msg, etc.). Within each type you can
# customize each hook, such as whether to only run it on certain files (via
# `include`), whether to only display output if it fails (via `quiet`), etc.
#
# For a complete list of hooks, see:
# https://github.com/sds/overcommit/tree/master/lib/overcommit/hook
#
# For a complete list of options that you can use to customize hooks, see:
# https://github.com/sds/overcommit#configuration
#
# Uncomment the following lines to make the configuration take effect.
# Install with: bundle exec overcommit --install

PreCommit:
RuboCop:
enabled: true
on_warn: fail # Treat all warnings as failures
#
# TrailingWhitespace:
# enabled: true
# exclude:
# - '**/db/structure.sql' # Ignore trailing whitespace in generated files
#
#PostCheckout:
# ALL: # Special hook name that customizes all hooks of this type
# quiet: true # Change all post-checkout hooks to only display output on failure
#
# IndexTags:
# enabled: true # Generate a tags file with `ctags` each time HEAD changes
RuboCop:
enabled: true
on_warn: fail # Treat all warnings as failures
command: ['bundle', 'exec', 'rubocop']

TrailingWhitespace:
enabled: true

YamlSyntax:
enabled: true

BundleCheck:
enabled: true

RSpec:
enabled: true
description: 'Run the unit specs'
command: ['bundle', 'exec', 'rspec', 'spec/unit']
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
--require spec_helper
--format documentation
--color
Loading