test/unit/action_tests.rb in much-rails-0.2.6 vs test/unit/action_tests.rb in much-rails-0.2.7
- old
+ new
@@ -165,22 +165,22 @@
# default_action_template_name
assert_that(subject.default_action_template_name)
.equals(
"some/namespace/for/"\
- "#{MuchRails.config.action.namespace.tableize.singularize}"\
+ "#{MuchRails.config.action.namespace.underscore}"\
"thing/show",
)
end
end
class InitTests < ReceiverTests
desc "when init"
subject do
receiver_class.new(
params: params1,
- current_user: current_user1,
+ current_session: current_session1,
request: request1,
)
end
let(:receiver_class) do
@@ -232,19 +232,19 @@
entered_on: current_date,
updated_at: current_time.utc,
active: "true",
}
end
- let(:current_user1){ "CURRENT USER 1" }
+ let(:current_session1){ "CURRENT SESSION 1" }
let(:request1){ "REQUEST 1" }
- should have_readers :params, :current_user, :request, :errors
+ should have_readers :params, :current_session, :request, :errors
should have_imeths :on_call, :valid_action?, :successful_action?
should "know its attributes" do
assert_that(subject.params).equals(params1.with_indifferent_access)
- assert_that(subject.current_user).equals(current_user1)
+ assert_that(subject.current_session).equals(current_session1)
assert_that(subject.request).equals(request1)
end
should "return the expected Result" do
result = subject.call
@@ -316,10 +316,11 @@
.equals(
template: "some/view/template",
layout: false,
)
+ view_model = Object.new
receiver_class.on_call do
render(view_model, "some/view/template", layout: false)
end
action = receiver_class.new(params: params1)
result = action.call
@@ -328,21 +329,32 @@
.equals(
template: "some/view/template",
layout: false,
)
+ view_model =
+ Class
+ .new{
+ def much_rails_action
+ "NOT A MUCH RAILS ACTION"
+ end
+ }
+ .new
receiver_class.on_call do
render(view_model, "some/view/template", template: "other/template")
end
action = receiver_class.new(params: params1)
result = action.call
assert_that(result.render_view_model).is(view_model)
+ assert_that(result.render_view_model.much_rails_action).is_not(action)
assert_that(result.render_kargs).equals(template: "other/template")
+ view_model = Struct.new(:much_rails_action).new(nil)
receiver_class.on_call{ render(view_model, template: "other/template") }
action = receiver_class.new(params: params1)
result = action.call
assert_that(result.render_view_model).is(view_model)
+ assert_that(result.render_view_model.much_rails_action).is(action)
assert_that(result.render_kargs).equals(template: "other/template")
end
should "return the expected Result given an on_call block that redirects" do
receiver_class.on_call{ redirect_to("URL") }