Permalink
Browse files

Support presenter spec

  • Loading branch information...
1 parent 0cabcee commit a0d2ed1dfdb6e45543a6d9a5e810eac47fe3dc8f @ArturG ArturG committed Mar 4, 2014
Showing with 47 additions and 2 deletions.
  1. +2 −2 app/presenters/support_presenter.rb
  2. +45 −0 spec/presenters/support_presenter_spec.rb
@@ -18,14 +18,14 @@ def collection_path
end
def edit_resource_path
- edit_support_question_path
+ edit_support_question_path(@support_question)
end
def resource_path(question)
if question
support_question_path(question)
else
- support_question_path(@question)
+ support_question_path(@support_question)
end
end
@@ -0,0 +1,45 @@
+require 'spec_helper'
+
+describe SupportPresenter do
+
+ let(:question){Fabricate(:question)}
+ let(:another_question){Fabricate(:question, :id => 'AnotherID')}
+
+ before do
+ @sp = SupportPresenter.new(question)
+ end
+
+ context 'page_title' do
+ it 'returns support questions title' do
+ @sp.page_title.should == 'Support Questions'
+ end
+ end
+
+ context 'collection_path' do
+ it 'returns support questions_path' do
+ @sp.collection_path.should == '/support/questions'
+ end
+ end
+
+ context 'edit_resource_path' do
+ it 'returns edit_support_question_path' do
+ @sp.edit_resource_path.should == '/support/questions/RandomID/edit'
+ end
+ end
+
+ context 'new_resource_path' do
+ it 'returns new_support_question_path' do
+ @sp.new_resource_path.should == '/support/questions/new'
+ end
+ end
+
+ context 'resource_path' do
+ it 'returns self question path if nil' do
+ @sp.resource_path(nil).should == '/support/questions/RandomID'
+ end
+
+ it 'returns question path if not nil' do
+ @sp.resource_path(another_question).should == '/support/questions/AnotherID'
+ end
+ end
+end

0 comments on commit a0d2ed1

Please sign in to comment.