Merge pull request #4916 from hpetru/validate-poll-answer

I added the validation to poll question and poll answer

Conflicts:
	app/assets/javascripts/app/views/publisher_view.js
This commit is contained in:
Jonne Haß
2014-05-24 17:42:18 +02:00
11 changed files with 118 additions and 18 deletions

View File

@@ -51,4 +51,11 @@ describe('app.views.PublisherPollCreator', function(){
expect(this.view.$(remove_btn).hasClass('active')).toBe(false);
});
});
describe('#validateInput', function(){
it('should invalid blank value', function(){
var input = this.view.$('input');
input.val(' ');
expect(this.view.validateInput(input)).toBe(false);
}):
});
});

View File

@@ -18,4 +18,17 @@ describe PollAnswer do
end
end
describe 'validation' do
it 'should validate pressence of answer' do
answer = PollAnswer.new
answer.valid?
answer.errors.should have_key(:answer)
end
it 'answer should not empty' do
answer = PollAnswer.new answer: ' '
answer.valid?
answer.errors.should have_key(:answer)
end
end
end

View File

@@ -16,5 +16,11 @@ describe Poll do
@poll.poll_answers.build(:answer => '2')
@poll.should be_valid
end
it 'should not create a poll when question in blank' do
@poll.question = ' '
@poll.valid?
@poll.errors.should have_key(:question)
end
end
end
end