Testing: setting up checkbox value and tutorial problems

I have been working through Hartl’s tutorials and am in chapter
almost done with it but have found a couple problems and am at a
for solving them.
First, prior to trying to add the ability to edit admin status all
tests were passing and if i take that one test out they pass again…

  1. I noticed today that when i do a user delete, it redirects to
    deleted users profile page like it’s supposed to but the user is
    deleted from the database. no errors are displayed…
  2. When i try to delete a micropost i get a message saying "No
    matches [GET] “/microposts/302"” I found a reference on
    for someone who had the same problem and solved it but I didn’t get
    any relief from it on my side.
  3. I wanted to add the ability to set and unset the admin field in
    database for a user so i added a checkbox to the user edit page.
    checkbox shows up and has the correct value (which i thought was a
    pretty good achievement :)) and i wanted to write a test to ensure
    that my update works but i don’t know how to set the checkbox
    programatically in the test. I’m putting it in the users_spec.rb
    realize that i’m not doing it as elegantly as i should but I’m not
    worried about that as i am the mechanics of what is happening as
    trying to learn here. I’ve pushed my code up to github and tagged
    commit with “admin-problem” in case anyone wants to check it
    it’s at: [email protected]:aamax/sample_app.git
    I’d love some help with this… am feeling like i’ve been picking
    ruby and rails pretty well, long way to go, but i’ve hit these
    walls and spent a ton of time on it. thanks in advance.


On number 2 below, I took a look at your code and it seems that it is
trying to redirect to the deleted micropost with the
‘redirect_back_or…’ call in the controller. Not totally sure why it
is giving you grief, but of course you could use some conditional
logic to see if the delete succeeds and redirect to root if it does,
otherwise send them back (the old-fashioned way). It would be more
explicit, too. Best of luck and whatever you do, don’t give up! :slight_smile: