Actualizar plugin Questions a 1.0.2 light

This commit is contained in:
Manuel Cillero 2020-11-22 21:40:10 +01:00
parent b9e569d03f
commit b37d1305f1
64 changed files with 394 additions and 229 deletions

View file

@ -9,4 +9,10 @@ answer_002:
content: This is answer for question_002
question_id: 2
author_id: 1
accepted: false
accepted: false
answer_003:
id: 3
content: This is a second answer for question_001
question_id: 1
author_id: 3
accepted: false

View file

@ -0,0 +1,10 @@
section_001:
id: 1
name: Open
color: green
is_closed: false
section_002:
id: 2
name: Closed
color: red
is_closed: true

View file

@ -3,7 +3,7 @@
# This file is a part of Redmine Q&A (redmine_questions) plugin,
# Q&A plugin for Redmine
#
# Copyright (C) 2011-2018 RedmineUP
# Copyright (C) 2011-2020 RedmineUP
# http://www.redmineup.com/
#
# redmine_questions is free software: you can redistribute it and/or modify
@ -79,7 +79,7 @@ class QuestionsAnswersControllerTest < ActionController::TestCase
assert_redirected_to :controller => 'questions',
:action => 'show',
:id => question,
:anchor => "question_item_#{QuestionsAnswer.order(:id).last.id}"
:anchor => "questions_answer_#{QuestionsAnswer.order(:id).last.id}"
assert_equal old_answer_count + 1, question.answers.count
assert_equal 'Answer for the first question', question.answers.last.content
end
@ -92,11 +92,7 @@ class QuestionsAnswersControllerTest < ActionController::TestCase
:content => "Previewed answer",
}
assert_response :success
assert_select 'fieldset' do
assert_select 'legend', :text => 'Preview'
assert_select 'p', :text => 'Previewed answer'
end
assert_select 'p', :text => 'Previewed answer'
end
def test_preview_edited_answer
@ -107,11 +103,7 @@ class QuestionsAnswersControllerTest < ActionController::TestCase
:content => "Previewed answer 1",
}
assert_response :success
assert_select 'fieldset' do
assert_select 'legend', :text => 'Preview'
assert_select 'p', :text => 'Previewed answer 1'
end
assert_select 'p', :text => 'Previewed answer 1'
end
def test_destroy
@ -121,7 +113,7 @@ class QuestionsAnswersControllerTest < ActionController::TestCase
assert_difference 'QuestionsAnswer.count', -1 do
compatible_request :post, :destroy, :id => answer.id
end
assert_redirected_to question_path(answer.question, :anchor => "question_item_#{answer.id}")
assert_redirected_to question_path(answer.question, :anchor => "questions_answer_#{answer.id}")
assert_nil QuestionsAnswer.find_by_id(answer.id)
end
@ -144,6 +136,6 @@ class QuestionsAnswersControllerTest < ActionController::TestCase
}
# assert_response :success
answer.reload
assert !answer.accepted, "Mark as officail answer did set for answer after update for user without permission"
assert !answer.accepted, "Mark as official answer did set for answer after update for user without permission"
end
end

View file

@ -3,7 +3,7 @@
# This file is a part of Redmine Q&A (redmine_questions) plugin,
# Q&A plugin for Redmine
#
# Copyright (C) 2011-2018 RedmineUP
# Copyright (C) 2011-2020 RedmineUP
# http://www.redmineup.com/
#
# redmine_questions is free software: you can redistribute it and/or modify
@ -22,8 +22,8 @@
require File.expand_path('../../test_helper', __FILE__)
class QuestionsCommentsControllerTest < ActionController::TestCase
fixtures :users,
:projects,
fixtures :users,
:projects,
:roles,
:members,
:member_roles,
@ -38,7 +38,7 @@ class QuestionsCommentsControllerTest < ActionController::TestCase
:issue_categories,
:enabled_modules,
:workflows,
:questions,
:questions,
:questions_answers,
:questions_sections

View file

