diff --git a/app/controllers/admin/tags_controller.rb b/app/controllers/admin/tags_controller.rb index 25258d2ab..e3530876d 100644 --- a/app/controllers/admin/tags_controller.rb +++ b/app/controllers/admin/tags_controller.rb @@ -4,7 +4,7 @@ class Admin::TagsController < Admin::BaseController respond_to :html, :js def index - @tags = ActsAsTaggableOn::Tag.order(kind: :asc, featured: :desc).page(params[:page]) + @tags = ActsAsTaggableOn::Tag.order(kind: :asc, id: :asc).page(params[:page]) @tag = ActsAsTaggableOn::Tag.new end @@ -43,7 +43,9 @@ class Admin::TagsController < Admin::BaseController @tag = ActsAsTaggableOn::Tag.find(params[:id]) end def search_tag - @tag = ActsAsTaggableOn::Tag.where("name = '#{@paramTag[:name]}' and - kind = '#{@paramTag[:kind]}'") + # @tag = ActsAsTaggableOn::Tag.where("name = '#{@paramTag[:name]}' and + # kind = '#{@paramTag[:kind]}'") + + @tag = ActsAsTaggableOn::Tag.where("upper(name) = upper('#{@paramTag[:name]}')") end end diff --git a/spec/features/admin/tags_spec.rb b/spec/features/admin/tags_spec.rb index 74579c1b8..6689aad03 100644 --- a/spec/features/admin/tags_spec.rb +++ b/spec/features/admin/tags_spec.rb @@ -17,7 +17,6 @@ feature 'Admin tags' do scenario 'Create' do visit admin_tags_path - expect(page).to_not have_content 'important issues' within("form.new_tag") do @@ -26,7 +25,6 @@ feature 'Admin tags' do end visit admin_tags_path - expect(page).to have_content 'important issues' end @@ -81,4 +79,48 @@ feature 'Admin tags' do expect(page).to_not have_content tag2.name end + scenario 'validate add new tags' do + visit admin_tags_path + expect(page).to_not have_content 'important issues' + + within("form.new_tag") do + fill_in "tag_name", with: 'important issues' + click_button 'Create Topic' + end + + visit admin_tags_path + + within("form.new_tag") do + fill_in "tag_name", with: 'important issues' + click_button 'Create Topic' + end + expect(page).to have_content 'name of the topic already exists' + end + + scenario 'validate uppercase name add new tags' do + visit admin_tags_path + expect(page).to_not have_content 'important issues' + + within("form.new_tag") do + fill_in "tag_name", with: 'important issues' + click_button 'Create Topic' + end + + visit admin_tags_path + + within("form.new_tag") do + fill_in "tag_name", with: 'IMPORTANT ISSUES' + click_button 'Create Topic' + end + expect(page).to have_content 'name of the topic already exists' + end + +scenario 'validate name new tags' do + visit admin_tags_path + + within("form.new_tag") do + click_button 'Create Topic' + end + expect(page).to have_content 'The name of the topic is mandatory filling' + end end \ No newline at end of file