From a489aa7ad9af5e819409a08020a7dfa99760df6f Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Wed, 17 Dec 2014 12:45:41 +1100 Subject: [PATCH] Fixing enterprise feature spec, adding first shop preference --- .../enterprise_controller.js.coffee | 16 ++++++- .../stylesheets/admin/side_menu.css.sass | 1 + app/models/enterprise.rb | 2 + .../admin/enterprises/_side_menu.html.haml | 3 +- .../form/_shop_preferences.html.haml | 10 +++- spec/features/admin/enterprises_spec.rb | 47 +++++++++++++++++-- 6 files changed, 70 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/admin/enterprises/controllers/enterprise_controller.js.coffee b/app/assets/javascripts/admin/enterprises/controllers/enterprise_controller.js.coffee index 9a665571b2..3c32c862c1 100644 --- a/app/assets/javascripts/admin/enterprises/controllers/enterprise_controller.js.coffee +++ b/app/assets/javascripts/admin/enterprises/controllers/enterprise_controller.js.coffee @@ -47,9 +47,21 @@ angular.module("admin.enterprises") , 0 $scope.$watch "Enterprise.is_primary_producer", (newValue, oldValue) -> - if newValue + if !newValue && $scope.Enterprise.sells == "none" + $scope.menu.hide_item_by_name('Enterprise Fees') + else + $scope.menu.show_item_by_name('Enterprise Fees') + + + $scope.$watch "Enterprise.sells", (newValue, oldValue) -> + if newValue == "none" $scope.menu.hide_item_by_name('Shipping Methods') $scope.menu.hide_item_by_name('Payment Methods') - else if !newValue + if $scope.Enterprise.is_primary_producer + $scope.menu.show_item_by_name('Enterprise Fees') + else + $scope.menu.hide_item_by_name('Enterprise Fees') + else $scope.menu.show_item_by_name('Shipping Methods') $scope.menu.show_item_by_name('Payment Methods') + $scope.menu.show_item_by_name('Enterprise Fees') diff --git a/app/assets/stylesheets/admin/side_menu.css.sass b/app/assets/stylesheets/admin/side_menu.css.sass index a41e60f711..6c03059d27 100644 --- a/app/assets/stylesheets/admin/side_menu.css.sass +++ b/app/assets/stylesheets/admin/side_menu.css.sass @@ -2,6 +2,7 @@ border-right: 2px solid #f6f6f6 border-top: 2px solid #f6f6f6 .menu_item + display: block padding: 8px 15px font-size: 120% cursor: pointer diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 5082267a01..49c2dd29e6 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -3,6 +3,8 @@ class Enterprise < ActiveRecord::Base SHOP_TRIAL_LENGTH = 30 ENTERPRISE_SEARCH_RADIUS = 100 + preference :shopfront_message, :text, default: "" + devise :confirmable, reconfirmable: true, confirmation_keys: [ :id, :email ] self.inheritance_column = nil diff --git a/app/views/admin/enterprises/_side_menu.html.haml b/app/views/admin/enterprises/_side_menu.html.haml index ee23e41d73..a1d32d3ecc 100644 --- a/app/views/admin/enterprises/_side_menu.html.haml +++ b/app/views/admin/enterprises/_side_menu.html.haml @@ -1,5 +1,6 @@ .side_menu{ ng: { controller: 'sideMenuCtrl' } } - .menu_item{ ng: { repeat: '(index,item) in menu.items', + %a.menu_item{ href: "#", id: "{{ item.name.toLowerCase().replace(' ', '_') }}", + ng: { repeat: '(index,item) in menu.items', show: "item.visible", click: 'select(index)', class: '{ selected: item.selected}', diff --git a/app/views/admin/enterprises/form/_shop_preferences.html.haml b/app/views/admin/enterprises/form/_shop_preferences.html.haml index cbf11fc474..a3c4cc3379 100644 --- a/app/views/admin/enterprises/form/_shop_preferences.html.haml +++ b/app/views/admin/enterprises/form/_shop_preferences.html.haml @@ -1 +1,9 @@ -Something \ No newline at end of file +.row + .alpha.eleven.columns + .three.columns.alpha + = f.label "preferred_shopfront_message", t(:shopfront_message) + .eight.columns.omega + -# %text-angular{'ng-model' => 'longDescription', 'id' => 'enterprise_long_description', 'name' => 'enterprise[long_description]', 'class' => 'text-angular', + -# 'ta-toolbar' => "[['h1','h2','h3','h4','p'],['bold','italics','underline','clear'],['insertLink']]", + -# 'placeholder' => 'Tell customers about yourself. This information appears on your public profile.'} + = f.text_area :preferred_shopfront_message, rows: 6, class: "fullwidth", placeholder: "An option explanation for customers detailing how your shopfront works. This text will appear at the top of your shop page, immediately above your products." \ No newline at end of file diff --git a/spec/features/admin/enterprises_spec.rb b/spec/features/admin/enterprises_spec.rb index 3383717460..2d88480b31 100644 --- a/spec/features/admin/enterprises_spec.rb +++ b/spec/features/admin/enterprises_spec.rb @@ -131,24 +131,37 @@ feature %q{ select2_search admin.email, from: 'Owner' select2_search admin.email, from: 'Owner' choose 'Any' - check "enterprise_payment_method_ids_#{payment_method.id}" - check "enterprise_shipping_method_ids_#{shipping_method.id}" select2_search eg1.name, from: 'Groups' + + click_link "Payment Methods" + check "enterprise_payment_method_ids_#{payment_method.id}" + + click_link "Shipping Methods" + check "enterprise_shipping_method_ids_#{shipping_method.id}" + + click_link "Contact" fill_in 'enterprise_contact', :with => 'Kirsten or Ren' fill_in 'enterprise_phone', :with => '0413 897 321' fill_in 'enterprise_email', :with => 'info@eaterprises.com.au' fill_in 'enterprise_website', :with => 'http://eaterprises.com.au' + + click_link "Social" fill_in 'enterprise_twitter', :with => '@eaterprises' fill_in 'enterprise_facebook', :with => 'facebook.com/eaterprises' fill_in 'enterprise_instagram', :with => 'eaterprises' + + click_link "Business Details" fill_in 'enterprise_abn', :with => '09812309823' fill_in 'enterprise_acn', :with => '' + click_link "Address" fill_in 'enterprise_address_attributes_address1', :with => '35 Ballantyne St' fill_in 'enterprise_address_attributes_city', :with => 'Thornbury' fill_in 'enterprise_address_attributes_zipcode', :with => '3072' select2_search 'Australia', :from => 'Country' select2_search 'Victoria', :from => 'State' + + click_link "About" long_description = find :css, "text-angular div.ta-scroll-window div.ta-bind" long_description.set 'Connecting farmers and eaters' @@ -176,11 +189,14 @@ feature %q{ fill_in 'enterprise_name', :with => 'Eaterprises' choose 'Own' select2_search user.email, from: 'Owner' + + click_link "About" fill_in 'enterprise_description', :with => 'Connecting farmers and eaters' long_description = find :css, "text-angular div.ta-scroll-window div.ta-bind" long_description.set 'This is an interesting long description' # Check Angularjs switching of sidebar elements + click_link "Primary Details" uncheck 'enterprise_is_primary_producer' choose 'None' page.should have_selector "#enterprise_fees", visible: false @@ -202,26 +218,37 @@ feature %q{ select2_search eg1.name, from: 'Groups' + click_link "Payment Methods" page.should_not have_checked_field "enterprise_payment_method_ids_#{payment_method.id}" - page.should_not have_checked_field "enterprise_shipping_method_ids_#{shipping_method.id}" - check "enterprise_payment_method_ids_#{payment_method.id}" + + click_link "Shipping Methods" + page.should_not have_checked_field "enterprise_shipping_method_ids_#{shipping_method.id}" check "enterprise_shipping_method_ids_#{shipping_method.id}" + click_link "Contact" fill_in 'enterprise_contact', :with => 'Kirsten or Ren' fill_in 'enterprise_phone', :with => '0413 897 321' fill_in 'enterprise_email', :with => 'info@eaterprises.com.au' fill_in 'enterprise_website', :with => 'http://eaterprises.com.au' + + click_link "Social" fill_in 'enterprise_twitter', :with => '@eaterprises' + + click_link "Business Details" fill_in 'enterprise_abn', :with => '09812309823' fill_in 'enterprise_acn', :with => '' + click_link "Address" fill_in 'enterprise_address_attributes_address1', :with => '35 Ballantyne St' fill_in 'enterprise_address_attributes_city', :with => 'Thornbury' fill_in 'enterprise_address_attributes_zipcode', :with => '3072' select2_search 'Australia', :from => 'Country' select2_search 'Victoria', :from => 'State' + click_link "Shop Preferences" + fill_in 'enterprise_preferred_shopfront_message', :with => 'This is my shopfront message.' + click_button 'Update' flash_message.should == 'Enterprise "Eaterprises" has been successfully updated!' @@ -229,10 +256,20 @@ feature %q{ @enterprise.reload expect(@enterprise.owner).to eq user + click_link "Payment Methods" page.should have_checked_field "enterprise_payment_method_ids_#{payment_method.id}" + + click_link "Shipping Methods" page.should have_checked_field "enterprise_shipping_method_ids_#{shipping_method.id}" - page.should have_selector "a.list-item", text: enterprise_fee.name + + click_link "Enterprise Fees" + page.should have_selector "td", text: enterprise_fee.name + + click_link "About" page.should have_content 'This is an interesting long description' + + click_link "Shop Preferences" + page.should have_field 'enterprise_preferred_shopfront_message', :text => 'This is my shopfront message.' end describe "producer properties" do