<commit_before>require 'rails_helper'
require 'database_cleaner'

DatabaseCleaner.strategy = :truncation
RSpec.describe CommentsController, type: :controller  do
	describe 'Routes' do
		it 'access methods routes with success' do
			expect(:post => '/comment').to route_to(:controller => "comments",
 				 :action => "create")
			expect(:get => '/comment/delete').to route_to(:controller => "comments",
 				 :action => "destroy")
		end
	end
	describe 'Acess instance variables' do
		context 'into create method,' do 
			before(:all) do
				@user = User.create(:id => 1, :name => "admin", :login => "admin", :password => "<PASSWORD>", :password_confirmation => "<PASSWORD>", :email => "<EMAIL>",
				:gender => "m", :admin => true, :active => true, :dateBirthday =>"10-01-1990",
				:uf_id => "1")
				@topic  = Topic.create()
			end

			before('comment should be deleted') do
				@comment = Comment.create(:description => 'test', :topic_id => @topic.id, :user_id => @user.id)
			end
			
			it 'comment should be created' do

				expect(post :create,{:comment =>  {:description => 'test', :user_id => @user.id,
					:topic_id => @topic.id}}).to redirect_to(Topic.find(@topic.id))
			end

			it 'comment should be deleted' do

				expect(get :destroy, {:format => @comment.id}).to redirect_to(Topic.find(@topic.id))
				
			end
		end

	end
end
DatabaseCleaner.clean<commit_msg>"Comments controller is covered 100% by unified tests. Now testing for edit method"<commit_after>require 'rails_helper'
require 'comments_controller'
require 'database_cleaner'

DatabaseCleaner.strategy = :truncation
RSpec.describe CommentsController, type: :controller  do
	describe 'Routes' do
		it 'access methods routes with success' do
			expect(:post => '/comment').to route_to(:controller => "comments",
 				 :action => "create")
			expect(:post => '/comment/edit').to route_to(:controller => "comments",
 				 :action => "edit")
			expect(:get => '/comment/delete').to route_to(:controller => "comments",
 				 :action => "destroy")
		end
	end
	describe 'Acess instance variables' do
		before(:each) do
			@user = User.create(:id => 1, :name => "admin", :login => "admin", :password => "<PASSWORD>", :password_confirmation => "<PASSWORD>", :email => "<EMAIL>",
			:gender => "m", :admin => true, :active => true, :dateBirthday =>"10-01-1990",
			:uf_id => "1")
			@topic  = Topic.create()
		end
		before(:each) do
			@comment = Comment.create(:description => 'test', :topic_id => @topic.id, :user_id => @user.id)
		end
		context 'into create method,' do 

			
			it 'comment should be created' do

				expect(post :create,{:comment =>  {:description => 'test', :user_id => @user.id,
					:topic_id => @topic.id}}).to redirect_to(Topic.find(@topic.id))
			end
		end
		context 'into edit method,' do

			it 'comment should be edited' do

				expect(post :edit, comment: {   comment_id: @comment.id, 
												new_description: 'new description'}).to redirect_to(Topic.find(@comment.topic))
			end
		end

		context 'into delete method' do
			
			it 'comment should be deleted' do

				expect(get :destroy, {:format => @comment.id}).to redirect_to(Topic.find(@topic.id))
				
			end
		end

	end
end
DatabaseCleaner.clean
{'fraction_non_alphanumeric': 0.16396002498438475, 'fraction_numerical': 0.007183010618363523, 'mean_word_length': 3.9505409582689337, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 62, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7579712', 'n_tokens_mistral': 1192, 'n_tokens_neox': 999, 'n_words': 280}