blogs functiontest fix

This commit is contained in:
yafeilee 2014-03-31 13:51:46 +08:00
parent fd805df5aa
commit e50cfaadb1
1 changed files with 5 additions and 4 deletions

View File

@ -65,19 +65,20 @@ describe BlogsController do
describe "get SHOW" do describe "get SHOW" do
it "#prev, #next" do it "#prev, #next" do
posts = create_list(:post_list, 3) posts = create_list(:post_list, 3)
posts = Post.order_by(created_at: 'asc')
selected = posts[1] selected = posts[1]
s_prev = posts[2] s_prev = posts[0]
s_next = posts[1] s_next = posts[2]
get :show, id: selected.id get :show, id: selected.id
expect(assigns(:prev)).to eq(s_prev) expect(assigns(:prev)).to eq(s_prev)
expect(assigns(:next)).to eq(s_next) expect(assigns(:next)).to eq(s_next)
selected = posts[2] selected = posts[0]
get :show, id: selected.id get :show, id: selected.id
expect(assigns(:prev)).to be_nil expect(assigns(:prev)).to be_nil
expect(assigns(:next)).to eq(posts[1]) expect(assigns(:next)).to eq(posts[1])
selected = posts[0] selected = posts[2]
get :show, id: selected.id get :show, id: selected.id
expect(assigns(:prev)).to eq(posts[1]) expect(assigns(:prev)).to eq(posts[1])
expect(assigns(:next)).to be_nil expect(assigns(:next)).to be_nil