Skip to content

Commit

Permalink
Merge branch 'main' into can-they-merge
Browse files Browse the repository at this point in the history
  • Loading branch information
ritikesh authored Oct 4, 2024
2 parents 20cdfa6 + 1cd897f commit c8be82c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 1.1.2 - 2024/10/3
- 🐛 [BUGFIX] Fixes an issue where a `Blueprinter::BlueprinterError` would be raised on render when providing `view: nil`, instead of falling back on the `:default` view. See
[#472](https://github.com/procore-oss/blueprinter/pull/472). Thanks to [@lessthanjacob](https://github.com/lessthanjacob).

## 1.1.1 - 2024/10/2
* 🐛 [BUGFIX] Fixes an issue when when calling `.render` multiple times on a Blueprint using the same `options` hash, which would result in the `options` changing unexpectedly between calls. See [#453](https://github.com/procore-oss/blueprinter/pull/453). Thanks to [@ryanmccarthypdx](https://github.com/ryanmccarthypdx).
* 🐛 [BUGFIX] Fixes an issue when passing in a `Symbol` (representing a method) to the `if:` condition on an association. The provided `Symbol` would be erroneously sent to the association's Blueprint, instead of the Blueprint in which the association was defined within. See [#464](https://github.com/procore-oss/blueprinter/pull/464). Thanks to [@lessthanjacob](https://github.com/lessthanjacob).

## 1.1.0 - 2024/08/02
* [BREAKING] Drops support for Ruby 2.7. See [#402](https://github.com/procore-oss/blueprinter/pull/402). Thanks to [@jmeridth](https://github.com/jmeridth)
* 🚜 [REFACTOR] Cleans up Blueprint validation logic and implements an `Association` class with a clearer interface. See [#414](https://github.com/procore-oss/blueprinter/pull/414). Thanks to [@lessthanjacob](https://github.com/lessthanjacob).
Expand Down
2 changes: 1 addition & 1 deletion lib/blueprinter/helpers/base_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module SingletonMethods
private

def prepare_for_render(object, options)
view_name = options.fetch(:view, :default)
view_name = options.fetch(:view, :default) || :default
root = options[:root]
meta = options[:meta]
validate_root_and_meta!(root, meta)
Expand Down
2 changes: 1 addition & 1 deletion lib/blueprinter/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Blueprinter
VERSION = '1.1.0'
VERSION = '1.1.2'
end
24 changes: 24 additions & 0 deletions spec/integrations/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,29 @@
describe '::render' do
subject { blueprint.render(obj) }

context 'when providing a view' do
let(:blueprint) do
Class.new(Blueprinter::Base) do
identifier :id
field :first_name

view :extended do
field :last_name
end
end
end
it 'renders the data based on the view definition' do
expect(blueprint.render(object_with_attributes, view: :extended)).
to eq('{"id":1,"first_name":"Meg","last_name":"Ryan"}')
end
context 'and the value is nil' do
it 'falls back to the :default view' do
expect(blueprint.render(object_with_attributes, view: nil)).
to eq(blueprint.render(object_with_attributes))
end
end
end

context 'Outside Rails project' do
context 'Given passed object has dot notation accessible attributes' do
let(:obj) { object_with_attributes }
Expand Down Expand Up @@ -544,6 +567,7 @@ def self.has_cars?(_field_name, object, local_options)
end
end
end

describe '::render_as_hash' do
subject { blueprint_with_block.render_as_hash(object_with_attributes) }
context 'Outside Rails project' do
Expand Down

0 comments on commit c8be82c

Please sign in to comment.