Permalink
Browse files

Extract Decorator Step Five

* Rename method to follow component API
  • Loading branch information...
jferris committed Feb 21, 2013
1 parent 72801b5 commit 61ca6784af2206ddd47be2013402188c7e5f0733
@@ -10,7 +10,7 @@ class Survey < ActiveRecord::Base
def summaries_using(summarizer, options = {})
questions.map do |question|
UnansweredQuestionHider.new(summarizer, options[:answered_by]).
summary_or_hidden_answer(question)
summarize(question)
end
end
end
@@ -6,7 +6,7 @@ def initialize(summarizer, user)
@user = user
end

def summary_or_hidden_answer(question)
def summarize(question)
if hide_unanswered_question?(question)
hide_answer_to_question(question)
else
@@ -1,13 +1,13 @@
require 'spec_helper'

describe UnansweredQuestionHider, '#summary_or_hidden_answer' do
describe UnansweredQuestionHider, '#summarize' do
it 'returns a hidden summary given a user without an answer' do
summarizer = stub('summarizer')
user = build_stubbed(:user)
question = stub_answered_question(user, false)
hider = UnansweredQuestionHider.new(summarizer, user)

result = hider.summary_or_hidden_answer(question)
result = hider.summarize(question)

result.title.should eq question.title
result.value.should eq UnansweredQuestionHider::NO_ANSWER
@@ -20,7 +20,7 @@
summarizer = stub_summarizer(question, summary)
hider = UnansweredQuestionHider.new(summarizer, user)

result = hider.summary_or_hidden_answer(question)
result = hider.summarize(question)

result.should eq summary
end
@@ -31,7 +31,7 @@
summarizer = stub_summarizer(question, summary)
hider = UnansweredQuestionHider.new(summarizer, nil)

result = hider.summary_or_hidden_answer(question)
result = hider.summarize(question)

result.should eq summary
end

0 comments on commit 61ca678

Please sign in to comment.