From 065859b90cc5ef403b8f47bd5394b343e556cc4d Mon Sep 17 00:00:00 2001 From: Azul Date: Wed, 23 Mar 2016 21:48:52 +0100 Subject: upgrade: remove references to RestClient CouchRest > 1.2 does not use RestClient anymore. So we should not try to catch its errors. --- engines/support/app/models/ticket.rb | 2 +- engines/support/test/unit/ticket_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/support') diff --git a/engines/support/app/models/ticket.rb b/engines/support/app/models/ticket.rb index b1bdf8d..4615a10 100644 --- a/engines/support/app/models/ticket.rb +++ b/engines/support/app/models/ticket.rb @@ -50,7 +50,7 @@ class Ticket < CouchRest::Model::Base self.by_created_by.key(user.id).each do |ticket| ticket.destroy end - rescue RestClient::ResourceNotFound + rescue RESOURCE_NOT_FOUND # silently ignore if design docs are not yet created end diff --git a/engines/support/test/unit/ticket_test.rb b/engines/support/test/unit/ticket_test.rb index 7b5281f..c2c5e11 100644 --- a/engines/support/test/unit/ticket_test.rb +++ b/engines/support/test/unit/ticket_test.rb @@ -63,7 +63,7 @@ class TicketTest < ActiveSupport::TestCase test "find tickets user commented on" do # clear old tickets just in case - # this will cause RestClient::ResourceNotFound errors if there are multiple copies of the same ticket returned + # this will cause RESOURCE_NOT_FOUND errors if there are multiple copies of the same ticket returned Ticket.by_includes_post_by.key('123').each {|t| t.destroy} # TODO: the by_includes_post_by view is only used for tests. Maybe we should get rid of it and change the test to including ordering? -- cgit v1.2.3 From de8f3e532d857ec64a9ba17bf9e5a4de272a6cbd Mon Sep 17 00:00:00 2001 From: Azul Date: Sat, 26 Mar 2016 17:36:37 +0100 Subject: upgrade: use bootstrap3 row and col-md-* --- engines/support/app/views/tickets/_edit_form.html.haml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/support') diff --git a/engines/support/app/views/tickets/_edit_form.html.haml b/engines/support/app/views/tickets/_edit_form.html.haml index cd1dbe4..8d64256 100644 --- a/engines/support/app/views/tickets/_edit_form.html.haml +++ b/engines/support/app/views/tickets/_edit_form.html.haml @@ -34,12 +34,12 @@ = simple_form_for @ticket do |f| = hidden_ticket_fields = f.input :subject, input_html: {:class => 'large full-width'} - .row-fluid - .span4 + .row + .col-md-4 = f.input :is_open, as: :select, collection: [:true, :false], include_blank: false - .span4 + .col-md-4 = f.input :email - .span4 + .col-md-4 = f.input :regarding_user, label: (Ticket.human_attribute_name(:regarding_user) + " " + regarding_user_link).html_safe = f.button :loading - if admin? -- cgit v1.2.3 From 6117518350847e83e5b0e79cb206b03ff99d6ee2 Mon Sep 17 00:00:00 2001 From: Azul Date: Sat, 26 Mar 2016 19:59:12 +0100 Subject: bugfix: test user properly in auto_new_ticket_path --- engines/support/app/helpers/auto_tickets_path_helper.rb | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'engines/support') diff --git a/engines/support/app/helpers/auto_tickets_path_helper.rb b/engines/support/app/helpers/auto_tickets_path_helper.rb index bc98a0a..17fc003 100644 --- a/engines/support/app/helpers/auto_tickets_path_helper.rb +++ b/engines/support/app/helpers/auto_tickets_path_helper.rb @@ -4,7 +4,8 @@ # (1) include the user in the path if appropriate. # (2) retain the sort params, if appropriate. # -# Tickets views with a user_id are limited to that user. For admins, they don't need a user_id for any ticket action. +# Tickets views with a user_id are limited to that user. +# Admins don't need a user_id for any ticket action. # # This is available both to the views and the tickets_controller. # @@ -13,7 +14,6 @@ module AutoTicketsPathHelper protected def auto_tickets_path(options={}) - return unless options.class == Hash options = ticket_view_options.merge options if @user.is_a? User user_tickets_path(@user, options) @@ -22,9 +22,9 @@ module AutoTicketsPathHelper end end - def auto_ticket_path(ticket, options={}) + def auto_ticket_path(ticket) return unless ticket.persisted? - options = ticket_view_options.merge options + options = ticket_view_options if @user.is_a? User user_ticket_path(@user, ticket, options) else @@ -32,10 +32,9 @@ module AutoTicketsPathHelper end end - def auto_new_ticket_path(options={}) - return unless options.class == Hash - options = ticket_view_options.merge options - if @user + def auto_new_ticket_path + options = ticket_view_options + if @user.is_a? User new_user_ticket_path(@user, options) else new_ticket_path(options) -- cgit v1.2.3 From a1b494e334406660a1f49fb7de9b043493809640 Mon Sep 17 00:00:00 2001 From: Azul Date: Fri, 13 May 2016 16:23:10 +0200 Subject: ensure invalid user ids still render the ticket form We still have strange urls requested like /pt/users/AnonymousUser.../tickets/new Not sure where they are coming from - but this should make sure we respond with sth. meaningful instead of erroring out. Conflicts: app/views/layouts/_content.html.haml --- engines/support/app/views/tickets/edit.html.haml | 1 - engines/support/app/views/tickets/index.html.haml | 2 -- engines/support/app/views/tickets/new.html.haml | 5 ----- engines/support/app/views/tickets/show.html.haml | 2 -- engines/support/test/functional/tickets_controller_test.rb | 6 ++++++ 5 files changed, 6 insertions(+), 10 deletions(-) (limited to 'engines/support') diff --git a/engines/support/app/views/tickets/edit.html.haml b/engines/support/app/views/tickets/edit.html.haml index 03bda7d..cdc5e16 100644 --- a/engines/support/app/views/tickets/edit.html.haml +++ b/engines/support/app/views/tickets/edit.html.haml @@ -1,4 +1,3 @@ -- @show_navigation = params[:user_id].present? - @comment = TicketComment.new .ticket diff --git a/engines/support/app/views/tickets/index.html.haml b/engines/support/app/views/tickets/index.html.haml index d107ce2..56c7012 100644 --- a/engines/support/app/views/tickets/index.html.haml +++ b/engines/support/app/views/tickets/index.html.haml @@ -1,5 +1,3 @@ -- @show_navigation = params[:user_id].present? - = render 'tickets/tabs' = table @tickets, %w(subject created updated voices) = paginate @tickets diff --git a/engines/support/app/views/tickets/new.html.haml b/engines/support/app/views/tickets/new.html.haml index d3580f9..d0b0f89 100644 --- a/engines/support/app/views/tickets/new.html.haml +++ b/engines/support/app/views/tickets/new.html.haml @@ -1,10 +1,5 @@ -- @show_navigation = params[:user_id].present? - = render 'tickets/tabs' -- user = @user if admin? -- user ||= current_user - = simple_form_for @ticket, :validate => true, :html => {:class => 'form-horizontal'} do |f| = hidden_ticket_fields = f.input :subject diff --git a/engines/support/app/views/tickets/show.html.haml b/engines/support/app/views/tickets/show.html.haml index 99afa2a..a625870 100644 --- a/engines/support/app/views/tickets/show.html.haml +++ b/engines/support/app/views/tickets/show.html.haml @@ -1,5 +1,3 @@ -- @show_navigation = params[:user_id].present? - .ticket = render 'tickets/edit_form' = render 'tickets/comments' diff --git a/engines/support/test/functional/tickets_controller_test.rb b/engines/support/test/functional/tickets_controller_test.rb index a7a2011..5c2b346 100644 --- a/engines/support/test/functional/tickets_controller_test.rb +++ b/engines/support/test/functional/tickets_controller_test.rb @@ -35,6 +35,12 @@ class TicketsControllerTest < ActionController::TestCase assert_response :success end + test "should get new despite invalid user_id" do + get :new, user_id: :bla + assert_equal Ticket, assigns(:ticket).class + assert_response :success + end + test "unauthenticated tickets are visible" do ticket = find_record :ticket, :created_by => nil get :show, :id => ticket.id -- cgit v1.2.3 From f20ecdfb249128ba79da069407dce32f6f7e2fca Mon Sep 17 00:00:00 2001 From: Azul Date: Fri, 20 May 2016 11:47:38 +0200 Subject: include engine tests in default test --- engines/support/test/integration/create_ticket_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/support') diff --git a/engines/support/test/integration/create_ticket_test.rb b/engines/support/test/integration/create_ticket_test.rb index 00f9a6b..6abb3d3 100644 --- a/engines/support/test/integration/create_ticket_test.rb +++ b/engines/support/test/integration/create_ticket_test.rb @@ -29,7 +29,7 @@ class CreateTicketTest < BrowserIntegrationTest fill_in 'Description', with: 'description of the problem goes here' click_on 'Submit Ticket' assert page.has_content?("is invalid") - assert_equal 'invalid data', find_field('Email').value + assert_equal 'invaliddata', find_field('Email').value assert_equal 'some user', find_field('Regarding User').value end -- cgit v1.2.3 From b851fe2fd6e0029df81976b647ede7190a1fd547 Mon Sep 17 00:00:00 2001 From: Azul Date: Sun, 22 May 2016 21:11:48 +0200 Subject: make ticket tests pass without network connection MX validations relied on network connection. Only using them in production environment now. I want to be able to develop and test when disconnected. --- engines/support/app/models/ticket.rb | 4 +++- engines/support/test/unit/ticket_test.rb | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'engines/support') diff --git a/engines/support/app/models/ticket.rb b/engines/support/app/models/ticket.rb index 4615a10..025e2ab 100644 --- a/engines/support/app/models/ticket.rb +++ b/engines/support/app/models/ticket.rb @@ -37,9 +37,11 @@ class Ticket < CouchRest::Model::Base # email can be nil, "", or valid address. # validation provided by 'valid_email' gem. + # mx validation depends on network availability and is disabled in test + # and development environment validates :email, :allow_blank => true, :email => true, - :mx_with_fallback => true + :mx_with_fallback => Rails.env.production? def self.search(options = {}) @selection = TicketSelection.new(options) diff --git a/engines/support/test/unit/ticket_test.rb b/engines/support/test/unit/ticket_test.rb index c2c5e11..373f06c 100644 --- a/engines/support/test/unit/ticket_test.rb +++ b/engines/support/test/unit/ticket_test.rb @@ -8,12 +8,12 @@ class TicketTest < ActiveSupport::TestCase test "ticket with default attribs is valid" do t = FactoryGirl.build :ticket - assert t.valid? + assert t.valid?, t.errors.full_messages.to_sentence end test "ticket without email is valid" do t = FactoryGirl.build :ticket, email: "" - assert t.valid? + assert t.valid?, t.errors.full_messages.to_sentence end test "ticket validates email format" do -- cgit v1.2.3 From 638acc59a241e141cf0fc9ccbf4e3c5578b98f0c Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 4 Jul 2016 20:19:21 +0200 Subject: Fix db:migrate and similar tasks We saw errors from duplicate loading of LocalEmail and LoginFormatValidation. The latter resulted in a crash. In an attempt to ensure all subclasses of Couchrest::Model::Base are loaded Couchrest::Model::Utils::Migrate requires all files in app/models. We have an extension that does the same for the engines. During this process LoginFormatValidation and LocalEmail were autoloaded when 'identity' was required. Afterwards they were required again. It looks like rails' autoload mechanism does not play nicely with require. So to make sure they are not autoloaded first move the concerns and helper classes into the lib directory and require them explicitly. --- engines/support/app/models/account_extension/tickets.rb | 13 ------------- engines/support/config/initializers/account_lifecycle.rb | 2 ++ engines/support/lib/account_extension/tickets.rb | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 13 deletions(-) delete mode 100644 engines/support/app/models/account_extension/tickets.rb create mode 100644 engines/support/lib/account_extension/tickets.rb (limited to 'engines/support') diff --git a/engines/support/app/models/account_extension/tickets.rb b/engines/support/app/models/account_extension/tickets.rb deleted file mode 100644 index f38d5fd..0000000 --- a/engines/support/app/models/account_extension/tickets.rb +++ /dev/null @@ -1,13 +0,0 @@ -module AccountExtension::Tickets - extend ActiveSupport::Concern - - def destroy_with_tickets(destroy_identities=false) - Ticket.destroy_all_from(self.user) - destroy_without_tickets(destroy_identities) - end - - included do - alias_method_chain :destroy, :tickets - end - -end diff --git a/engines/support/config/initializers/account_lifecycle.rb b/engines/support/config/initializers/account_lifecycle.rb index d9f04c1..9060757 100644 --- a/engines/support/config/initializers/account_lifecycle.rb +++ b/engines/support/config/initializers/account_lifecycle.rb @@ -1,3 +1,5 @@ +require 'account_extension/tickets' + ActiveSupport.on_load(:account) do include AccountExtension::Tickets end diff --git a/engines/support/lib/account_extension/tickets.rb b/engines/support/lib/account_extension/tickets.rb new file mode 100644 index 0000000..63f4873 --- /dev/null +++ b/engines/support/lib/account_extension/tickets.rb @@ -0,0 +1,15 @@ +module AccountExtension + module Tickets + extend ActiveSupport::Concern + + def destroy_with_tickets(destroy_identities=false) + Ticket.destroy_all_from(self.user) + destroy_without_tickets(destroy_identities) + end + + included do + alias_method_chain :destroy, :tickets + end + + end +end -- cgit v1.2.3 From 1c648da3e16848f2a146c5713e3ff0801468cfc8 Mon Sep 17 00:00:00 2001 From: luca-marie Date: Thu, 7 Jul 2016 16:01:58 +0200 Subject: Added missing word --- engines/support/config/locales/en.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/support') diff --git a/engines/support/config/locales/en.yml b/engines/support/config/locales/en.yml index 83af2c4..3b509d5 100644 --- a/engines/support/config/locales/en.yml +++ b/engines/support/config/locales/en.yml @@ -92,7 +92,7 @@ en: # mouse over hints for the given fields hints: ticket: - email: "Provide an email address in order to notified when this ticket is updated." + email: "Provide an email address in order to be notified when this ticket is updated." # these will fallback to translations in "simple_form.hints.defaults" # placeholders inside the fields before anything was typed #placeholders: -- cgit v1.2.3 From c904acbc17c4198bfb1e67b7c6b04004e7a24b3d Mon Sep 17 00:00:00 2001 From: thea Date: Tue, 12 Jul 2016 16:32:24 +0200 Subject: bugfix #226:patch instead of put --- engines/support/config/routes.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/support') diff --git a/engines/support/config/routes.rb b/engines/support/config/routes.rb index 81bdf9a..5647477 100644 --- a/engines/support/config/routes.rb +++ b/engines/support/config/routes.rb @@ -3,8 +3,8 @@ Rails.application.routes.draw do resources :tickets, except: :edit do member do - put 'open' - put 'close' + patch 'open' + patch 'close' end end -- cgit v1.2.3