Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class RatingsController < ApplicationController
- before_filter :require_user_json
- def create
- @rating = Rating.new(:rating => params[:rating])
- @rating.user = current_user
- @rating.album = Album.find(params[:id])
- @rating.save!
- render :json => {}.to_json
- end
- end
- describe RatingsController
- before(:all) do
- @valid_user = User.make(:login => 'ratings_user')
- end
- after(:all) do
- @valid_user.destroy
- end
- describe "create" do
- it "should create a rating if you don't already have one" do
- activate_authlogic
- UserSession.create(@valid_user)
- album = mock_model(Album, :null_object => true)
- Album.should_receive(:find).with('1').and_return(album)
- xhr :post,
- :create,
- :id => 1,
- :rating => 5
- assigns[:rating].should be_valid
- response.code.should == '200'
- end
- end
- end
Add Comment
Please, Sign In to add comment