Sha256: 2e5af2ec11933971cae17b515c5aefd73e5efd97f02605c174357bfc017fb9df
Contents?: true
Size: 1013 Bytes
Versions: 1
Compression:
Stored size: 1013 Bytes
Contents
require "test_helper" class ContextTest < MiniTest::Spec class ParentCell < Cell::ViewModel def user context[:user] end def controller context[:controller] end end let (:model) { Object.new } let (:user) { Object.new } let (:controller) { Object.new } let (:parent) { ParentCell.(model, admin: true, context: { user: user, controller: controller }) } it do parent.model.must_equal model parent.controller.must_equal controller parent.user.must_equal user # nested cell child = parent.cell("context_test/parent", "") child.model.must_equal "" child.controller.must_equal controller child.user.must_equal user end # child can add to context it do child = parent.cell(ParentCell, nil, context: { "is_child?" => true }) assert_nil(parent.context["is_child?"]) assert_nil(child.model) child.controller.must_equal controller child.user.must_equal user child.context["is_child?"].must_equal true end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cells-4.1.7 | test/context_test.rb |