Class: Embryo::RubyTemplate::Action::Update
Instance Method Summary
collapse
#initialize
#text
Instance Method Details
#controller_method_code ⇒ Object
5
6
7
8
9
10
11
12
|
# File 'lib/rails-embryo/ruby_template/action/update.rb', line 5
def controller_method_code
method_code :update,
"if @#{model.singular}.update_attributes #{model.singular}_params",
indent("redirect_to #{@model.plural_symbol}_path, notice: \"#{model.singular.capitalize} updated.\""),
"else",
indent("render :show"),
"end"
end
|
#controller_spec_code ⇒ Object
14
15
16
17
18
19
20
21
|
# File 'lib/rails-embryo/ruby_template/action/update.rb', line 14
def controller_spec_code
spec_group_code "#update",
spec_context_code("with valid attributes",
spec_code("redirects to the index",
"@#{model.singular} = create :#{model.symbol}",
"post :update, id: @#{model.singular}.id, #{model.singular}: attributes_for(:#{model.symbol})",
"expect(response).to redirect_to #{model.plural_symbol}_path"))
end
|