This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 let(:stories) { 2.times.map { Factory.create :story } } | |
23 it "should get all stories" do | |
24 @admin = Factory(:user, :email => "admin@test.com", :admin => true) | |
25 User.all.each { |u| puts u.inspect } | |
26 test_sign_in(@admin) | |
27 get 'admin' | |
28 assigns(:stories).should eq(stories) | |
29 end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let(:stories) { 2.times.map { Story.create } } | |
it "should get all of them" do | |
stories = Story.all | |
assigns(:stories).should == stories | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
context "for logged in user" do | |
before do | |
@user = Factory(:user) | |
@story = Factory(:story) | |
@user.follow! @story | |
end | |
it "should set turn if it's not set" do | |
get :show, :id => 1 | |
assigns(:turn).should == "Mike Hoxhuge" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 class PhrasesController < ApplicationController | |
2 before_filter :authenticate, :only => [:create, :destroy] | |
3 | |
4 def create | |
5 @phrase = @story.phrases.build(params[:phrase]) | |
6 if @phrase.save | |
7 flash[:success] = "Micropost created!" | |
8 redirect_to @story | |
9 else | |
10 render 'pages/home' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MicropostsController < ApplicationController | |
before_filter :authenticate, :only => [:create, :destroy] | |
before_filter :authorized_user, :only => :destroy | |
. | |
. | |
. | |
def destroy | |
@micropost.destroy | |
redirect_back_or root_path | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SessionsController < ApplicationController | |
def new | |
@title = "Sign in" | |
end | |
def create | |
user = User.authenticate(params[:session][:email], | |
params[:session][:password]) | |
if user.nil? | |
flash.now[:error] = "Invalid email/password combination." |