-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure that image_kind attribute is assigned first
... and test the other methods in the mixin
- Loading branch information
1 parent
d48da72
commit fa41313
Showing
2 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require "test_helper" | ||
|
||
class ImageKindTest < ActiveSupport::TestCase | ||
setup do | ||
@test_instance = ( | ||
Class.new do | ||
include ActiveModel::Model | ||
include ActiveModel::Attributes | ||
include ActiveModel::AttributeAssignment | ||
|
||
include ImageKind | ||
|
||
attr_reader :assigned_attributes | ||
|
||
def assign_attributes(attributes) | ||
@assigned_attributes = attributes | ||
end | ||
end | ||
).new | ||
end | ||
|
||
test "adds an image_kind method with a default" do | ||
assert_equal "default", @test_instance.image_kind | ||
end | ||
|
||
test "reorders attributes so image_kind comes first" do | ||
@test_instance.assign_attributes( file: "some file", image_kind: "some image kind") | ||
assert_equal({ image_kind: "some image kind", file: "some file" }, @test_instance.assigned_attributes) | ||
end | ||
|
||
test "loads image_kind_config" do | ||
assert_instance_of Whitehall::ImageKind, @test_instance.image_kind_config | ||
end | ||
end |