b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornbergerrequire 'spec_helper'
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornbergerdescribe CommentsController do
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger
ee5342a8882c2fc7631fcffb5497e6597747887cTim Reddehase let(:ontology){ create :ontology }
ee5342a8882c2fc7631fcffb5497e6597747887cTim Reddehase let(:repository){ ontology.repository }
ee5342a8882c2fc7631fcffb5497e6597747887cTim Reddehase let(:user){ create :user }
ee5342a8882c2fc7631fcffb5497e6597747887cTim Reddehase
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger context 'not signed in' do
ee5342a8882c2fc7631fcffb5497e6597747887cTim Reddehase
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger context 'on GET to index' do
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger context 'without comment' do
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger before do
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger get :index, :ontology_id => ontology.to_param, :repository_id => repository.to_param
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger end
ee5342a8882c2fc7631fcffb5497e6597747887cTim Reddehase
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger it{ should respond_with :success }
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger it{ should render_template 'comments/index' }
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger end
ee5342a8882c2fc7631fcffb5497e6597747887cTim Reddehase
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger context 'with comment' do
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger before do
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger comment = create :comment, :commentable => ontology
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger get :index, :ontology_id => ontology.to_param, :repository_id => repository.to_param
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger end
ee5342a8882c2fc7631fcffb5497e6597747887cTim Reddehase
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger it{ should respond_with :success }
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger it{ should render_template 'comments/index' }
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger end
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger end
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger end
ee5342a8882c2fc7631fcffb5497e6597747887cTim Reddehase
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger context 'signed in' do
ee5342a8882c2fc7631fcffb5497e6597747887cTim Reddehase
23305f217b86a2ebf90a848af9036908e0070542Eugen Kuksa before { sign_in user }
ee5342a8882c2fc7631fcffb5497e6597747887cTim Reddehase
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger context 'on GET to index' do
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger context 'without comment' do
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger before do
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger get :index, :ontology_id => ontology.to_param, :repository_id => repository.to_param
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger end
ee5342a8882c2fc7631fcffb5497e6597747887cTim Reddehase
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger it{ should respond_with :success }
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger it{ should render_template 'comments/index' }
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger end
ee5342a8882c2fc7631fcffb5497e6597747887cTim Reddehase
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger context 'with comment' do
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger before do
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger comment = create :comment, :commentable => ontology
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger get :index, :ontology_id => ontology.to_param, :repository_id => repository.to_param
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger end
ee5342a8882c2fc7631fcffb5497e6597747887cTim Reddehase
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger it{ should respond_with :success }
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger it{ should render_template 'comments/index' }
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger end
ee5342a8882c2fc7631fcffb5497e6597747887cTim Reddehase
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger context 'on POST to delete' do
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger before do
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger comment = create :comment, :commentable => ontology, :user => user
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger xhr :delete, :destroy, :ontology_id => ontology.to_param, :repository_id => repository.to_param, :id => comment.id
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger end
ee5342a8882c2fc7631fcffb5497e6597747887cTim Reddehase
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger it{ should respond_with :success }
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger end
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger end
ee5342a8882c2fc7631fcffb5497e6597747887cTim Reddehase
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger context 'on POST to create' do
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger context 'with too short text' do
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger before do
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger xhr :post, :create,
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger ontology_id: ontology.to_param,
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger repository_id: repository.to_param,
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger comment: {text: 'foo'}
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger end
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger it{ should respond_with :unprocessable_entity }
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger end
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger context 'with too enough text' do
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger before do
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger xhr :post, :create,
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger ontology_id: ontology.to_param,
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger repository_id: repository.to_param,
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger comment: {text: 'fooo baaaaaaaaaaaaaaar'}
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger end
ee5342a8882c2fc7631fcffb5497e6597747887cTim Reddehase
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger it{ should respond_with :success }
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger end
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger end
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger end
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornberger
b8a8f5a9b535f39bf9f1b00ec2983bd610bb2373Julian Kornbergerend