Skip to content

Commit

Permalink
fix specs ,ad factory_girl and make some style
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas committed May 1, 2009
1 parent 43fb3cf commit cb5437e
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 13 deletions.
4 changes: 3 additions & 1 deletion app/views/answers/_answer.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
%p= link_to(t('action.flag'), new_answer_flag_path(@question) , :rel => 'facebox')
= render :partial => 'common/vote_box' , :locals => {:model => answer}
= link_to((answer.selected ? t('answer.selected') : t('answer.unselected')) , select_answer_path(answer) , :id => "answer_link_#{answer.id}" , :class => "select_answer_link #{answer.selected ? 'selected' : 'unselected'}")

- if answer.user == current_user
%p.owner_links
= link_to(t('app.edit') , edit_answer_path(answer))
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
= yield
#sidebar
.content_box
%h2 HINTS
%h2= t('app.tips')
.content_box
= render :partial => '/layouts/cloud'
.content_box
Expand Down
6 changes: 4 additions & 2 deletions app/views/questions/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
%h2.title= @question.title
%p.body= @question.body
%p.tags= tag_links(@question.tag_list)
= render :partial => 'common/user_box' , :locals => {:user => @question.user}
= render :partial => 'common/user_box' , :locals => {:user => @question.user}
= render :partial => 'common/vote_box' , :locals => {:model => @question}
%p{:id => "flag_for_question_#{@question.id}"}
= link_to(t('action.flag') , new_question_flag_path(@question) , :rel => 'facebox')

- if @question.user == current_user
%p.owner_links
= link_to(t('app.edit') , edit_question_path(@question))
#answers
= link_to(t('action.answer'), '#' , :class => 'answer_new_form_link')
%div{:id => 'answer_new_form_box'}
Expand Down
4 changes: 3 additions & 1 deletion config/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
# config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
# config.gem "sqlite3-ruby", :lib => "sqlite3"
config.gem 'mislav-will_paginate', :lib => 'will_paginate', :source => 'http://gems.github.com'
config.gem 'nokogiri'
config.gem "thoughtbot-factory_girl",
:lib => "factory_girl",
:source => "http://gems.github.com"

# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named
Expand Down
6 changes: 4 additions & 2 deletions config/locales/es_AR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@
profile: Perfil
new_question: Nueva Pregunta
search: Buscar
edit: Editar
tips: Tips
flash:
notice:
application:
Expand All @@ -220,8 +222,8 @@
valid: La pregunta ha sido actualizada
invalid: La pregunta NO ha sido actualizada
vote:
valid: Tu voto NO a sido guardado
invalid: Tu voto a sido guardado
valid: Tu voto a sido guardado
invalid: Tu voto NO a sido guardado
update: Tu voto ha sido actualizado
nochange: Ya has votado esta pregunta
answer:
Expand Down
5 changes: 5 additions & 0 deletions spec/factories/question.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Factory.define(:question) do |f|
f.title "title"
f.body "body"
f.association :user
end
6 changes: 6 additions & 0 deletions spec/factories/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Factory.define(:user) do |f|
f.sequence(:login) {|n| "test#{n}"}
f.password 'abc123'
f.sequence(:email) { |n| "test#{n}@test.com"}
f.password_confirmation {|p| p.password}
end
6 changes: 3 additions & 3 deletions spec/models/answer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
before(:each) do
@valid_attributes = {
:body => "value for body",
:user => mock_model(User),
:question => mock_model(Question)
:user => Factory(:user),
:question => Factory(:question)
}
end

Expand Down Expand Up @@ -76,7 +76,7 @@
@new_selected_answer.reload.selected.should == true
end
it "should the question flagged as answered" do
@new_selected_answer.quetion.answered.should == true
@new_selected_answer.question.answered.should == true
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/models/question_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
@valid_attributes = {
:title => "What is the best Framework?",
:body => "body for description",
:user => mock_model(User),
:user => Factory(:user),
:votes_average => 0
}
end
Expand Down
4 changes: 2 additions & 2 deletions spec/models/vote_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
describe Vote do

before(:each) do
@voteable = Question.create(:title => 'title' , :body => 'body' , :user => mock_model(User))
@voteable = Factory(:question)
@valid_attributes = {
:vote => 1,
:voteable => @voteable,
:user => mock_model(User)
:user => Factory(:user)
}
end

Expand Down

0 comments on commit cb5437e

Please sign in to comment.