Skip to content

Instantly share code, notes, and snippets.

@Marchino
Created September 13, 2011 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Marchino/1213831 to your computer and use it in GitHub Desktop.
Save Marchino/1213831 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe "Question", :search => true do
before(:each) do
@buyer = Buyer.first
@item = RareBook.first
host! 'mmplus.dev'
Capybara.app_host = "http://mmplus.dev"
reset_email
end
context "if user is not logged in" do
it "shouldn't be able to access question page without being logged in" do
visit new_rare_book_question_path(:title => @item.to_url_param, :id => @item.id)
page.should have_content I18n.t('devise.failure.unauthenticated')
end
end
context "if user is logged in" do
before(:each) do
login_user(@buyer.username, @buyer.username)
save_and_open_page
end
after(:each) do
logout_user
end
it "a question should not be created without free text if item faq does require it" do
visit new_rare_book_question_path(:title => @item.to_url_param, :id => @item.id)
select "generica", :from => "question_item_faq_id"
click_button "question_submit"
page.should_not have_content I18n.t('questions.created')
end
it "a question should not be created without free text if item faq does require it" do
visit new_rare_book_question_path(:title => @item.to_url_param, :id => @item.id)
select "generica", :from => "question_item_faq_id"
fill_in "question_free_text", :with => 'random and absolutely malicious text'
click_button "question_submit"
Sunspot.commit
page.should have_content I18n.t('questions.created')
end
it "a question should be created without free text if item faq doesn't require it" do
visit new_rare_book_question_path(:title => @item.to_url_param, :id => @item.id)
select "sconto?", :from => "question_item_faq_id"
click_button "question_submit"
Sunspot.commit
page.should have_content I18n.t('questions.created')
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment