class Object
Public Instance Methods
<(%= resource_name %>_form_values(<%= resource_name %>) <%- if t_helper.shallow_routes? -%> <%= resource_name %>.persisted? ? <%= t_helper.scoped_values_for_form resource_name, true %> : <%= t_helper.scoped_values_for_form resource_name, false %> <%- else -%> <%= t_helper.scoped_values_for_form resource_name %> <%- end -%>)
click to toggle source
Returns the form arguments required to create or update the <%= resource_name %>
# File lib/generators/authorized_rails_scaffolds/install_templates/templates/scaffold/helper.rb, line 16 def <%= resource_name %>_form_values(<%= resource_name %>) <%- if t_helper.shallow_routes? -%> <%= resource_name %>.persisted? ? <%= t_helper.scoped_values_for_form resource_name, true %> : <%= t_helper.scoped_values_for_form resource_name, false %> <%- else -%> <%= t_helper.scoped_values_for_form resource_name %> <%- end -%> end
valid_create_attributes()
click to toggle source
This should return the minimal set of attributes required to create a valid <%= resource_class %>.
# File lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/controller_spec.rb, line 58 def valid_create_attributes FactoryGirl.attributes_for(<%= resource_symbol %>) end # This should return the minimal set of attributes required to update a valid # <%= resource_class %>. def valid_update_attributes FactoryGirl.attributes_for(<%= resource_symbol %>) end <%- if parent_model_names.any? -%> <%- parent_model_names.each do |parent_model| -%> let(<%= t_helper.references_test_sym(parent_model) %>) { <%= t_helper.create_parent_resource_from_factory parent_model %> } <%- end -%> <%- end -%> <% unless options[:singleton] -%> describe "GET index" do <%= t_helper.start_nesting_block %> <%- t_helper.parent_models.each do |parent_model| -%> grant_ability :read, <%= parent_model.classify %> <%- end -%> context 'without a user session' do describe 'with a valid request' do before(:each) do <%= resource_test_var %> = <%= t_helper.create_resource_from_factory %> get :index, {<%= t_helper.build_example_index_params %>} end it { should redirect_to(new_user_session_path) } it { should set_the_flash[:alert].to("You need to sign in or sign up before continuing.") } end end context 'as an unauthorized user' do login_unauthorized_user describe 'with a valid request' do before(:each) do <%= resource_test_var %> = <%= t_helper.create_resource_from_factory %> get :index, {<%= t_helper.build_example_index_params %>} end it { should redirect_to(root_url) } it { should set_the_flash[:alert].to("You are not authorized to access this page.") } end end context 'as user with read ability' do login_user_with_ability :read, <%= resource_class %> describe 'with a valid request' do before(:each) do <%= resource_test_var %> = <%= t_helper.create_resource_from_factory %> get :index, {<%= t_helper.build_example_index_params %>} end it { should respond_with(:success) } it { should render_template(:index) } it { should render_with_layout(:application) } it "assigns all <%= t_helper.resource_array_name %> as <%= t_helper.resource_array_var %>" do assigns(<%= t_helper.resource_array_sym %>).should eq([<%= resource_test_var %>]) end end end