diff --git a/app/assets/javascripts/curate/link_users.js.coffee b/app/assets/javascripts/curate/link_users.js.coffee index 9237c811..7bb3f7c4 100644 --- a/app/assets/javascripts/curate/link_users.js.coffee +++ b/app/assets/javascripts/curate/link_users.js.coffee @@ -104,7 +104,7 @@ $.getJSON $targetElement.data('url'), { q: request.term + "*" }, ( data, status, xhr ) -> matches = [] $.each data.response.docs, (idx, val) -> - matches.push {label: val['desc_metadata__name_tesim'][0], value: val['id']} + matches.push {label: (val['desc_metadata__first_name_tesim'] + " " + val['desc_metadata__last_name_tesim']), value: val['id']} response( matches ) minLength: 2 focus: ( event, ui ) -> diff --git a/app/assets/javascripts/curate/proxy_rights.js.coffee b/app/assets/javascripts/curate/proxy_rights.js.coffee index a880b7b5..a2ede137 100644 --- a/app/assets/javascripts/curate/proxy_rights.js.coffee +++ b/app/assets/javascripts/curate/proxy_rights.js.coffee @@ -73,7 +73,7 @@ $.getJSON $targetElement.data('url'), { q: request.term, user: true}, ( data, status, xhr ) -> matches = [] $.each data.response.docs, (idx, val) -> - matches.push {label: val['desc_metadata__name_tesim'][0], value: val['id']} + matches.push {label: (val['desc_metadata__first_name_tesim'] + " " + val['desc_metadata__last_name_tesim']), value: val['id']} response( matches ) minLength: 2 focus: ( event, ui ) -> diff --git a/app/controllers/concerns/curate_controller.rb b/app/controllers/concerns/curate_controller.rb index bc92d5ba..2034a588 100644 --- a/app/controllers/concerns/curate_controller.rb +++ b/app/controllers/concerns/curate_controller.rb @@ -73,7 +73,7 @@ def render_response_for_error(wrapper) def configure_permitted_parameters full_list = [:email, :password, :password_confirmation, :current_password, - :name, :email, :alternate_email, + :name, :last_name, :first_name, :email, :alternate_email, :date_of_birth, :gender, :title, :campus_phone_number, :alternate_phone_number, :personal_webpage, :blog, :files] diff --git a/app/controllers/curate/people_controller.rb b/app/controllers/curate/people_controller.rb index 98daf660..99939c2e 100644 --- a/app/controllers/curate/people_controller.rb +++ b/app/controllers/curate/people_controller.rb @@ -18,7 +18,7 @@ def self.search_config initialized_config = Curate.configuration.search_config['people'] # If the hash is empty, set reasonable defaults for this search type if initialized_config.nil? - Hash['qf' => 'desc_metadata__name_tesim','fl' => 'desc_metadata__name_tesim id','qt' => 'search','rows' => 10] + Hash['qf' => 'desc_metadata__first_name_tesim desc_metadata__last_name_tesim','fl' => 'desc_metadata__first_name_tesim desc_metadata__last_name_tesim id','qt' => 'search','rows' => 10] else initialized_config end diff --git a/app/controllers/curation_concern/generic_works_controller.rb b/app/controllers/curation_concern/generic_works_controller.rb index fc79eb51..d92e5020 100644 --- a/app/controllers/curation_concern/generic_works_controller.rb +++ b/app/controllers/curation_concern/generic_works_controller.rb @@ -53,7 +53,7 @@ def after_create_response # Override setup_form in concrete controllers to get the form ready for display def setup_form if curation_concern.respond_to?(:creator) - curation_concern.creator << current_user.name if curation_concern.creator.empty? && !current_user.can_make_deposits_for.any? + curation_concern.creator << current_user.inverted_name if curation_concern.creator.empty? && !current_user.can_make_deposits_for.any? end curation_concern.editors << current_user.person if curation_concern.editors.blank? diff --git a/app/helpers/blacklight_helper.rb b/app/helpers/blacklight_helper.rb index fcb201e2..fb890804 100644 --- a/app/helpers/blacklight_helper.rb +++ b/app/helpers/blacklight_helper.rb @@ -16,4 +16,9 @@ module BlacklightHelper def application_name t('sufia.product_name') end + + ## Override the default seperator used to display multivalue fields on the index view + def field_value_separator + tag(:br) + end end diff --git a/app/helpers/curate/collections_helper.rb b/app/helpers/curate/collections_helper.rb index d34dcb12..656c2702 100644 --- a/app/helpers/curate/collections_helper.rb +++ b/app/helpers/curate/collections_helper.rb @@ -121,7 +121,7 @@ def collection_line_item(collection, terminate, options={}) def creators(work) if work.respond_to?(:creator) - "(#{work.creator.to_a.join(', ')})" + "(#{work.creator.to_a.join('; ')})" else '' end diff --git a/app/models/account.rb b/app/models/account.rb index 6adea5e7..d524edbe 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -215,7 +215,7 @@ def profile_title end def sync_profile_title_to_name(update_attributes) - return true unless update_attributes[:name] + return true unless update_attributes[:last_name] or update_attributes[:first_name] profile.update(title: profile_title) end diff --git a/app/models/classify_concern.rb b/app/models/classify_concern.rb index 515ae92a..546d6a55 100644 --- a/app/models/classify_concern.rb +++ b/app/models/classify_concern.rb @@ -1,6 +1,6 @@ require 'active_attr' class ClassifyConcern - UPCOMING_CONCERNS = ['ETD'] + UPCOMING_CONCERNS = [] def self.normalize_concern_name(name) name.to_s.classify diff --git a/app/models/curate/user_behavior/base.rb b/app/models/curate/user_behavior/base.rb index b17ab296..28aa8e80 100644 --- a/app/models/curate/user_behavior/base.rb +++ b/app/models/curate/user_behavior/base.rb @@ -32,7 +32,15 @@ def manager_usernames end def name - read_attribute(:name) || user_key + name = "#{read_attribute(:first_name)} #{read_attribute(:last_name)}" + return name unless name.blank? + user_key + end + + def inverted_name + name = "#{read_attribute(:last_name)}, #{read_attribute(:first_name)}" + return name unless read_attribute(:last_name).blank? or read_attribute(:first_name).blank? + "" end def groups diff --git a/app/repository_datastreams/person_metadata_datastream.rb b/app/repository_datastreams/person_metadata_datastream.rb index 82cfe28c..3b8019f6 100644 --- a/app/repository_datastreams/person_metadata_datastream.rb +++ b/app/repository_datastreams/person_metadata_datastream.rb @@ -5,6 +5,14 @@ class PersonMetadataDatastream < ActiveFedora::NtriplesRDFDatastream index.as :stored_searchable end + map.first_name(to: "firstName", in: RDF::FOAF) do |index| + index.as :stored_searchable + end + + map.last_name(to: "lastName", in: RDF::FOAF) do |index| + index.as :stored_searchable + end + map.title(to: "title", in: RDF::FOAF) do |index| index.as :stored_searchable end diff --git a/app/repository_models/person.rb b/app/repository_models/person.rb index dbf6ff2e..8fb22eb5 100644 --- a/app/repository_models/person.rb +++ b/app/repository_models/person.rb @@ -23,6 +23,12 @@ class Person < ActiveFedora::Base datastream: :descMetadata, multiple: false, label: "Name" + attribute :first_name, + datastream: :descMetadata, multiple: false + + attribute :last_name, + datastream: :descMetadata, multiple: false + attribute :email, datastream: :descMetadata, multiple: false @@ -53,6 +59,12 @@ class Person < ActiveFedora::Base attribute :gender, datastream: :descMetadata, multiple: false + def name + name = "#{self.first_name} #{self.last_name}" + return name unless name.blank? or self.first_name.blank? or self.last_name.blank? + user_key + end + def validate_work(work) !work.is_a?(Person) && !work.is_a?(Collection) && work.is_a?(CurationConcern::Work) end @@ -88,18 +100,6 @@ def date_uploaded Time.new(create_date).strftime("%Y-%m-%d") end - def first_name - name_parser.given - end - - def last_name - name_parser.family - end - - def name_parser - Namae.parse(self.name).first - end - def user_key if user user.user_key diff --git a/app/views/curate/people/show.html.erb b/app/views/curate/people/show.html.erb index 88ee994b..801185a3 100644 --- a/app/views/curate/people/show.html.erb +++ b/app/views/curate/people/show.html.erb @@ -49,7 +49,7 @@
- <% @person.terms_for_display.reject{|attribute| (attribute == :name) || (attribute == :title)}.each do |attribute_name| %> + <% @person.terms_for_display.reject{|attribute| (attribute == :last_name) || (attribute == :first_name) || (attribute == :name) || (attribute == :title)}.each do |attribute_name| %> <% if @person.send(attribute_name).present? %>
<%= derived_label_for( @person, attribute_name) %>:
<% [@person.send(attribute_name)].flatten.compact.each do |value| %> diff --git a/app/views/curation_concern/articles/_form_required_information.html.erb b/app/views/curation_concern/articles/_form_required_information.html.erb index a3f075b4..bea0ab29 100644 --- a/app/views/curation_concern/articles/_form_required_information.html.erb +++ b/app/views/curation_concern/articles/_form_required_information.html.erb @@ -22,8 +22,7 @@ <%= f.input :creator, as: :multi_value, label: 'Author', - required: true, - input_html: { value: "@current_user.name" } %> + required: true %> <%= render 'form_input_help_block', help_text: I18n.t('sufia.work.input_field.creator.help', work_type: curation_concern.human_readable_type) %> diff --git a/app/views/curation_concern/datasets/_form_required_information.html.erb b/app/views/curation_concern/datasets/_form_required_information.html.erb index b1f9ddd7..ba27f2d6 100644 --- a/app/views/curation_concern/datasets/_form_required_information.html.erb +++ b/app/views/curation_concern/datasets/_form_required_information.html.erb @@ -21,8 +21,7 @@
<%= f.input :creator, as: :multi_value, - required: true, - input_html: { value: "@current_user.name" } %> + required: true %>
<%= render 'form_input_help_block', help_text: I18n.t('sufia.work.input_field.creator.help', work_type: curation_concern.human_readable_type) %> diff --git a/app/views/curation_concern/documents/_form_required_information.html.erb b/app/views/curation_concern/documents/_form_required_information.html.erb index 666be583..52e8b3c0 100644 --- a/app/views/curation_concern/documents/_form_required_information.html.erb +++ b/app/views/curation_concern/documents/_form_required_information.html.erb @@ -21,8 +21,7 @@
<%= f.input :creator, as: :multi_value, - required: true, - input_html: { value: "@current_user.name" } %> + required: true %>
<%= render 'form_input_help_block', help_text: I18n.t('sufia.work.input_field.creator.help', work_type: curation_concern.human_readable_type) %> diff --git a/app/views/curation_concern/images/_form_required_information.html.erb b/app/views/curation_concern/images/_form_required_information.html.erb index 666be583..52e8b3c0 100644 --- a/app/views/curation_concern/images/_form_required_information.html.erb +++ b/app/views/curation_concern/images/_form_required_information.html.erb @@ -21,8 +21,7 @@
<%= f.input :creator, as: :multi_value, - required: true, - input_html: { value: "@current_user.name" } %> + required: true %>
<%= render 'form_input_help_block', help_text: I18n.t('sufia.work.input_field.creator.help', work_type: curation_concern.human_readable_type) %> diff --git a/app/views/registrations/_form_attributes.html.erb b/app/views/registrations/_form_attributes.html.erb index 0fa59b43..26a0bf1b 100644 --- a/app/views/registrations/_form_attributes.html.erb +++ b/app/views/registrations/_form_attributes.html.erb @@ -3,7 +3,8 @@
Personal Information - <%= f.input :name %> + <%= f.input :first_name, hint: 'Please include any middle names or initials here, if desired', required: true %> + <%= f.input :last_name, required: true %> <%= f.input :title, label: 'Job Title' %> <%= f.input :personal_webpage %> <%= f.input :blog %> diff --git a/app/views/registrations/_form_password_management.html.erb b/app/views/registrations/_form_password_management.html.erb index 91a898b6..86a97114 100644 --- a/app/views/registrations/_form_password_management.html.erb +++ b/app/views/registrations/_form_password_management.html.erb @@ -15,7 +15,7 @@ Authorize Your Changes

Enter your current password to confirm your changes

- <%= f.input :current_password, required: true %> + <%= f.input :current_password, required: true, input_html: { autocomplete: "off" } %>
diff --git a/config/locales/sufia.en.yml b/config/locales/sufia.en.yml index 9e9c35a3..f92e2163 100644 --- a/config/locales/sufia.en.yml +++ b/config/locales/sufia.en.yml @@ -38,7 +38,7 @@ en: coverage_temporal: help: "

Enter the period or date associated with the subject of your %{work_type}.

Examples:

  • 19th century
  • Middle Ages
  • Jurassic Period
  • " creator: - help: "

    Enter the names of creators of the %{work_type}. This could include important authors, co-authors, or other significant contributors.

    " + help: "

    Enter the names of creators of the %{work_type}, in LastName, FirstName format. These could include important authors, co-authors, or other significant contributors.

    " cultural_context: help: "

    Enter the name of culture, people, or adjectival form of country associated with the subject of your %{work_type}.

    Examples:

  • American
  • Vietnamese
  • Inuit
  • " date_created: diff --git a/db/migrate/20150423153556_add_family_name_and_given_name_to_user.rb b/db/migrate/20150423153556_add_family_name_and_given_name_to_user.rb new file mode 100644 index 00000000..f0a3a9e9 --- /dev/null +++ b/db/migrate/20150423153556_add_family_name_and_given_name_to_user.rb @@ -0,0 +1,6 @@ +class AddFamilyNameAndGivenNameToUser < ActiveRecord::Migration + def change + add_column User.table_name, :first_name, :string + add_column User.table_name, :last_name, :string + end +end diff --git a/spec/controllers/curate/people_controller_spec.rb b/spec/controllers/curate/people_controller_spec.rb index 67610eca..93a5736c 100644 --- a/spec/controllers/curate/people_controller_spec.rb +++ b/spec/controllers/curate/people_controller_spec.rb @@ -26,28 +26,28 @@ describe "searching via json" do before(:each) do - @katie = FactoryGirl.create(:person, name: 'Katie F. White-Kopp') - @alvin = FactoryGirl.create(:person, name: 'A. S. Mitchell') - @john = FactoryGirl.create(:person_with_user, name: 'John Corcoran III') + @katie = FactoryGirl.create(:person, first_name: 'Katie F.', last_name: 'White-Kopp') + @alvin = FactoryGirl.create(:person, first_name: 'A. S.', last_name: 'Mitchell') + @john = FactoryGirl.create(:person_with_user, first_name: 'John', last_name: 'Corcoran III') end it "should return results on full first name match" do get :index, q: 'Katie', format: :json json = JSON.parse(response.body) - json['response']['docs'].should == [{"id"=>@katie.pid, "desc_metadata__name_tesim"=>["Katie F. White-Kopp"]}] + json['response']['docs'].should == [{"id"=>@katie.pid, "desc_metadata__first_name_tesim"=>["Katie F."], "desc_metadata__last_name_tesim"=>["White-Kopp"]}] end it "should return results on full last name match" do get :index, q: 'Mitchell', format: :json json = JSON.parse(response.body) - json['response']['docs'].should == [{"id"=>@alvin.pid, "desc_metadata__name_tesim"=>["A. S. Mitchell"]}] + json['response']['docs'].should == [{"id"=>@alvin.pid, "desc_metadata__first_name_tesim"=>["A. S."], "desc_metadata__last_name_tesim"=>["Mitchell"]}] end describe "when constrained to users" do it "should return users" do get :index, q: '', user: true, format: :json json = JSON.parse(response.body) - json['response']['docs'].should == [{"id"=>@john.pid, "desc_metadata__name_tesim"=>["John Corcoran III"]}] + json['response']['docs'].should == [{"id"=>@john.pid, "desc_metadata__first_name_tesim"=>["John"], "desc_metadata__last_name_tesim"=>["Corcoran III"]}] end end diff --git a/spec/curate/internal/factories.rb b/spec/curate/internal/factories.rb index c5b35229..e06ed1df 100644 --- a/spec/curate/internal/factories.rb +++ b/spec/curate/internal/factories.rb @@ -3,7 +3,8 @@ FactoryGirl.define do factory :user do sequence(:email) {|n| "email-#{srand}@test.com" } - sequence(:name) {|n| "User Named #{n}" } + sequence(:first_name) {|n| "First #{n}" } + sequence(:last_name) {|n| "Last #{n}" } agreed_to_terms_of_service true user_does_not_require_profile_update true password 'a password' diff --git a/spec/features/generic_work_spec.rb b/spec/features/generic_work_spec.rb index 7eae3a01..4ec3daa6 100644 --- a/spec/features/generic_work_spec.rb +++ b/spec/features/generic_work_spec.rb @@ -139,14 +139,13 @@ end describe 'When I click on the link to create a work: ' do - let(:account) { FactoryGirl.create(:account, name: 'Iron Man') } + let(:account) { FactoryGirl.create(:account, first_name: 'Iron', last_name: 'Man') } let(:user) { account.user } let(:person) { account.person } before { login_as(user) } it 'should have my name set in the creator/contributor list' do visit new_curation_concern_generic_work_path - page.should have_css("a[href$='people/#{person.to_param}']") - page.should have_tag("a[href$='people/#{person.to_param}']", text: "Iron Man") + page.should have_tag("input", value: "Man, Iron") end end diff --git a/spec/features/manager_profile_workflow_spec.rb b/spec/features/manager_profile_workflow_spec.rb index e6378ae6..130ba4cb 100644 --- a/spec/features/manager_profile_workflow_spec.rb +++ b/spec/features/manager_profile_workflow_spec.rb @@ -14,7 +14,8 @@ visit edit_user_path(user.id) - new_name = 'Frodo Baggins' + new_first_name = 'Frodo' + new_last_name = 'Baggins' new_pref = 'pref@example.com' new_alt = 'alt@example.com' new_title = 'student' @@ -24,7 +25,8 @@ new_blog = 'blog.example.com' within('form.edit_user') do - fill_in("user[name]", with: new_name) + fill_in("user[first_name]", with: new_first_name) + fill_in("user[last_name]", with: new_last_name) fill_in("user[email]", with: new_pref) fill_in("user[alternate_email]", with: new_alt) fill_in("user[title]", with: new_title) @@ -43,7 +45,7 @@ user.person.reload # Verify that everything got updated - user.name.should == new_name + user.name.should == "#{new_first_name} #{new_last_name}" user.email.should == new_pref user.alternate_email.should == new_alt user.title.should == new_title diff --git a/spec/features/person_profile_spec.rb b/spec/features/person_profile_spec.rb index 6fc5beb3..b59bdd18 100644 --- a/spec/features/person_profile_spec.rb +++ b/spec/features/person_profile_spec.rb @@ -4,7 +4,7 @@ context 'logged in user' do let(:password) { FactoryGirl.attributes_for(:user).fetch(:password) } - let(:account) { FactoryGirl.create(:account, name: 'Iron Man') } + let(:account) { FactoryGirl.create(:account, first_name: 'Iron', last_name: "Man") } let(:user) { account.user } let(:person) { account.person } before { login_as(user) } @@ -19,7 +19,8 @@ visit catalog_index_path click_link 'My Profile' click_link 'Update Personal Information' - expect(page).to have_field('Name', with: 'Iron Man') + expect(page).to have_field('First name', with: 'Iron') + expect(page).to have_field('Last name', with: 'Man') end it 'should update their name and see the updated value' do @@ -28,7 +29,8 @@ click_link 'Update Personal Information' page.should have_link("Cancel", href: person_path(person)) within('form.edit_user') do - fill_in("user[name]", with: 'Spider Man') + fill_in("user[first_name]", with: 'Spider') + fill_in("user[last_name]", with: 'Man') fill_in("user[current_password]", with: password) click_button "Update Account" end @@ -69,14 +71,21 @@ expect(page).to_not have_link('Marguerite Scypion') #title end end + end + + context "searching" do + let!(:account) { FactoryGirl.create(:account, first_name: 'Bruce', last_name: 'Banner') } + let!(:user) { account.user } + let!(:person) { account.person } + before { login_as(user) } it 'with edit access is displayed in the results' do login_as(user) create_work visit catalog_index_path - fill_in 'Search Curate', with: 'Hulk' + fill_in 'Search Curate', with: 'Bruce' click_button 'keyword-search-submit' within('#documents') do - expect(page).to have_link('The Hulk') #title + expect(page).to have_link('Bruce Banner') #title end end it 'should not show repository managers in search results' do @@ -94,7 +103,7 @@ let(:email) { 'manager2@example.com' } let(:manager_user) { FactoryGirl.create(:user, email: email) } - let(:manager_2) {FactoryGirl.create(:account, email: 'manager@example.com', name: 'Stan Theman')} + let(:manager_2) {FactoryGirl.create(:account, email: 'manager@example.com', first_name: 'Stan', last_name: 'Theman')} let!(:user) {manager_2.user} let!(:person) {manager_2.person} @@ -113,7 +122,7 @@ context 'A person when logged in' do let(:password) { FactoryGirl.attributes_for(:user).fetch(:password) } - let(:account) { FactoryGirl.create(:account, name: 'Iron Man') } + let(:account) { FactoryGirl.create(:account, first_name: 'Iron', last_name: 'Man') } let(:user) { account.user } let(:person) { account.person } let(:image_file){ Rails.root.join('../fixtures/files/image.png') } diff --git a/spec/features/user_profile_workflow_spec.rb b/spec/features/user_profile_workflow_spec.rb index 20be296a..95a8ec0a 100644 --- a/spec/features/user_profile_workflow_spec.rb +++ b/spec/features/user_profile_workflow_spec.rb @@ -12,7 +12,8 @@ visit edit_user_registration_path - new_name = 'Frodo Baggins' + new_first_name = 'Frodo' + new_last_name = 'Baggins' new_pref = 'pref@example.com' new_alt = 'alt@example.com' new_title = 'student' @@ -23,7 +24,8 @@ within('form.edit_user') do fill_in("user[current_password]", with: password) - fill_in("user[name]", with: new_name) + fill_in("user[first_name]", with: new_first_name) + fill_in("user[last_name]", with: new_last_name) fill_in("user[email]", with: new_pref) fill_in("user[alternate_email]", with: new_alt) fill_in("user[title]", with: new_title) @@ -42,7 +44,7 @@ user.person.reload # Verify that everything got updated - user.name.should == new_name + user.name.should == "#{new_first_name} #{new_last_name}" user.email.should == new_pref user.alternate_email.should == new_alt user.title.should == new_title diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 0593882c..f9c0d352 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -70,18 +70,19 @@ end it 'if the person name changes, it keeps profile title in sync' do - new_name = 'Meriadoc Brandybuck' - subject.update_with_password(current_password: password, name: new_name) - person.name.should == new_name + new_first_name = 'Meriadoc' + new_last_name = 'Brandybuck' + subject.update_with_password(current_password: password, first_name: new_first_name, last_name: new_last_name) person.profile.reload - person.profile.title.should == new_name + person.profile.title.should == "#{new_first_name} #{new_last_name}" end it 'if the person name changes, it keeps the user.name in sync' do - new_name = 'Meriadoc Brandybuck' - subject.update_with_password(current_password: password, name: new_name) - person.name.should == new_name - person.user.name.should == new_name + new_first_name = 'Meriadoc' + new_last_name = 'Brandybuck' + subject.update_with_password(current_password: password, first_name: new_first_name, last_name: new_last_name) + person.name.should == "#{new_first_name} #{new_last_name}" + person.user.name.should == "#{new_first_name} #{new_last_name}" end end @@ -100,7 +101,7 @@ describe '#save via .new_with_session' do let(:expected_name) { 'Robert Frost' } - let(:attributes) { FactoryGirl.attributes_for(:user, name: expected_name) } + let(:attributes) { FactoryGirl.attributes_for(:user, first_name: 'Robert', last_name: 'Frost') } let(:session) { {} } subject { Account.new_with_session(attributes, session) } @@ -155,8 +156,7 @@ subject { Account.new(user) } it 'has a default title for the profile' do - subject.name.should == user.name - subject.profile.title.should == user.name + subject.profile.title.should == "Profile" end end diff --git a/spec/views/registrations/edit.html.erb_spec.rb b/spec/views/registrations/edit.html.erb_spec.rb new file mode 100644 index 00000000..f47cb760 --- /dev/null +++ b/spec/views/registrations/edit.html.erb_spec.rb @@ -0,0 +1,18 @@ +require 'spec_helper' + +describe 'registrations/edit' do + let(:person) { FactoryGirl.create(:person_with_user) } + let(:user) { person.user } + + before do + view.stub(:current_user).and_return(user) + view.stub(:resource).and_return(user) + view.stub(:resource_name).and_return(user) + view.stub(:devise_mapping).and_return(Devise.mappings[:user]) + render + end + + it 'displays password fields with autocomplete turned off' do + expect(rendered).to have_tag('input[autocomplete=off]', count: 3) + end +end diff --git a/spec/views/shared/_site_actions.html.erb_spec.rb b/spec/views/shared/_site_actions.html.erb_spec.rb index 5b069b40..e46727f4 100644 --- a/spec/views/shared/_site_actions.html.erb_spec.rb +++ b/spec/views/shared/_site_actions.html.erb_spec.rb @@ -21,8 +21,8 @@ def have_my_actions_section(&block) context 'logged in' do let(:person) { double(pid: 'test:1234') } - let(:name) { 'My Display Name' } - let(:current_user) { User.new(name: name, person: person).tap {|u| u.stub(groups: ['registered'])} } + let(:name) { 'Display Name' } + let(:current_user) { User.new(first_name: 'Display', last_name: 'Name', person: person).tap {|u| u.stub(groups: ['registered'])} } it 'renders a link to create a new user session' do expect(rendered).to_not have_login_section expect(rendered).to have_add_content_section do