Skip to content
Merged
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
91 changes: 88 additions & 3 deletions ruby3.2-activemodel.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package:
name: ruby3.2-activemodel
version: 7.2.1.2
epoch: 1
version: 8.0.0
epoch: 0
description: A toolkit for building modeling frameworks like Active Record. Rich support for attributes, callbacks, validations, serialization, internationalization, and testing.
copyright:
- license: MIT
Expand All @@ -24,7 +24,7 @@ pipeline:
with:
repository: https://github.com/rails/rails
tag: v${{package.version}}
expected-commit: 7750d64a65e5b2641d87ef45e6e65ace193d9a27
expected-commit: dd8f7185faeca6ee968a6e9367f6d8601a83b8db

- uses: ruby/build
with:
Expand All @@ -42,6 +42,91 @@ pipeline:
vars:
gem: activemodel

test:
environment:
contents:
packages:
- ruby${{vars.rubyMM}}-activesupport
- ruby${{vars.rubyMM}}-benchmark
- ruby${{vars.rubyMM}}-uri
pipeline:
- name: Basic require test
runs: ruby -e "require 'active_model'"
- name: Test validations and errors
runs: |
ruby <<EOF-
require 'active_model'

class Person
include ActiveModel::Validations

attr_accessor :name, :email, :age
validates :name, presence: true
validates :email, format: { with: /@/, message: 'must contain @' }
validates :age, numericality: { greater_than: 0 }, allow_nil: true
end

person = Person.new
raise 'Validation failed: empty should be invalid' if person.valid?
raise 'Name error missing' unless person.errors[:name].include?("can't be blank")

person.name = 'John'
person.email = 'invalid'
raise 'Email validation failed' if person.valid?
raise 'Email error missing' unless person.errors[:email].include?('must contain @')

puts 'ActiveModel validations tests passed'
EOF-
- name: Test model naming and conversion
runs: |
ruby <<EOF-
require 'active_model'

class Article
include ActiveModel::Conversion
extend ActiveModel::Naming

attr_accessor :id, :title

def persisted?
false
end
end

article = Article.new
raise 'Model name failed' unless Article.model_name.singular == 'article'
raise 'Model name failed' unless Article.model_name.plural == 'articles'
raise 'Model param key failed' unless Article.model_name.param_key == 'article'
raise 'To param failed' unless article.to_param.nil?

puts 'ActiveModel naming and conversion tests passed'
EOF-
- name: Test serialization
runs: |
ruby <<EOF-
require 'active_model'

class Product
include ActiveModel::Serialization

attr_accessor :name, :price

def attributes
{'name' => name, 'price' => price}
end
end

product = Product.new
product.name = 'Widget'
product.price = 19.99

serialized = product.serializable_hash
raise 'Serialization failed for name' unless serialized['name'] == 'Widget'
raise 'Serialization failed for price' unless serialized['price'] == 19.99

puts 'ActiveModel serialization tests passed'
EOF-

update:
enabled: true
github:
Expand Down
Loading