Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## the test
- def test_should_assign_dashboard_items
- login_as :aaron
- get :index
- assert_response :success
- assert_not_nil assigns(:post), "Did not assign a news posting"
- assert_not_nil assigns(:shifts), "Did not assign shifts for the calendar."
- id = Post.find(:first, :order => "created_at DESC", :limit => 1).id
- assert_select "div#post-#{id}", true, "div#post-#{id} should be assigned."
- assert_select "div#calendar", true, "div#calendar should be assigned."
- end
- ## the error
- fails inside the partial that renders the post on post.user.name
- ActionView::TemplateError: You have a nil object when you didn't expect it!
- The error occurred while evaluating nil.name
- On line #3 of shared/_post.html.erb
- 1: <div id="post-<%= post.id %>">
- 2: <h2><%= post.title %></h2>
- 3: <p><strong>Posted on: <%= post.posted_on %></strong> by <strong><%= post.user.name %></strong>
- 4: <% if current_user.is_admin? %>
- 5: <strong>[ <%= link_to 'Edit', edit_admin_post_path(post) %> <%= link_to 'Delete', {:controller => 'admin/posts', :action => 'destroy', :id => post.id}, :confirm => 'Are you sure?', :method => :delete %> ]</strong>
- 6: <% end %>
- ## posts.yml
- one:
- id: 1
- title: MyString
- content: MyText
- user: brandon
- two:
- id: 2
- title: MyString
- content: MyText
- user: brandon
- ## users.yml
- brandon:
- id: 4
- login: brandon
- email: fake@fake.com
- salt: da4b9237bacccdf19c0760cab7aec4a8359010b0 # SHA1('1')
- crypted_password: 7006b28985f1682bf1a75b0ce4871eea60d39627 # 'monkey'
- first_name: brandon
- last_name: george
Add Comment
Please, Sign In to add comment