diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/billing/app/controllers/billing_admin_controller.rb | 1 | ||||
-rw-r--r-- | engines/billing/app/controllers/billing_base_controller.rb | 2 | ||||
-rw-r--r-- | engines/billing/app/controllers/payments_controller.rb | 2 | ||||
-rw-r--r-- | engines/billing/app/controllers/subscriptions_controller.rb | 3 | ||||
-rw-r--r-- | engines/billing/config/routes.rb | 33 | ||||
-rw-r--r-- | engines/support/app/models/account_extension/tickets.rb | 13 | ||||
-rw-r--r-- | engines/support/app/models/ticket.rb | 6 | ||||
-rw-r--r-- | engines/support/app/views/tickets/_edit_form.html.haml | 8 | ||||
-rw-r--r-- | engines/support/config/initializers/account_lifecycle.rb | 2 | ||||
-rw-r--r-- | engines/support/config/locales/en.yml | 2 | ||||
-rw-r--r-- | engines/support/config/routes.rb | 4 | ||||
-rw-r--r-- | engines/support/lib/account_extension/tickets.rb | 15 | ||||
-rw-r--r-- | engines/support/test/integration/create_ticket_test.rb | 2 | ||||
-rw-r--r-- | engines/support/test/unit/ticket_test.rb | 6 |
14 files changed, 55 insertions, 44 deletions
diff --git a/engines/billing/app/controllers/billing_admin_controller.rb b/engines/billing/app/controllers/billing_admin_controller.rb index 23740d6..7a1de30 100644 --- a/engines/billing/app/controllers/billing_admin_controller.rb +++ b/engines/billing/app/controllers/billing_admin_controller.rb @@ -1,5 +1,6 @@ class BillingAdminController < BillingBaseController before_filter :require_admin + respond_to :html #not sure if this controller is still needed. Admin can easly acess #braintree's dashboard and check subscriptions. Don't know if everything diff --git a/engines/billing/app/controllers/billing_base_controller.rb b/engines/billing/app/controllers/billing_base_controller.rb index c343938..39d41e4 100644 --- a/engines/billing/app/controllers/billing_base_controller.rb +++ b/engines/billing/app/controllers/billing_base_controller.rb @@ -3,6 +3,8 @@ class BillingBaseController < ApplicationController helper 'billing' + protected + # required for navigation to work. def assign_user if params[:user_id] diff --git a/engines/billing/app/controllers/payments_controller.rb b/engines/billing/app/controllers/payments_controller.rb index 871f1b4..4f93aa6 100644 --- a/engines/billing/app/controllers/payments_controller.rb +++ b/engines/billing/app/controllers/payments_controller.rb @@ -1,6 +1,8 @@ class PaymentsController < BillingBaseController before_filter :require_login, :only => [:index] + respond_to :html + def new if current_user.has_payment_info? @client_token = Braintree::ClientToken.generate(customer_id: current_user.braintree_customer_id) diff --git a/engines/billing/app/controllers/subscriptions_controller.rb b/engines/billing/app/controllers/subscriptions_controller.rb index 1d29cac..9df4ecd 100644 --- a/engines/billing/app/controllers/subscriptions_controller.rb +++ b/engines/billing/app/controllers/subscriptions_controller.rb @@ -1,4 +1,7 @@ class SubscriptionsController < BillingBaseController + + respond_to :html + before_filter :require_login before_filter :assign_user before_filter :confirm_cancel_subscription, only: [:destroy] diff --git a/engines/billing/config/routes.rb b/engines/billing/config/routes.rb index 357c55b..12a6778 100644 --- a/engines/billing/config/routes.rb +++ b/engines/billing/config/routes.rb @@ -2,26 +2,23 @@ Rails.application.routes.draw do scope "(:locale)", :locale => CommonLanguages.match_available do - get 'payments/new' => 'payments#new', :as => :new_payment - post 'payments/confirm' => 'payments#confirm', :as => :confirm_payment - # match 'payments/new' => 'payments#new', :as => :new_payment - # match 'payments/confirm' => 'payments#confirm', :as => :confirm_payment - #resources :users do - # resources :payments, :only => [:new, :confirm] - # resources :subscriptions, :only => [:index, :destroy] - #end - resources :subscriptions, :only => [:index, :show] do - member do - post 'subscribe' - delete 'unsubscribe' + get 'payments/new' => 'payments#new', :as => :new_payment + post 'payments/confirm' => 'payments#confirm', :as => :confirm_payment + # match 'payments/new' => 'payments#new', :as => :new_payment + # match 'payments/confirm' => 'payments#confirm', :as => :confirm_payment + #resources :users do + # resources :payments, :only => [:new, :confirm] + # resources :subscriptions, :only => [:index, :destroy] + #end + resources :subscriptions, :only => [:index, :show] do + member do + post 'subscribe' + delete 'unsubscribe' + end end - end - - resources :customer, :only => [:new, :edit] - match 'customer/confirm/' => 'customer#confirm', :as => :confirm_customer - match 'customer/show/:id' => 'customer#show', :as => :show_customer + resources :customer, :only => [:new, :edit] - match 'billing_admin' => 'billing_admin#show', :as => :billing_admin + get 'billing_admin' => 'billing_admin#show' end end 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/app/models/ticket.rb b/engines/support/app/models/ticket.rb index b1bdf8d..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) @@ -50,7 +52,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/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? 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/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: 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 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 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 diff --git a/engines/support/test/unit/ticket_test.rb b/engines/support/test/unit/ticket_test.rb index 7b5281f..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 @@ -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? |