Skip to content

Commit

Permalink
Remove changes related to enterprise trials as they dont make sense w…
Browse files Browse the repository at this point in the history
…ithout business models and account invoices
  • Loading branch information
luisramos0 committed Feb 25, 2019
1 parent a870299 commit 0501db1
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 158 deletions.
12 changes: 0 additions & 12 deletions app/assets/stylesheets/admin/components/trial_progess_bar.scss

This file was deleted.

4 changes: 0 additions & 4 deletions app/controllers/admin/enterprises_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ def register

attributes = { sells: params[:sells], visible: true }

if ['own', 'any'].include? params[:sells]
attributes[:shop_trial_start_date] = @enterprise.shop_trial_start_date || Time.zone.now
end

if @enterprise.update_attributes(attributes)
flash[:success] = I18n.t(:enterprise_register_success_notice, enterprise: @enterprise.name)
redirect_to admin_path
Expand Down
16 changes: 0 additions & 16 deletions app/helpers/enterprises_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,6 @@ def link_to_delete_enterprise(enterprise)
link_to_with_icon 'icon-trash', name, url, options
end

def shop_trial_in_progress?(enterprise)
!!enterprise.shop_trial_start_date &&
(enterprise.shop_trial_start_date + Spree::Config[:shop_trial_length_days].days > Time.zone.now) &&
%w(own any).include?(enterprise.sells)
end

def shop_trial_expired?(enterprise)
!!enterprise.shop_trial_start_date &&
(enterprise.shop_trial_start_date + Spree::Config[:shop_trial_length_days].days <= Time.zone.now) &&
%w(own any).include?(enterprise.sells)
end

def remaining_trial_days(enterprise)
distance_of_time_in_words(Time.zone.now, enterprise.shop_trial_start_date + Spree::Config[:shop_trial_length_days].days)
end

def order_changes_allowed?
current_order.andand.distributor.andand.allow_order_changes?
end
Expand Down
4 changes: 0 additions & 4 deletions app/models/enterprise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,6 @@ def self.find_available_permalink(test_permalink)
end
end

def shop_trial_expiry
shop_trial_start_date.andand + Spree::Config[:shop_trial_length_days].days
end

def can_invoice?
abn.present?
end
Expand Down
15 changes: 1 addition & 14 deletions app/views/admin/enterprises/_change_type_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@
%p.description
= t('.producer_hub_description_text')
-# %p.description
-# Test out having your own shopfront with full access to all Shopfront features for 30 days.
-# %br
-# %br
-# At the end of your trial, there is a one-off $200 fee to fully activate your account. Then you will be billed for 2% of your actual transactions, capped at $50 a month (so if you don’t sell anything you don’t pay anything, but you never pay more than $50 a month).
- else
.two.columns.alpha
&nbsp;
Expand Down Expand Up @@ -76,14 +70,7 @@
.sixteen.columns.alpha
%span.error{ ng: { show: "(change_type.sells.$error.required || change_type.sells.$error.pattern) && submitted" } }
= t('.choose_option')
- if @enterprise.sells == 'unspecified' && @enterprise.shop_trial_start_date.nil?
-if free_use?
%input.button.big{ type: 'submit', value: t(:select_continue), ng: { click: "submit(change_type)" } }
- else
- trial_length = Spree::Config[:shop_trial_length_days]
%input.button.big{ type: 'submit', value: "Start #{trial_length}-Day Shop Trial", ng: { click: "submit(change_type)", show: "sells=='own' || sells=='any'" } }
%input.button.big{ type: 'submit', value: t(:select_continue), ng: { click: "submit(change_type)", hide: "sells=='own' || sells=='any'" } }
- elsif @enterprise.sells == 'unspecified'
- if @enterprise.sells == 'unspecified'
%input.button.big{ type: 'submit', value: t(:select_continue), ng: { click: "submit(change_type)" } }
- else
%input.button.big{ type: 'submit', value: t('.change_now'), ng: { click: "submit(change_type)" } }
Expand Down
3 changes: 0 additions & 3 deletions app/views/shops/signup.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
.small-12.medium-10.medium-offset-1.columns.text-center
%h2
= t :shops_signup_pricing
-# %p.text-big
-# If there is a time-sensitive offer you can write it here, e.g.
-# Sign up before 30th June for an extra month free!
%br
= ContentConfig.hub_signup_pricing_table_html.html_safe

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,3 @@
%a.button.bottom{href: main_app.admin_order_cycles_path}
= t "manage_order_cycles"
%span.icon-arrow-right

= render 'spree/admin/shared/trial_progress_bar', enterprise: @enterprise
7 changes: 0 additions & 7 deletions app/views/spree/admin/shared/_trial_progress_bar.html.haml

This file was deleted.

14 changes: 0 additions & 14 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,17 +202,9 @@ en:
confirm_resend_order_confirmation: "Are you sure you want to resend the order confirmation email?"
must_have_valid_business_number: "%{enterprise_name} must have a valid ABN before invoices can be sent."
invoice: "Invoice"
percentage_of_sales: "%{percentage} of sales"
capped_at_cap: "capped at %{cap}"
per_month: "per month"
free: "free"
free_trial: "free trial"
plus_tax: "plus GST"
min_bill_turnover_desc: "once turnover exceeds %{mbt_amount}"
more: "More"
say_no: "No"
say_yes: "Yes"
then: then
ongoing: Ongoing
bill_address: Billing Address
ship_address: Shipping Address
Expand Down Expand Up @@ -1767,10 +1759,6 @@ See the %{link} to find out more about %{sitename}'s features and to start using
products_distributor_info: When you select a distributor for your order, their address and pickup times will be displayed here.
products_distribution_adjustment_label: "Product distribution by %{distributor} for %{product}"

