Commits

heliostatic committed 4c4e046

Some cleanup

Comments (0)

Files changed (5)

app/controllers/books_controller.rb

     end
   end
 
-  def edit
-  end
-
   def destroy
     book = Book.find(params[:id])
     next_book = book.next
     redirect_to :index
   end
 
-  def new
-  end
-
-  def create
-  end
-
   def update
     @book = Book.find params[:id]
 

app/models/book.rb

 
   has_paper_trail
 
+  # Should move this out
   def next
     Book.where("books.id > ?", self.id).order("books.id ASC").limit(1).first
   end
 
+  # Should move this out
   def previous
     Book.where("books.id < ?", self.id).order("books.id DESC").limit(1).last
   end

test/functional/books_controller_test.rb

     assert_response :unauthorized
   end 
 
-  it "can get a page after authenticating" do
-    @request.env["HTTP_AUTHORIZATION"] = "Basic " + Base64::encode64("books:books")
-    get :index
-    assert_response :success
+  describe 'authentication' do
+    before { authenticate_user }
+
+    it "can get a page after authenticating" do
+      get :index
+      assert_response :success
+    end
   end
 end

test/integration/books_pages_test.rb

+# class BooksPagesTest < ActionDispatch::IntegrationTest
+# end

test/test_helper.rb

   # -- they do not yet inherit this setting
   fixtures :all
 
-  # Add more helper methods to be used by all tests here...
+  def authenticate_user
+    @request.env["HTTP_AUTHORIZATION"] = "Basic " + Base64::encode64("books:books")
+  end
 end