@ -3,7 +3,7 @@
# This file is a part of Redmine Q&A (redmine_questions) plugin,
# Q&A plugin for Redmine
#
# Copyright (C) 2011-2018 RedmineUP
# Copyright (C) 2011-2020 RedmineUP
# http://www.redmineup.com/
#
# redmine_questions is free software: you can redistribute it and/or modify
@ -22,8 +22,8 @@
require File.expand_path('../../test_helper', __FILE__)
class QuestionsControllerTest < ActionController::TestCase
fixtures :users,
:projects,
fixtures :users,
:projects,
:roles,
:members,
:member_roles,
@ -40,14 +40,13 @@ class QuestionsControllerTest < ActionController::TestCase
:attachments,
:workflows,
:time_entries,
:questions,
:questions_answers,
:questions,
:questions_answers,
:questions_sections
fixtures :email_addresses if ActiveRecord::VERSION::MAJOR >= 4
RedmineQuestions::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_questions).directory + '/test/fixtures/',
[:tags, :taggings, :comments])
RedmineQuestions::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_questions).directory + '/test/fixtures/', [:tags, :taggings, :comments])
def setup
RedmineQuestions::TestCase.prepare
@ -77,6 +76,34 @@ class QuestionsControllerTest < ActionController::TestCase
assert_select 'p.breadcrumb'
end
def test_get_new
@request.session[:user_id] = 1
compatible_request :get, :new, project_id: @project
assert_select 'input#question_subject'
assert_select 'select#question_section_id'
assert_select 'input[type=?]', 'submit'
end
def test_get_edit
@request.session[:user_id] = 1
compatible_request :get, :edit, id: 1
assert_select 'input#question_subject'
assert_select 'select#question_section_id'
assert_select 'input[type=?]', 'submit'
end
def test_post_create_failed
@request.session[:user_id] = 1
compatible_request :post, :create, :project_id => @project,
:question => {
:content => "Body of text"
}
assert_response :success
end
def test_post_create
@request.session[:user_id] = 1
ActionMailer::Base.deliveries.clear
@ -118,7 +145,7 @@ class QuestionsControllerTest < ActionController::TestCase
assert_select 'div#reply'
assert_select 'a.icon-del'
assert_select 'a.add-comment-link'
assert_select 'span.items', {:text => "(1-1/1)"}
assert_select 'span.items', {:text => "(1-2/2)"}
@dev_role.permissions << :add_answers
@dev_role.save
@request.session[:user_id] = 3
@ -164,20 +191,17 @@ class QuestionsControllerTest < ActionController::TestCase
end
assert_redirected_to questions_path(:section_id => question.section)
assert_nil Question.find_by_id(question.id)
end
end
def test_preview_new_question
@request.session[:user_id] = 1
question = questions(:question_001)
compatible_xhr_request :post, :preview,
compatible_xhr_request :post, :preview,
:question => {
:content => "Previewed question",
}
assert_response :success
assert_select 'fieldset' do
assert_select 'legend', :text => 'Preview'
assert_select 'p', :text => 'Previewed question'
end
assert_select 'p', :text => 'Previewed question'
end
def test_update_question

View file

@ -3,7 +3,7 @@
# This file is a part of Redmine Q&A (redmine_questions) plugin,
# Q&A plugin for Redmine
#
# Copyright (C) 2011-2018 RedmineUP
# Copyright (C) 2011-2020 RedmineUP
# http://www.redmineup.com/
#
# redmine_questions is free software: you can redistribute it and/or modify

View file