shop_trial_expires_in: "Your shopfront trial expires in"
shop_trial_expired_notice: "Good news! We have decided to extend shopfront trials until further notice."


# keys used in javascript
password: Password
remember_me: Remember Me
Expand Down Expand Up @@ -2154,7 +2142,6 @@ See the %{link} to find out more about %{sitename}'s features and to start using
live: "live"
manage: "Manage"
resend: "Resend"
trial: Trial
add_and_manage_products: "Add & manage products"
add_and_manage_order_cycles: "Add & manage order cycles"
manage_order_cycles: "Manage order cycles"
Expand Down Expand Up @@ -2187,7 +2174,6 @@ See the %{link} to find out more about %{sitename}'s features and to start using
hub_sidebar_at_least: "At least one hub must be selected"
hub_sidebar_blue: "blue"
hub_sidebar_red: "red"
shop_trial_in_progress: "Your shopfront trial expires in %{days}."
report_customers_distributor: "Distributor"
report_customers_supplier: "Supplier"
report_customers_cycle: "Order Cycle"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class DropEnterpriseShopTrialStartDate < ActiveRecord::Migration
def up
remove_column :enterprises, :shop_trial_start_date
end

def down
add_column :enterprises, :shop_trial_start_date, :datetime, default: nil
end
end
3 changes: 1 addition & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20190221131741) do
ActiveRecord::Schema.define(:version => 20190221214542) do

create_table "account_invoices", :force => true do |t|
t.integer "user_id", :null => false
Expand Down Expand Up @@ -233,7 +233,6 @@
t.string "linkedin"
t.integer "owner_id", :null => false
t.string "sells", :default => "none", :null => false
t.datetime "shop_trial_start_date"
t.boolean "producer_profile_only", :default => false
t.string "permalink", :null => false
t.boolean "charges_sales_tax", :default => false, :null => false
Expand Down
90 changes: 10 additions & 80 deletions spec/controllers/admin/enterprises_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -344,90 +344,20 @@ module Admin
enterprise.save!
end

context "if the trial has finished" do
let(:trial_start) { 30.days.ago.beginning_of_day }

before do
enterprise.update_attribute(:shop_trial_start_date, trial_start)
end

it "is allowed" do
Timecop.freeze(Time.zone.local(2015, 4, 16, 14, 0, 0)) do
spree_post :register, { id: enterprise, sells: 'own' }
expect(response).to redirect_to spree.admin_path
expect(enterprise.reload.sells).to eq 'own'
expect(enterprise.shop_trial_start_date).to eq trial_start
end
end
end

context "if the trial has not finished" do
let(:trial_start) { Date.current.to_time }

before do
enterprise.update_attribute(:shop_trial_start_date, trial_start)
end

it "is allowed, but trial start date is not reset" do
spree_post :register, { id: enterprise, sells: 'own' }
expect(response).to redirect_to spree.admin_path
expect(enterprise.reload.sells).to eq 'own'
expect(enterprise.shop_trial_start_date).to eq trial_start
end
end

context "if a trial has not started" do
it "is allowed" do
spree_post :register, { id: enterprise, sells: 'own' }
expect(response).to redirect_to spree.admin_path
expect(flash[:success]).to eq "Congratulations! Registration for #{enterprise.name} is complete!"
expect(enterprise.reload.sells).to eq 'own'
expect(enterprise.reload.shop_trial_start_date).to be > Time.zone.now-(1.minute)
end
it "is allowed" do
spree_post :register, { id: enterprise, sells: 'own' }
expect(response).to redirect_to spree.admin_path
expect(flash[:success]).to eq "Congratulations! Registration for #{enterprise.name} is complete!"
expect(enterprise.reload.sells).to eq 'own'
end
end

context "setting 'sells' to any" do
context "if the trial has finished" do
let(:trial_start) { 30.days.ago.beginning_of_day }

before do
enterprise.update_attribute(:shop_trial_start_date, trial_start)
end

it "is allowed" do
Timecop.freeze(Time.zone.local(2015, 4, 16, 14, 0, 0)) do
spree_post :register, { id: enterprise, sells: 'any' }
expect(response).to redirect_to spree.admin_path
expect(enterprise.reload.sells).to eq 'any'
expect(enterprise.shop_trial_start_date).to eq trial_start
end
end
end

context "if the trial has not finished" do
let(:trial_start) { Date.current.to_time }

before do
enterprise.update_attribute(:shop_trial_start_date, trial_start)
end

it "is allowed, but trial start date is not reset" do
spree_post :register, { id: enterprise, sells: 'any' }
expect(response).to redirect_to spree.admin_path
expect(enterprise.reload.sells).to eq 'any'
expect(enterprise.shop_trial_start_date).to eq trial_start
end
end

context "if a trial has not started" do
it "is allowed" do
spree_post :register, { id: enterprise, sells: 'any' }
expect(response).to redirect_to spree.admin_path
expect(flash[:success]).to eq "Congratulations! Registration for #{enterprise.name} is complete!"
expect(enterprise.reload.sells).to eq 'any'
expect(enterprise.reload.shop_trial_start_date).to be > Time.zone.now-(1.minute)
end
it "is allowed" do
spree_post :register, { id: enterprise, sells: 'any' }
expect(response).to redirect_to spree.admin_path
expect(flash[:success]).to eq "Congratulations! Registration for #{enterprise.name} is complete!"
expect(enterprise.reload.sells).to eq 'any'
end
end

Expand Down

0 comments on commit 0501db1

Please sign in to comment.