Created
June 11, 2014 12:46
-
-
Save walidvb/e87e6a94a21286c3d95c to your computer and use it in GitHub Desktop.
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 BooksController < ApplicationController | |
before_filter do |controller| | |
#binding.pry | |
if(Book.find_by_slug(params[:id]).published? && current_user.is_admin?) | |
flash[:warning] = "Please login as admin to view this page" | |
redirect_to root_path | |
end | |
end | |
def show | |
@book = Book.find_by_slug(params[:id]) or raise "No such book '#{params[:id]}'" | |
@comments = @book.comments.reversed_nested_set.with_state([:draft, :published]) | |
end | |
def subscribed | |
@book = Book.find_by_slug(params[:id]) or raise "No such book '#{params[:id]}'" | |
end | |
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
Scenario: Book is private | |
Given there is a published book | |
And the book is private | |
When I visit the book | |
Then I should be on the home page |
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
When(/^I visit the book$/) do | |
# no online reader for now | |
visit book_path(Book.first) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment