diff --git a/app/assets/javascripts/darkswarm/services/enterprise_registration_service.js.coffee b/app/assets/javascripts/darkswarm/services/enterprise_registration_service.js.coffee index 102da60f19..a7d6a657fa 100644 --- a/app/assets/javascripts/darkswarm/services/enterprise_registration_service.js.coffee +++ b/app/assets/javascripts/darkswarm/services/enterprise_registration_service.js.coffee @@ -2,7 +2,7 @@ Darkswarm.factory "EnterpriseRegistrationService", ($http, RegistrationService, new class EnterpriseRegistrationService enterprise: user_ids: [CurrentUser.id] - email: CurrentUser.email + email_address: CurrentUser.email address: {} country: availableCountries[0] diff --git a/app/assets/javascripts/templates/partials/contact.html.haml b/app/assets/javascripts/templates/partials/contact.html.haml index bdde30b8bb..12aa5ff061 100644 --- a/app/assets/javascripts/templates/partials/contact.html.haml +++ b/app/assets/javascripts/templates/partials/contact.html.haml @@ -1,11 +1,11 @@ %div.contact-container{bindonce: true} - %div.modal-centered{"bo-if" => "enterprise.email || enterprise.website || enterprise.phone"} + %div.modal-centered{"bo-if" => "enterprise.email_address || enterprise.website || enterprise.phone"} %p.modal-header {{'contact' | t}} %p{"bo-if" => "enterprise.phone", "bo-text" => "enterprise.phone"} - %p.word-wrap{"ng-if" => "enterprise.email"} - %a{"bo-href" => "enterprise.email | stripUrl", target: "_blank", mailto: true} - %span.email{"bo-bind" => "enterprise.email | stripUrl"} + %p.word-wrap{"ng-if" => "enterprise.email_address"} + %a{"bo-href" => "enterprise.email_address | stripUrl", target: "_blank", mailto: true} + %span.email{"bo-bind" => "enterprise.email_address | stripUrl"} %p.word-wrap{"ng-if" => "enterprise.website"} %a{"bo-href-i" => "http://{{enterprise.website | stripUrl}}", target: "_blank", "bo-bind" => "enterprise.website | stripUrl"} diff --git a/app/assets/javascripts/templates/registration/contact.html.haml b/app/assets/javascripts/templates/registration/contact.html.haml index b2a2164910..a22b0677a7 100644 --- a/app/assets/javascripts/templates/registration/contact.html.haml +++ b/app/assets/javascripts/templates/registration/contact.html.haml @@ -17,28 +17,13 @@ {{'enterprise_contact_required' | t}} .row .small-12.columns.field - %label{ for: 'enterprise_email' } {{'enterprise_email' | t}}: - %input.chunky.small-12.columns{ id: 'enterprise_email', name: 'email', type: 'email', required: true, placeholder: "eg. charlie@thefarm.com", ng: { model: 'enterprise.email' } } - %span.error.small-12.columns{ ng: { show: "(contact.email.$error.email || contact.email.$error.required) && submitted" } } - {{'enterprise_email_required' | t}} + %label{ for: 'enterprise_email_address' } {{'enterprise_email_address' | t}}: + %input.chunky.small-12.columns{ id: 'enterprise_email_address', name: 'email_address', type: 'email', placeholder: "eg. charlie@thefarm.com", ng: { model: 'enterprise.email_address' } } .row .small-12.columns.field %label{ for: 'enterprise_phone' } {{'enterprise_phone' | t}}: %input.chunky.small-12.columns{ id: 'enterprise_phone', name: 'phone', placeholder: "eg. (03) 1234 5678", ng: { model: 'enterprise.phone' } } .small-12.medium-12.large-5.hide-for-small-only - / %h6 - / Contact display - / %i.ofn-i_013-help.has-tip{ 'data-tooltip' => true, title: "Choose how you want to display your contact details on the Open Food Network."} - / .row - / .small-12.columns - / %label.indent-checkbox - / %input{ type: 'checkbox', id: 'contact_name_profile', ng: { model: 'enterprise.name_in_profile' } }   Display name in profile - / .small-12.columns - / %label.indent-checkbox - / %input{ type: 'checkbox', id: 'contact_email_profile', ng: { model: 'enterprise.email_in_profile' } }   Display email in profile - / .small-12.columns - / %label.indent-checkbox - / %input{ type: 'checkbox', id: 'contact_phone_profile', ng: { model: 'enterprise.phone_in_profile' } }   Display phone in profile .row.buttons .small-12.columns diff --git a/app/assets/stylesheets/darkswarm/modal-enterprises.css.sass b/app/assets/stylesheets/darkswarm/modal-enterprises.css.sass index e0090ca163..e4724a13f5 100644 --- a/app/assets/stylesheets/darkswarm/modal-enterprises.css.sass +++ b/app/assets/stylesheets/darkswarm/modal-enterprises.css.sass @@ -62,10 +62,8 @@ // ABOUT Enterprise .about-container - max-height: 200px min-height: 20px margin-bottom: 0.5rem - overflow-y: scroll overflow-x: hidden border-bottom: 1px solid $light-grey @include box-shadow(0 2px 2px -2px $light-grey) diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index bc46cbd58f..432b53bd4d 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -81,6 +81,7 @@ class Enterprise < ActiveRecord::Base before_validation :initialize_permalink, if: lambda { permalink.nil? } before_validation :ensure_owner_is_manager, if: lambda { owner_id_changed? && !owner_id.nil? } + before_validation :ensure_email_set before_validation :set_unused_address_fields after_validation :geocode_address @@ -409,6 +410,10 @@ class Enterprise < ActiveRecord::Base users << owner unless users.include?(owner) || owner.admin? end + def ensure_email_set + self.email = owner.email if email.blank? && owner.present? + end + def enforce_ownership_limit unless owner.can_own_more_enterprises? errors.add(:owner, "^#{owner.email} is not permitted to own any more enterprises (limit is #{owner.enterprise_limit}).") diff --git a/app/serializers/api/enterprise_serializer.rb b/app/serializers/api/enterprise_serializer.rb index 287ebfe872..3210c1d2af 100644 --- a/app/serializers/api/enterprise_serializer.rb +++ b/app/serializers/api/enterprise_serializer.rb @@ -41,7 +41,7 @@ class Api::CachedEnterpriseSerializer < ActiveModel::Serializer attributes :name, :id, :description, :latitude, :longitude, :long_description, :website, :instagram, :linkedin, :twitter, :facebook, :is_primary_producer, :is_distributor, :phone, :visible, - :email, :hash, :logo, :promo_image, :path, :pickup, :delivery, + :email_address, :hash, :logo, :promo_image, :path, :pickup, :delivery, :icon, :icon_font, :producer_icon_font, :category, :producers, :hubs attributes :taxons, :supplied_taxons @@ -67,8 +67,8 @@ class Api::CachedEnterpriseSerializer < ActiveModel::Serializer services ? services[:delivery] : false end - def email - object.email.to_s.reverse + def email_address + object.email_address.to_s.reverse end def hash diff --git a/app/views/admin/enterprise_groups/index.html.haml b/app/views/admin/enterprise_groups/index.html.haml index 13bc19e364..e78dadc72c 100644 --- a/app/views/admin/enterprise_groups/index.html.haml +++ b/app/views/admin/enterprise_groups/index.html.haml @@ -1,9 +1,9 @@ = content_for :page_title do Enterprise Groups -= content_for :page_actions do - %li#new_enterprise_group_link - = button_link_to "New Enterprise Group", main_app.new_admin_enterprise_group_path, :icon => 'add', :id => 'admin_new_enterprise_group_link' +- if admin_user? + = content_for :page_actions do + %li= button_link_to "New Enterprise Group", main_app.new_admin_enterprise_group_path %table.index#listing_enterprise_groups %thead diff --git a/app/views/admin/enterprises/_new_form.html.haml b/app/views/admin/enterprises/_new_form.html.haml index 3ab9392712..ba8fce56ae 100644 --- a/app/views/admin/enterprises/_new_form.html.haml +++ b/app/views/admin/enterprises/_new_form.html.haml @@ -1,6 +1,7 @@ .row .three.columns.alpha = f.label :name + %span.required * .nine.columns.omega = f.text_field :name, { placeholder: "eg. Professor Plum's Biodynamic Truffles", class: "fullwidth" } @@ -8,6 +9,7 @@ .row .three.columns.alpha =f.label :owner_id, 'Owner' + %span.required * %div{'ofn-with-tip' => "The primary user responsible for this enterprise."} %a What's this? .nine.columns.omega @@ -50,13 +52,9 @@ = f.text_field :contact, { placeholder: "eg. Gustav Plum"} .row .alpha.three.columns - = f.label :email + = f.label :email_address .omega.nine.columns - = f.text_field :email, { placeholder: "eg. gustav@truffles.com", "ng-model" => "Enterprise.email" } - .alert-box - %i.icon-info-sign - If we don't recognise this email address we'll send you a confirmation email to make sure it belongs to you. You'll need to use the link in the email we send to fully activate your new enterprise. - %a.close{ href: "" } × + = f.text_field :email_address, { placeholder: "eg. gustav@truffles.com", "ng-model" => "Enterprise.email_address" } .row .alpha.three.columns = f.label :phone @@ -72,6 +70,7 @@ .row .three.columns.alpha = af.label :address1 + %span.required * .nine.columns.omega = af.text_field :address1, { placeholder: "eg. 123 High Street"} .row @@ -84,6 +83,7 @@ = af.label :city, 'Suburb' \/ = af.label :zipcode, 'Postcode' + %span.required * .four.columns = af.text_field :city, { placeholder: "eg. Northcote"} .five.columns.omega diff --git a/app/views/admin/enterprises/form/_contact.html.haml b/app/views/admin/enterprises/form/_contact.html.haml index df28b6a921..28bbd6014b 100644 --- a/app/views/admin/enterprises/form/_contact.html.haml +++ b/app/views/admin/enterprises/form/_contact.html.haml @@ -1,11 +1,3 @@ --if @enterprise.pending_any_confirmation? - .alert-box - - email = @enterprise.confirmed? ? @enterprise.unconfirmed_email : @enterprise.email - Email confirmation is pending. - We've sent a confirmation email to - %strong= "#{email}." - = link_to('Resend', main_app.enterprise_confirmation_path(enterprise: { id: @enterprise.id, email: email } ), method: :post) - %a.close{ href: "#" } × .row .alpha.three.columns = f.label :contact, 'Name' @@ -13,15 +5,9 @@ = f.text_field :contact, { placeholder: "eg. Gustav Plum"} .row .alpha.three.columns - = f.label :email - %span.required * + = f.label :email_address .omega.eight.columns - = f.text_field :email, { placeholder: "eg. gustav@truffles.com", "ng-model" => "Enterprise.email" } -.row{ ng: { hide: "pristineEmail == null || pristineEmail == Enterprise.email"} } - .alpha.three.columns -   - .omega.eight.columns - Note: A new email address may need to be confirmed prior to use + = f.text_field :email_address, { placeholder: "eg. gustav@truffles.com" } .row .alpha.three.columns = f.label :phone diff --git a/app/views/admin/enterprises/form/_users.html.haml b/app/views/admin/enterprises/form/_users.html.haml index 289a85d7a1..42e25fad0a 100644 --- a/app/views/admin/enterprises/form/_users.html.haml +++ b/app/views/admin/enterprises/form/_users.html.haml @@ -1,6 +1,15 @@ - owner_email = @enterprise.andand.owner.andand.email || "" - full_permissions = (spree_current_user.admin? || spree_current_user == @enterprise.andand.owner) +-if @enterprise.pending_any_confirmation? + .alert-box + - email = @enterprise.confirmed? ? @enterprise.unconfirmed_email : @enterprise.email + Email confirmation is pending. + We've sent a confirmation email to + %strong= "#{email}." + = link_to('Resend', main_app.enterprise_confirmation_path(enterprise: { id: @enterprise.id, email: email } ), method: :post) + %a.close{ href: "#" } × + .row .three.columns.alpha =f.label :owner_id, 'Owner' @@ -14,6 +23,24 @@ - else = owner_email +.row + .three.columns.alpha + = f.label :email, 'Notifications' + - if full_permissions + %span.required * + .with-tip{'data-powertip' => "Notifications about orders will be send to this email address."} + %a What's this? + .eight.columns.omega + - if full_permissions + = f.text_field :email, { placeholder: "eg. gustav@truffles.com", "ng-model" => "Enterprise.email" } + - else + = @enterprise.email +.row{ ng: { hide: "pristineEmail == null || pristineEmail == Enterprise.email"} } + .alpha.three.columns +   + .omega.eight.columns + Note: A new email address may need to be confirmed prior to use + .row .three.columns.alpha =f.label :user_ids, 'Managers' diff --git a/app/views/json/partials/_enterprise.rabl b/app/views/json/partials/_enterprise.rabl index 6e17cf3c58..ca99b9d14c 100644 --- a/app/views/json/partials/_enterprise.rabl +++ b/app/views/json/partials/_enterprise.rabl @@ -1,7 +1,7 @@ attributes :name, :id, :description, :latitude, :longitude, :long_description, :website, :instagram, :linkedin, :twitter, :facebook, :is_primary_producer, :is_distributor, :phone -node :email do |enterprise| - enterprise.email.to_s.reverse +node :email_address do |enterprise| + enterprise.email_address.to_s.reverse end child :address do diff --git a/app/views/order_cycles/_orders_closed.html.haml b/app/views/order_cycles/_orders_closed.html.haml index ae0568ae2d..782c680add 100644 --- a/app/views/order_cycles/_orders_closed.html.haml +++ b/app/views/order_cycles/_orders_closed.html.haml @@ -12,6 +12,6 @@ = t :ocs_closed_opens, time: distance_of_time_in_words_to_now(next_oc.orders_open_at) %p - = t(:ocs_closed_email, email: current_distributor.email) if current_distributor.email + = t(:ocs_closed_email, email: current_distributor.email_address) if current_distributor.email_address %br/ = t(:ocs_closed_phone, phone: current_distributor.phone) if current_distributor.phone diff --git a/app/views/producers/_fat.html.haml b/app/views/producers/_fat.html.haml index c1de090978..9faa239c02 100644 --- a/app/views/producers/_fat.html.haml +++ b/app/views/producers/_fat.html.haml @@ -23,7 +23,7 @@ %div.show-for-medium-up{"ng-if" => "producer.supplied_taxons.length==0"}   - %div{"bo-if" => "producer.email || producer.website || producer.phone"} + %div{"bo-if" => "producer.email_address || producer.website || producer.phone"} %label = t :producers_contact @@ -31,9 +31,9 @@ = t :producers_contact_phone %span{"bo-text" => "producer.phone"} - %p.word-wrap{"bo-if" => "producer.email"} - %a{"bo-href" => "producer.email | stripUrl", target: "_blank", mailto: true} - %span.email{"bo-bind" => "producer.email | stripUrl"} + %p.word-wrap{"bo-if" => "producer.email_address"} + %a{"bo-href" => "producer.email_address | stripUrl", target: "_blank", mailto: true} + %span.email{"bo-bind" => "producer.email_address | stripUrl"} %p.word-wrap{"bo-if" => "producer.website"} %a{"bo-href-i" => "http://{{producer.website | stripUrl}}", target: "_blank" } diff --git a/app/views/shopping_shared/_contact.html.haml b/app/views/shopping_shared/_contact.html.haml index a88c421270..100d64d958 100644 --- a/app/views/shopping_shared/_contact.html.haml +++ b/app/views/shopping_shared/_contact.html.haml @@ -18,7 +18,7 @@ = current_distributor.address.zipcode .small-12.large-4.columns - - if current_distributor.website || current_distributor.email + - if current_distributor.website || current_distributor.email_address %div.center .header = t :shopping_contact_web @@ -27,10 +27,10 @@ %a{href: "http://#{current_distributor.website}", target: "_blank" } = current_distributor.website %br - - unless current_distributor.email.blank? - %a{href: current_distributor.email.reverse, mailto: true} + - unless current_distributor.email_address.blank? + %a{href: current_distributor.email_address.reverse, mailto: true} %span.email - = current_distributor.email.reverse + = current_distributor.email_address.reverse .small-12.large-4.columns - if current_distributor.twitter.present? || current_distributor.facebook.present? || current_distributor.linkedin.present? || current_distributor.instagram.present? diff --git a/config/locales/en.yml b/config/locales/en.yml index 7603457981..323288edc2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -602,8 +602,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using who_is_managing_enterprise: "Who is responsible for managing %{enterprise}?" enterprise_contact: "Primary Contact" enterprise_contact_required: "You need to enter a primary contact." - enterprise_email: "Email address" - enterprise_email_required: "You need to enter valid email address." + enterprise_email_address: "Email address" enterprise_phone: "Phone number" back: "Back" continue: "Continue" diff --git a/db/migrate/20160205044930_add_email_address_to_enterprises.rb b/db/migrate/20160205044930_add_email_address_to_enterprises.rb new file mode 100644 index 0000000000..b1047fe4b8 --- /dev/null +++ b/db/migrate/20160205044930_add_email_address_to_enterprises.rb @@ -0,0 +1,5 @@ +class AddEmailAddressToEnterprises < ActiveRecord::Migration + def change + add_column :enterprises, :email_address, :string + end +end diff --git a/db/migrate/20160212092908_set_enterprise_email_address.rb b/db/migrate/20160212092908_set_enterprise_email_address.rb new file mode 100644 index 0000000000..a43591624a --- /dev/null +++ b/db/migrate/20160212092908_set_enterprise_email_address.rb @@ -0,0 +1,8 @@ +class SetEnterpriseEmailAddress < ActiveRecord::Migration + def up + Enterprise.all.each do |enterprise| + enterprise.email_address = enterprise.email + enterprise.save + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 85b940db9d..cdab93834c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -347,6 +347,7 @@ ActiveRecord::Schema.define(:version => 20160302044850) do t.boolean "producer_profile_only", :default => false t.string "permalink", :null => false t.boolean "charges_sales_tax", :default => false, :null => false + t.string "email_address" end add_index "enterprises", ["address_id"], :name => "index_enterprises_on_address_id" diff --git a/spec/features/admin/enterprises_spec.rb b/spec/features/admin/enterprises_spec.rb index 4bd58715eb..92ac89015e 100644 --- a/spec/features/admin/enterprises_spec.rb +++ b/spec/features/admin/enterprises_spec.rb @@ -47,7 +47,7 @@ feature %q{ 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_email_address', :with => 'info@eaterprises.com.au' fill_in 'enterprise_website', :with => 'http://eaterprises.com.au' fill_in 'enterprise_address_attributes_address1', :with => '35 Ballantyne St' @@ -130,7 +130,7 @@ feature %q{ 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_email_address', :with => 'info@eaterprises.com.au' fill_in 'enterprise_website', :with => 'http://eaterprises.com.au' click_link "Social" @@ -312,7 +312,7 @@ feature %q{ click_link 'Enterprises' click_link 'New Enterprise' fill_in 'enterprise_name', with: 'zzz' - fill_in 'enterprise_email', with: 'bob@example.com' + fill_in 'enterprise_email_address', with: 'bob@example.com' fill_in 'enterprise_address_attributes_address1', with: 'z' fill_in 'enterprise_address_attributes_city', with: 'z' fill_in 'enterprise_address_attributes_zipcode', with: 'z' diff --git a/spec/features/admin/payment_method_spec.rb b/spec/features/admin/payment_method_spec.rb index c208d7dd47..caf52c08f8 100644 --- a/spec/features/admin/payment_method_spec.rb +++ b/spec/features/admin/payment_method_spec.rb @@ -44,7 +44,7 @@ feature %q{ select2_select "PayPal Express", from: "payment_method_type" click_button 'Update' - expect(flash_message).to eq 'Payment Method has been successfully updated!' + flash_message.should eq 'Payment Method has been successfully updated!' payment_method = Spree::PaymentMethod.find_by_name('New PM Name') expect(payment_method.distributors).to include @distributors[1], @distributors[2] diff --git a/spec/features/admin/variant_overrides_spec.rb b/spec/features/admin/variant_overrides_spec.rb index 037c3e7cf0..a3a08c2466 100644 --- a/spec/features/admin/variant_overrides_spec.rb +++ b/spec/features/admin/variant_overrides_spec.rb @@ -84,7 +84,7 @@ feature %q{ expect(page).to have_selector "#v_#{variant_related.id}" select2_select producer.name, from: 'producer_filter' expect(page).to have_selector "#v_#{variant.id}" - expect(page).to_not have_selector "#v_#{variant_related.id}" + expect(page).to have_no_selector "#v_#{variant_related.id}" select2_select 'All', from: 'producer_filter' # Filters based on the quick search box @@ -92,7 +92,7 @@ feature %q{ expect(page).to have_selector "#v_#{variant_related.id}" fill_in 'query', with: product.name expect(page).to have_selector "#v_#{variant.id}" - expect(page).to_not have_selector "#v_#{variant_related.id}" + expect(page).to have_no_selector "#v_#{variant_related.id}" fill_in 'query', with: '' # Clears the filters @@ -100,8 +100,8 @@ feature %q{ expect(page).to have_selector "tr#v_#{variant_related.id}" select2_select producer.name, from: 'producer_filter' fill_in 'query', with: product_related.name - expect(page).to_not have_selector "tr#v_#{variant.id}" - expect(page).to_not have_selector "tr#v_#{variant_related.id}" + expect(page).to have_no_selector "tr#v_#{variant.id}" + expect(page).to have_no_selector "tr#v_#{variant_related.id}" click_button 'Clear All' expect(page).to have_selector "tr#v_#{variant.id}" expect(page).to have_selector "tr#v_#{variant_related.id}" @@ -113,15 +113,15 @@ feature %q{ expect(page).to have_selector "tr#v_#{variant.id}" expect(page).to have_selector "tr#v_#{variant_related.id}" within "tr#v_#{variant.id}" do click_button 'Hide' end - expect(page).to_not have_selector "tr#v_#{variant.id}" + expect(page).to have_no_selector "tr#v_#{variant.id}" expect(page).to have_selector "tr#v_#{variant_related.id}" first("div#views-dropdown").click first("div#views-dropdown div.menu div.menu_item", text: "Hidden Products").click expect(page).to have_selector "tr#v_#{variant.id}" - expect(page).to_not have_selector "tr#v_#{variant_related.id}" + expect(page).to have_no_selector "tr#v_#{variant_related.id}" within "tr#v_#{variant.id}" do click_button 'Add' end - expect(page).to_not have_selector "tr#v_#{variant.id}" - expect(page).to_not have_selector "tr#v_#{variant_related.id}" + expect(page).to have_no_selector "tr#v_#{variant.id}" + expect(page).to have_no_selector "tr#v_#{variant_related.id}" first("div#views-dropdown").click first("div#views-dropdown div.menu div.menu_item", text: "Inventory Products").click expect(page).to have_selector "tr#v_#{variant.id}" @@ -319,8 +319,8 @@ feature %q{ end it "alerts the user to the presence of new products, and allows them to be added or hidden", retry: 3 do - expect(page).to_not have_selector "table#variant-overrides tr#v_#{variant1.id}" - expect(page).to_not have_selector "table#variant-overrides tr#v_#{variant2.id}" + expect(page).to have_no_selector "table#variant-overrides tr#v_#{variant1.id}" + expect(page).to have_no_selector "table#variant-overrides tr#v_#{variant2.id}" expect(page).to have_selector '.alert-row span.message', text: "There are 1 new products available to add to your inventory." click_button "Review Now" @@ -330,17 +330,17 @@ feature %q{ expect(page).to have_selector "table#new-products tr#v_#{variant2.id}" within "table#new-products tr#v_#{variant1.id}" do click_button 'Add' end within "table#new-products tr#v_#{variant2.id}" do click_button 'Hide' end - expect(page).to_not have_selector "table#new-products tr#v_#{variant1.id}" - expect(page).to_not have_selector "table#new-products tr#v_#{variant2.id}" + expect(page).to have_no_selector "table#new-products tr#v_#{variant1.id}" + expect(page).to have_no_selector "table#new-products tr#v_#{variant2.id}" click_button "Back to my inventory" expect(page).to have_selector "table#variant-overrides tr#v_#{variant1.id}" - expect(page).to_not have_selector "table#variant-overrides tr#v_#{variant2.id}" + expect(page).to have_no_selector "table#variant-overrides tr#v_#{variant2.id}" first("div#views-dropdown").click first("div#views-dropdown div.menu div.menu_item", text: "Hidden Products").click - expect(page).to_not have_selector "table#hidden-products tr#v_#{variant1.id}" + expect(page).to have_no_selector "table#hidden-products tr#v_#{variant1.id}" expect(page).to have_selector "table#hidden-products tr#v_#{variant2.id}" end end diff --git a/spec/features/consumer/registration_spec.rb b/spec/features/consumer/registration_spec.rb index d36cd48f7d..0e54011f1c 100644 --- a/spec/features/consumer/registration_spec.rb +++ b/spec/features/consumer/registration_spec.rb @@ -38,7 +38,7 @@ feature "Registration", js: true do # Filling in Contact Details expect(page).to have_content 'Who is responsible for managing My Awesome Enterprise?' fill_in 'enterprise_contact', with: 'Saskia Munroe' - page.should have_field 'enterprise_email', with: user.email + page.should have_field 'enterprise_email_address', with: user.email fill_in 'enterprise_phone', with: '12 3456 7890' click_button 'Continue' diff --git a/spec/models/enterprise_spec.rb b/spec/models/enterprise_spec.rb index 08c10dd31e..b8360094ec 100644 --- a/spec/models/enterprise_spec.rb +++ b/spec/models/enterprise_spec.rb @@ -180,7 +180,6 @@ describe Enterprise do describe "validations" do subject { FactoryGirl.create(:distributor_enterprise) } it { should validate_presence_of(:name) } - it { should validate_presence_of(:email) } it { should validate_uniqueness_of(:permalink) } it { should ensure_length_of(:description).is_at_most(255) } @@ -210,9 +209,15 @@ describe Enterprise do end it "does not prohibit the saving of an enterprise with no name clash" do - enterprise.email = 'new@email.com' enterprise.should be_valid end + + it "takes the owner's email address as default email" do + enterprise.email = nil + enterprise.should be_valid + enterprise.email.should be_present + enterprise.email.should eq owner.email + end end describe "preferred_shopfront_taxon_order" do