@ -0,0 +1,93 @@
# encoding: utf-8
#
# This file is a part of Redmine Q&A (redmine_questions) plugin,
# Q&A plugin for Redmine
#
# Copyright (C) 2011-2020 RedmineUP
# http://www.redmineup.com/
#
# redmine_questions is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_questions is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_questions. If not, see <http://www.gnu.org/licenses/>.
require File.expand_path('../../test_helper', __FILE__)
class QuestionsStatusesControllerTest < ActionController::TestCase
fixtures :users,
:projects,
:roles,
:members,
:member_roles,
:trackers,
:enumerations,
:projects_trackers,
:issues,
:issue_statuses,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules,
:workflows,
:questions,
:questions_answers,
:questions_sections
fixtures :email_addresses if ActiveRecord::VERSION::MAJOR >= 4
RedmineQuestions::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_questions).directory + '/test/fixtures/', [:questions,
:questions_answers,
:questions_sections,
:questions_statuses])
def setup
RedmineQuestions::TestCase.prepare
@project = Project.find(1)
User.current = nil
end
def test_new
@request.session[:user_id] = 1
compatible_request :get, :new
assert_response :success
assert_select 'input#questions_status_name'
assert_select 'input[type=?]', 'submit'
end
def test_create
@request.session[:user_id] = 1
assert_difference 'QuestionsStatus.count' do
compatible_request :post, :create, questions_status: { name: 'Test status', color: 'green', is_closed: '0' }
end
assert_equal 'Test status', QuestionsStatus.last.name
end
def test_delete
@request.session[:user_id] = 1
status = QuestionsStatus.find(1)
assert_difference 'QuestionsStatus.count', -1 do
compatible_request :delete, :destroy, id: status
end
assert_nil QuestionsStatus.where(id: status.id).first
end
def test_update
@request.session[:user_id] = 1
status = QuestionsStatus.find(1)
compatible_request :put, :update, id: status, questions_status: { name: 'New name', color: 'green', is_closed: '0' }
status.reload
assert_equal status.name, 'New name'
end
end

View file

@ -3,7 +3,7 @@
# This file is a part of Redmine Q&A (redmine_questions) plugin,
# Q&A plugin for Redmine
#
# Copyright (C) 2011-2018 RedmineUP
# Copyright (C) 2011-2020 RedmineUP
# http://www.redmineup.com/
#
# redmine_questions is free software: you can redistribute it and/or modify

View file

@ -3,7 +3,7 @@
# This file is a part of Redmine Q&A (redmine_questions) plugin,
# Q&A plugin for Redmine
#
# Copyright (C) 2011-2018 RedmineUP
# Copyright (C) 2011-2020 RedmineUP
# http://www.redmineup.com/
#
# redmine_questions is free software: you can redistribute it and/or modify
@ -74,7 +74,7 @@ class RedmineQuestions::TestCase
end
def self.prepare
Role.where(:id => [1, 3]).each do |r|
Role.where(:id => 1).each do |r|
# user_2
r.permissions << :view_questions
r.permissions << :global_view_questions
@ -103,11 +103,6 @@ class RedmineQuestions::TestCase
r.save
end
Role.where(:id => 1).each do |r|
r.permissions << :accept_answers
r.save
end
Project.where(:id => [1, 2, 3, 4, 5]).each do |project|
EnabledModule.create(:project => project, :name => 'questions')
end

View file

@ -3,7 +3,7 @@
# This file is a part of Redmine Q&A (redmine_questions) plugin,
# Q&A plugin for Redmine
#
# Copyright (C) 2011-2018 RedmineUP
# Copyright (C) 2011-2020 RedmineUP
# http://www.redmineup.com/
#
# redmine_questions is free software: you can redistribute it and/or modify

View file

@ -3,7 +3,7 @@
# This file is a part of Redmine Q&A (redmine_questions) plugin,
# Q&A plugin for Redmine
#
# Copyright (C) 2011-2018 RedmineUP
# Copyright (C) 2011-2020 RedmineUP
# http://www.redmineup.com/
#
# redmine_questions is free software: you can redistribute it and/or modify

View file

@ -3,7 +3,7 @@
# This file is a part of Redmine Q&A (redmine_questions) plugin,
# Q&A plugin for Redmine
#
# Copyright (C) 2011-2018 RedmineUP
# Copyright (C) 2011-2020 RedmineUP
# http://www.redmineup.com/
#
# redmine_questions is free software: you can redistribute it and/or modify