fixed question generator not working if privacy_allow_anonymous_questions is false (GitHub issue #71)
This commit is contained in:
parent
8ff92dca15
commit
b26ec1dd0b
|
@ -3,7 +3,7 @@ class Inbox < ActiveRecord::Base
|
|||
belongs_to :question
|
||||
|
||||
before_create do
|
||||
raise "User does not want to receive anonymous questions" if self.question.author_is_anonymous and !self.user.privacy_allow_anonymous_questions?
|
||||
raise "User does not want to receive anonymous questions" if self.question.author_is_anonymous and self.question.author_name != 'justask' and !self.user.privacy_allow_anonymous_questions?
|
||||
end
|
||||
|
||||
def answer(answer_content, user)
|
||||
|
|
|
@ -60,6 +60,27 @@ feature "Inbox", :devise do
|
|||
page.driver.render Rails.root.join("tmp/#{Time.now.to_i}_2.png"), full: true
|
||||
end
|
||||
|
||||
# Scenario: User with privacy options generates new question
|
||||
# Given I am signed in
|
||||
# When I visit the inbox
|
||||
# And I click "Get new question"
|
||||
# And I don't want to receive questions by anonymous users
|
||||
# Then I get a new question
|
||||
scenario 'user with privacy options generates new question', js: true do
|
||||
me = FactoryGirl.create :user
|
||||
me.privacy_allow_anonymous_questions = false
|
||||
me.save
|
||||
|
||||
login_as me, scope: :user
|
||||
visit inbox_path
|
||||
page.driver.render Rails.root.join("tmp/#{Time.now.to_i}_1.png"), full: true
|
||||
|
||||
click_button "Get new question"
|
||||
wait_for_ajax
|
||||
expect(page).to have_text('Answer'.upcase)
|
||||
page.driver.render Rails.root.join("tmp/#{Time.now.to_i}_2.png"), full: true
|
||||
end
|
||||
|
||||
=begin
|
||||
# Scenario: User deletes a question
|
||||
# Given I am signed in
|
||||
|
|
Loading…
Reference in New Issue