Skip to content
This repository has been archived by the owner on Mar 12, 2021. It is now read-only.

Commit

Permalink
answer_group show view improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
robmckinnon committed Apr 24, 2008
1 parent 8c51dd5 commit 86b606e
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
9 changes: 9 additions & 0 deletions app/helpers/answer_groups_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,13 @@ def link_to_source_file group
def question_introduction question
"<span class='asking_member'>#{question.member}</span> asked Her Majesty's Government:"
end

def answering_member answer
answering = ["<span class='answering'>"]
answering << "<span class='role'>#{answer.role}</span> (" if answer.role
answering << "<span class='member'>#{answer.member}</span>"
answering << ")" if answer.role
answering << ":</span>"
answering.join('')
end
end
2 changes: 1 addition & 1 deletion app/views/answer_groups/index.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%h1 Written Answers
- @title = 'Written Answers'

%table
%tbody
Expand Down
3 changes: 2 additions & 1 deletion app/views/answer_groups/show.haml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
= question_introduction(question)
%blockquote
= question.text
- answer
= answering_member(answer)
= answer.text
= link_to 'Back', answer_groups_path
13 changes: 6 additions & 7 deletions app/views/layouts/application.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
%html
%head
%title Lords Q+A
<link rel="stylesheet" href="http://yui.yahooapis.com/2.5.1/build/reset-fonts-grids/reset-fonts-grids.css" type="text/css">
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.5.1/build/assets/skins/sam/skin.css">
<style type="text/css">#custom-doc { width: 66%; min-width: 740px; font-size:138.5%}</style>
- # %link{ :rel=>"stylesheet", :href=>"http://yui.yahooapis.com/2.5.1/build/reset-fonts-grids/reset-fonts-grids.css", :type=>"text/css" }
- # %link{ :rel=>"stylesheet", :type=>"text/css", :href=>"http://yui.yahooapis.com/2.5.1/build/assets/skins/sam/skin.css" }
%style{ :type=>"text/css"}
= "#custom-doc { width: 66%; min-width: 740px; font-size: 1.3em; margin-left: 5em}"
= ".asking_member, .answering { font-weight: bold }"
%body
#custom-doc.yui-t7
#hd
%h1 Title
%h1= @title
#bd
%div.yui-g
= yield
#ft
Footer


10 changes: 10 additions & 0 deletions spec/helpers/answer_groups_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,14 @@
question = mock_model(Question, :member => 'member')
question_introduction(question).should == "<span class='asking_member'>member</span> asked Her Majesty's Government:"
end

it 'should format answering member role and name' do
answer = mock_model(Answer, :role => 'role', :member => 'member')
answering_member(answer).should == "<span class='answering'><span class='role'>role</span> (<span class='member'>member</span>):</span>"
end

it 'should format answering member role and name' do
answer = mock_model(Answer, :member => 'member', :role => nil)
answering_member(answer).should == "<span class='answering'><span class='member'>member</span>:</span>"
end
end

0 comments on commit 86b606e

Please sign in to comment.