enju_leaf 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/user_import_file.rb +24 -14
- data/app/views/my_accounts/show.html.erb +11 -8
- data/app/views/profiles/show.html.erb +8 -6
- data/app/views/user_import_files/show.html.erb +1 -1
- data/app/views/user_import_results/index.html.erb +2 -2
- data/app/views/user_import_results/index.txt.erb +0 -1
- data/config/routes.rb +4 -6
- data/lib/enju_leaf/user.rb +38 -51
- data/lib/enju_leaf/version.rb +1 -1
- data/lib/generators/enju_leaf/setup/setup_generator.rb +2 -0
- data/spec/dummy/config/initializers/assets.rb +12 -0
- data/spec/models/user_import_file_spec.rb +8 -5
- data/spec/models/user_spec.rb +6 -2
- metadata +5 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 689aa74d521ef467b8f7ffedf62d89e53a3eff85
         | 
| 4 | 
            +
              data.tar.gz: 59d301030021945d636fa62b67dffec2039f8bb7
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 68a128ad91643369d17f6fc06922c2a71099103eb3890128fe3cb44b5fc1aa6a40dbce1a12a176d4e2cb30979eb7d244bef42112395d683849ceaff76487ffe1
         | 
| 7 | 
            +
              data.tar.gz: 1f4dc0718ee60d18382d966aede3747fbbfa69dab8ba06a3089981ef1af709bbe9a87e20fe8b1b9a75827820b85dc3107560ae65c76630dd75a7ad5de8fc4a40
         | 
| @@ -46,7 +46,7 @@ class UserImportFile < ActiveRecord::Base | |
| 46 46 | 
             
              # 利用者情報をTSVファイルを用いて作成します。
         | 
| 47 47 | 
             
              def import
         | 
| 48 48 | 
             
                transition_to!(:started)
         | 
| 49 | 
            -
                num = { user_imported: 0, user_found: 0, failed: 0 }
         | 
| 49 | 
            +
                num = { user_imported: 0, user_found: 0, failed: 0, error: 0 }
         | 
| 50 50 | 
             
                rows = open_import_file(create_import_temp_file(user_import))
         | 
| 51 51 | 
             
                row_num = 1
         | 
| 52 52 |  | 
| @@ -57,10 +57,10 @@ class UserImportFile < ActiveRecord::Base | |
| 57 57 |  | 
| 58 58 | 
             
                rows.each do |row|
         | 
| 59 59 | 
             
                  row_num += 1
         | 
| 60 | 
            -
                  next if row['dummy'].to_s.strip.present?
         | 
| 61 60 | 
             
                  import_result = UserImportResult.create!(
         | 
| 62 61 | 
             
                    user_import_file_id: id, body: row.fields.join("\t")
         | 
| 63 62 | 
             
                  )
         | 
| 63 | 
            +
                  next if row['dummy'].to_s.strip.present?
         | 
| 64 64 |  | 
| 65 65 | 
             
                  username = row['username']
         | 
| 66 66 | 
             
                  new_user = User.where(username: username).first
         | 
| @@ -84,31 +84,41 @@ class UserImportFile < ActiveRecord::Base | |
| 84 84 | 
             
                    profile = Profile.new
         | 
| 85 85 | 
             
                    profile.assign_attributes(set_profile_params(row))
         | 
| 86 86 |  | 
| 87 | 
            -
                     | 
| 88 | 
            -
                      new_user. | 
| 89 | 
            -
             | 
| 90 | 
            -
                        num[:user_imported] += 1
         | 
| 87 | 
            +
                    Profile.transaction do
         | 
| 88 | 
            +
                      if new_user.valid? and profile.valid?
         | 
| 89 | 
            +
                        new_user.profile = profile
         | 
| 91 90 | 
             
                        import_result.user = new_user
         | 
| 92 91 | 
             
                        import_result.save!
         | 
| 92 | 
            +
                        num[:user_imported] += 1
         | 
| 93 93 | 
             
                      else
         | 
| 94 | 
            -
                         | 
| 94 | 
            +
                        error_message = "line #{row_num}: "
         | 
| 95 | 
            +
                        error_message += new_user.errors.full_messages.join(" ")
         | 
| 96 | 
            +
                        error_message += profile.errors.full_messages.join(" ")
         | 
| 97 | 
            +
                        import_result.error_message = error_message
         | 
| 98 | 
            +
                        import_result.save
         | 
| 99 | 
            +
                        num[:error] += 1
         | 
| 95 100 | 
             
                      end
         | 
| 96 | 
            -
                    else
         | 
| 97 | 
            -
                      import_result.error_message = new_user.errors.full_messages.join("\n")
         | 
| 98 | 
            -
                      import_result.save
         | 
| 99 | 
            -
                      num[:failed] += 1
         | 
| 100 101 | 
             
                    end
         | 
| 101 102 | 
             
                  end
         | 
| 102 103 | 
             
                end
         | 
| 103 104 |  | 
| 104 105 | 
             
                Sunspot.commit
         | 
| 105 106 | 
             
                rows.close
         | 
| 106 | 
            -
                 | 
| 107 | 
            +
                error_messages = user_import_results.order(:id).pluck(:error_message).compact
         | 
| 108 | 
            +
                unless error_messages.empty?
         | 
| 109 | 
            +
                  self.error_message = '' if error_message.nil?
         | 
| 110 | 
            +
                  self.error_message += "\n"
         | 
| 111 | 
            +
                  self.error_message += error_messages.join("\n")
         | 
| 112 | 
            +
                end
         | 
| 113 | 
            +
                save
         | 
| 114 | 
            +
                if num[:error] >= 1
         | 
| 115 | 
            +
                  transition_to!(:failed)
         | 
| 116 | 
            +
                else
         | 
| 117 | 
            +
                  transition_to!(:completed)
         | 
| 118 | 
            +
                end
         | 
| 107 119 | 
             
                send_message
         | 
| 108 120 | 
             
                num
         | 
| 109 121 | 
             
              rescue => e
         | 
| 110 | 
            -
                self.error_message = "line #{row_num}: #{e.message}"
         | 
| 111 | 
            -
                save
         | 
| 112 122 | 
             
                transition_to!(:failed)
         | 
| 113 123 | 
             
                raise e
         | 
| 114 124 | 
             
              end
         | 
| @@ -8,7 +8,10 @@ | |
| 8 8 | 
             
                <%= current_user.username -%>
         | 
| 9 9 | 
             
              </h2>
         | 
| 10 10 |  | 
| 11 | 
            -
              <p><%= t('activerecord.attributes.profile.user_number') %>: <%=  | 
| 11 | 
            +
              <p><%= t('activerecord.attributes.profile.user_number') %>: <%= @profile.user_number %></p>
         | 
| 12 | 
            +
              <% if defined?(EnjuOrcid) %>
         | 
| 13 | 
            +
                <p><%= 'ORCID iD' %>: <%= link_to orcid_url(@profile), orcid_url(@profile) %></p>
         | 
| 14 | 
            +
              <% end %>
         | 
| 12 15 |  | 
| 13 16 | 
             
              <% if defined?(EnjuCirculation) %>
         | 
| 14 17 | 
             
                <%= render 'profiles/checkout_list', profile: current_user.profile %>
         | 
| @@ -23,24 +26,24 @@ | |
| 23 26 | 
             
              <ul>
         | 
| 24 27 | 
             
                <li><%= link_to t('page.edit'), edit_my_account_path -%></li>
         | 
| 25 28 | 
             
                <li><%= link_to t('activerecord.models.registration'), edit_user_registration_path -%></li>
         | 
| 26 | 
            -
                <%- if can? | 
| 27 | 
            -
                  <li><%= link_to t('page.destroy'),  | 
| 29 | 
            +
                <%- if can?(:destroy, @profile) -%>
         | 
| 30 | 
            +
                  <li><%= link_to t('page.destroy'), @profile, data: {confirm: t('page.are_you_sure')}, method: :delete -%></li>
         | 
| 28 31 | 
             
                <%- end -%>
         | 
| 29 32 | 
             
                <% if defined?(EnjuSearchLog) %>
         | 
| 30 33 | 
             
                  <li><%= link_to t('activerecord.models.search_history'), search_histories_path %></li>
         | 
| 31 34 | 
             
                <% end %>
         | 
| 32 35 | 
             
                <% if defined?(EnjuCirculation) %>
         | 
| 33 | 
            -
                  <li><%= link_to t('activerecord.models.checkout'), checkouts_path %></li>
         | 
| 34 | 
            -
                  <li><%= link_to t('activerecord.models.reserve'), reserves_path %></li>
         | 
| 36 | 
            +
                  <li><%= link_to t('page.listing', model: t('activerecord.models.checkout')), checkouts_path(user_id: @profile.user.username) %></li>
         | 
| 37 | 
            +
                  <li><%= link_to t('page.listing', model: t('activerecord.models.reserve')), reserves_path(user_id: @profile.user.username) %></li>
         | 
| 35 38 | 
             
                <% end %>
         | 
| 36 39 | 
             
                <% if defined?(EnjuQuestion) %>
         | 
| 37 | 
            -
                  <li><%= link_to t('activerecord.models.question'),  | 
| 40 | 
            +
                  <li><%= link_to t('page.listing', model: t('activerecord.models.question')), questions_path(user_id: @profile.user.username) %></li>
         | 
| 38 41 | 
             
                <% end %>
         | 
| 39 42 | 
             
                <% if defined?(EnjuBookmark) %>
         | 
| 40 | 
            -
                  <li><%= link_to t('activerecord.models.bookmark'), bookmarks_path %></li>
         | 
| 43 | 
            +
                  <li><%= link_to t('page.listing', model: t('activerecord.models.bookmark')), bookmarks_path(user_id: @profile.user.username) %></li>
         | 
| 41 44 | 
             
                <% end %>
         | 
| 42 45 | 
             
                <% if defined?(EnjuPurchaseRequest) %>
         | 
| 43 | 
            -
                  <li><%= link_to t('activerecord.models.purchase_request'), purchase_requests_path %></li>
         | 
| 46 | 
            +
                  <li><%= link_to t('page.listing', model: t('activerecord.models.purchase_request')), purchase_requests_path(user_id: @profile.user.username) %></li>
         | 
| 44 47 | 
             
                <% end %>
         | 
| 45 48 | 
             
              </ul>
         | 
| 46 49 | 
             
            </div>
         | 
| @@ -38,7 +38,9 @@ | |
| 38 38 | 
             
                    <li><%= link_to t('page.edit'), edit_profile_path(@profile) -%></li>
         | 
| 39 39 | 
             
                  <% end %>
         | 
| 40 40 | 
             
                  <% if defined?(EnjuMessage) %>
         | 
| 41 | 
            -
                     | 
| 41 | 
            +
                    <% if can? :create, Message %>
         | 
| 42 | 
            +
                      <li><%= link_to t('message.send'), new_message_path(recipient: @profile.user.username) -%></li>
         | 
| 43 | 
            +
                    <% end %>
         | 
| 42 44 | 
             
                  <% end %>
         | 
| 43 45 | 
             
                  <%- if can? :create, Profile -%>
         | 
| 44 46 | 
             
                    <li><%= link_to t('page.new', model: t('activerecord.models.profile')), new_profile_path -%></li>
         | 
| @@ -48,17 +50,17 @@ | |
| 48 50 | 
             
                  <% end %>
         | 
| 49 51 | 
             
                <%- end -%>
         | 
| 50 52 | 
             
                <% if defined?(EnjuCirculation) %>
         | 
| 51 | 
            -
                  <li><%= link_to t('activerecord.models.checkout'), checkouts_path(user_id: @profile.user.username) %></li>
         | 
| 52 | 
            -
                  <li><%= link_to t('activerecord.models.reserve'), reserves_path(user_id: @profile.user.username) %></li>
         | 
| 53 | 
            +
                  <li><%= link_to t('page.listing', model: t('activerecord.models.checkout')), checkouts_path(user_id: @profile.user.username) %></li>
         | 
| 54 | 
            +
                  <li><%= link_to t('page.listing', model: t('activerecord.models.reserve')), reserves_path(user_id: @profile.user.username) %></li>
         | 
| 53 55 | 
             
                <% end %>
         | 
| 54 56 | 
             
                <% if defined?(EnjuQuestion) %>
         | 
| 55 | 
            -
                  <li><%= link_to t('activerecord.models.question'), questions_path(user_id: @profile.user.username) %></li>
         | 
| 57 | 
            +
                  <li><%= link_to t('page.listing', model: t('activerecord.models.question')), questions_path(user_id: @profile.user.username) %></li>
         | 
| 56 58 | 
             
                <% end %>
         | 
| 57 59 | 
             
                <% if defined?(EnjuBookmark) %>
         | 
| 58 | 
            -
                  <li><%= link_to t('activerecord.models.bookmark'), bookmarks_path(user_id: @profile.user.username) %></li>
         | 
| 60 | 
            +
                  <li><%= link_to t('page.listing', model: t('activerecord.models.bookmark')), bookmarks_path(user_id: @profile.user.username) %></li>
         | 
| 59 61 | 
             
                <% end %>
         | 
| 60 62 | 
             
                <% if defined?(EnjuPurchaseRequest) %>
         | 
| 61 | 
            -
                  <li><%= link_to t('activerecord.models.purchase_request'), purchase_requests_path(user_id: @profile.user.username) %></li>
         | 
| 63 | 
            +
                  <li><%= link_to t('page.listing', model: t('activerecord.models.purchase_request')), purchase_requests_path(user_id: @profile.user.username) %></li>
         | 
| 62 64 | 
             
                <% end %>
         | 
| 63 65 | 
             
              </ul>
         | 
| 64 66 | 
             
            </div>
         | 
| @@ -14,8 +14,8 @@ | |
| 14 14 | 
             
              <ul>
         | 
| 15 15 | 
             
                <li>
         | 
| 16 16 | 
             
                <% if @user_import_file %>
         | 
| 17 | 
            -
                  <%= link_to((image_tag 'icons/page_white_excel.png', size: '16x16', alt: 'TSV', class: 'icon'),  | 
| 18 | 
            -
                  (<%= link_to 'TSV',  | 
| 17 | 
            +
                  <%= link_to((image_tag 'icons/page_white_excel.png', size: '16x16', alt: 'TSV', class: 'icon'), user_import_results_path(user_import_file_id: @user_import_file.id, format: :txt, locale: @locale.to_s)) -%>
         | 
| 18 | 
            +
                  (<%= link_to 'TSV', user_import_results_path(user_import_file_id: @user_import_file.id, format: :txt, locale: @locale.to_s) -%>)
         | 
| 19 19 | 
             
                <% else %>
         | 
| 20 20 | 
             
                  <%= link_to((image_tag 'icons/page_white_excel.png', size: '16x16', alt: 'TSV', class: 'icon'), user_import_results_path(format: :txt, locale: @locale.to_s)) -%>
         | 
| 21 21 | 
             
                  (<%= link_to 'TSV', user_import_results_path(format: :txt, locale: @locale.to_s) -%>)
         | 
    
        data/config/routes.rb
    CHANGED
    
    | @@ -7,22 +7,20 @@ Rails.application.routes.draw do | |
| 7 7 |  | 
| 8 8 | 
             
              resources :user_export_files
         | 
| 9 9 |  | 
| 10 | 
            -
              resources :user_import_results, : | 
| 10 | 
            +
              resources :user_import_results, only: [:index, :show, :destroy]
         | 
| 11 11 |  | 
| 12 | 
            -
              resources :user_import_files | 
| 13 | 
            -
                resources :user_import_results, :only => [:index, :show, :destroy]
         | 
| 14 | 
            -
              end
         | 
| 12 | 
            +
              resources :user_import_files
         | 
| 15 13 |  | 
| 16 14 | 
             
              resource :my_account
         | 
| 17 15 |  | 
| 18 | 
            -
              resources :roles, : | 
| 16 | 
            +
              resources :roles, except: [:new, :create, :destroy]
         | 
| 19 17 |  | 
| 20 18 | 
             
              resources :user_groups
         | 
| 21 19 |  | 
| 22 20 | 
             
              resources :accepts
         | 
| 23 21 |  | 
| 24 22 | 
             
              resources :baskets do
         | 
| 25 | 
            -
                resources :accepts, : | 
| 23 | 
            +
                resources :accepts, except: [:edit, :update]
         | 
| 26 24 | 
             
              end
         | 
| 27 25 |  | 
| 28 26 | 
             
              as :user do
         | 
    
        data/lib/enju_leaf/user.rb
    CHANGED
    
    | @@ -8,19 +8,6 @@ module EnjuLeaf | |
| 8 8 | 
             
                  def enju_leaf_user_model
         | 
| 9 9 | 
             
                    include InstanceMethods
         | 
| 10 10 |  | 
| 11 | 
            -
                    # Setup accessible (or protected) attributes for your model
         | 
| 12 | 
            -
                    #attr_accessible :email, :password, :password_confirmation, :current_password,
         | 
| 13 | 
            -
                    #  :remember_me, :email_confirmation,
         | 
| 14 | 
            -
                    #  :auto_generated_password,
         | 
| 15 | 
            -
                    #  :profile_attributes
         | 
| 16 | 
            -
                    #attr_accessible :email, :password, :password_confirmation, :username,
         | 
| 17 | 
            -
                    #  :current_password, :remember_me,
         | 
| 18 | 
            -
                    #  :email_confirmation,
         | 
| 19 | 
            -
                    #  :expired_at, :locked, :role_id,
         | 
| 20 | 
            -
                    #  :user_has_role_attributes, :auto_generated_password,
         | 
| 21 | 
            -
                    #  :profile_attributes,
         | 
| 22 | 
            -
                    #  as: :admin
         | 
| 23 | 
            -
             | 
| 24 11 | 
             
                    scope :administrators, -> { joins(:role).where('roles.name = ?', 'Administrator') }
         | 
| 25 12 | 
             
                    scope :librarians, -> { joins(:role).where('roles.name = ? OR roles.name = ?', 'Administrator', 'Librarian') }
         | 
| 26 13 | 
             
                    scope :suspended, -> { where('locked_at IS NOT NULL') }
         | 
| @@ -78,7 +65,7 @@ module EnjuLeaf | |
| 78 65 |  | 
| 79 66 | 
             
                    # ユーザの情報をエクスポートします。
         | 
| 80 67 | 
             
                    # @param [Hash] options
         | 
| 81 | 
            -
                    def export(options = {format: :txt})
         | 
| 68 | 
            +
                    def self.export(options = {format: :txt})
         | 
| 82 69 | 
             
                      header = %w(
         | 
| 83 70 | 
             
                        username
         | 
| 84 71 | 
             
                        full_name
         | 
| @@ -96,48 +83,48 @@ module EnjuLeaf | |
| 96 83 | 
             
                        expired_at
         | 
| 97 84 | 
             
                        keyword_list
         | 
| 98 85 | 
             
                        note
         | 
| 99 | 
            -
             | 
| 100 | 
            -
             | 
| 86 | 
            +
                      )
         | 
| 87 | 
            +
                      header += %w(
         | 
| 101 88 | 
             
                        checkout_icalendar_token
         | 
| 102 89 | 
             
                        save_checkout_history
         | 
| 103 | 
            -
             | 
| 104 | 
            -
             | 
| 105 | 
            -
             | 
| 106 | 
            -
             | 
| 107 | 
            -
                       | 
| 108 | 
            -
                         | 
| 109 | 
            -
                         | 
| 110 | 
            -
                         | 
| 111 | 
            -
                         | 
| 112 | 
            -
                         | 
| 113 | 
            -
                         | 
| 114 | 
            -
                         | 
| 115 | 
            -
                         | 
| 116 | 
            -
                         | 
| 117 | 
            -
                         | 
| 118 | 
            -
                         | 
| 119 | 
            -
                         | 
| 120 | 
            -
                         | 
| 121 | 
            -
                         | 
| 122 | 
            -
                         | 
| 123 | 
            -
                         | 
| 124 | 
            -
                         | 
| 125 | 
            -
             | 
| 126 | 
            -
                           | 
| 127 | 
            -
                           | 
| 128 | 
            -
             | 
| 129 | 
            -
             | 
| 130 | 
            -
                           | 
| 131 | 
            -
             | 
| 132 | 
            -
             | 
| 133 | 
            -
                           | 
| 134 | 
            -
             | 
| 135 | 
            -
             | 
| 90 | 
            +
                      ) if defined? EnjuCirculation
         | 
| 91 | 
            +
                      header << "save_search_history" if defined? EnjuSearchLog
         | 
| 92 | 
            +
                      header << "share_bookmarks" if defined? EnjuBookmark
         | 
| 93 | 
            +
                      lines = []
         | 
| 94 | 
            +
                      User.all.map{|u|
         | 
| 95 | 
            +
                        line = []
         | 
| 96 | 
            +
                        line << u.username
         | 
| 97 | 
            +
                        line << u.try(:profile).try(:full_name)
         | 
| 98 | 
            +
                        line << u.try(:profile).try(:full_name_transcription)
         | 
| 99 | 
            +
                        line << u.email
         | 
| 100 | 
            +
                        line << u.try(:profile).try(:user_number)
         | 
| 101 | 
            +
                        line << u.role.try(:name)
         | 
| 102 | 
            +
                        line << u.try(:profile).try(:user_group).try(:name)
         | 
| 103 | 
            +
                        line << u.try(:profile).try(:library).try(:name)
         | 
| 104 | 
            +
                        line << u.try(:profile).try(:locale)
         | 
| 105 | 
            +
                        line << u.access_locked?
         | 
| 106 | 
            +
                        line << u.try(:profile).try(:required_role).try(:name)
         | 
| 107 | 
            +
                        line << u.created_at
         | 
| 108 | 
            +
                        line << u.updated_at
         | 
| 109 | 
            +
                        line << u.try(:profile).try(:expired_at)
         | 
| 110 | 
            +
                        line << u.try(:profile).try(:keyword_list).try(:split).try(:join, "//")
         | 
| 111 | 
            +
                        line << u.try(:profile).try(:note)
         | 
| 112 | 
            +
                        if defined? EnjuCirculation
         | 
| 113 | 
            +
                          line << u.try(:profile).try(:checkout_icalendar_token)
         | 
| 114 | 
            +
                          line << u.try(:profile).try(:save_checkout_history)
         | 
| 115 | 
            +
                        end
         | 
| 116 | 
            +
                        if defined? EnjuSearchLog
         | 
| 117 | 
            +
                          line << u.try(:profile).try(:save_search_history)
         | 
| 118 | 
            +
                        end
         | 
| 119 | 
            +
                        if defined? EnjuBookmark
         | 
| 120 | 
            +
                          line << u.try(:profile).try(:share_bookmarks)
         | 
| 121 | 
            +
                        end
         | 
| 122 | 
            +
                        lines << line
         | 
| 136 123 | 
             
                      }
         | 
| 137 124 | 
             
                      if options[:format] == :txt
         | 
| 138 | 
            -
                         | 
| 125 | 
            +
                        lines.map{|line| line.to_csv(col_sep: "\t")}.unshift(header.to_csv(col_sep: "\t")).join
         | 
| 139 126 | 
             
                      else
         | 
| 140 | 
            -
                         | 
| 127 | 
            +
                        lines
         | 
| 141 128 | 
             
                      end
         | 
| 142 129 | 
             
                    end
         | 
| 143 130 | 
             
                  end
         | 
    
        data/lib/enju_leaf/version.rb
    CHANGED
    
    
| @@ -8,6 +8,7 @@ class EnjuLeaf::SetupGenerator < Rails::Generators::Base | |
| 8 8 | 
             
                copy_file("Procfile", "Procfile")
         | 
| 9 9 | 
             
                copy_file("config/schedule.rb", "config/schedule.rb")
         | 
| 10 10 | 
             
                copy_file("config/initializers/resque.rb", "config/initializers/resque.rb")
         | 
| 11 | 
            +
                append_to_file("config/initializers/assets.rb", "Rails.application.config.assets.precompile += %w( *.png )")
         | 
| 11 12 | 
             
                inject_into_file 'config/application.rb', after: /# config.i18n.default_locale = :de$\n/ do
         | 
| 12 13 | 
             
                  <<"EOS"
         | 
| 13 14 | 
             
                config.i18n.available_locales = [:en, :ja]
         | 
| @@ -42,6 +43,7 @@ EOS | |
| 42 43 | 
             
                generate("sunspot_rails:install")
         | 
| 43 44 | 
             
                generate("kaminari:config")
         | 
| 44 45 | 
             
                generate("simple_form:install")
         | 
| 46 | 
            +
                generate("geocoder:config")
         | 
| 45 47 | 
             
                gsub_file "config/sunspot.yml",
         | 
| 46 48 | 
             
                  /path: \/solr\/production/,
         | 
| 47 49 | 
             
                  "path: /solr/default"
         | 
| @@ -0,0 +1,12 @@ | |
| 1 | 
            +
            # Be sure to restart your server when you modify this file.
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            # Version of your assets, change this if you want to expire all your assets.
         | 
| 4 | 
            +
            Rails.application.config.assets.version = '1.0'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            # Add additional assets to the asset load path
         | 
| 7 | 
            +
            # Rails.application.config.assets.paths << Emoji.images_path
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            # Precompile additional assets.
         | 
| 10 | 
            +
            # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
         | 
| 11 | 
            +
            # Rails.application.config.assets.precompile += %w( search.js )
         | 
| 12 | 
            +
            Rails.application.config.assets.precompile += %w( icons/*.png )
         | 
| @@ -18,7 +18,7 @@ describe UserImportFile do | |
| 18 18 | 
             
                  old_import_results_count = UserImportResult.count
         | 
| 19 19 | 
             
                  old_profiles_solr_count = Profile.search.total
         | 
| 20 20 | 
             
                  @file.current_state.should eq 'pending'
         | 
| 21 | 
            -
                  @file.import_start.should eq({:user_imported => 5, :user_found => 0, :failed =>  | 
| 21 | 
            +
                  @file.import_start.should eq({:user_imported => 5, :user_found => 0, :failed => 0, error: 3})
         | 
| 22 22 | 
             
                  User.order('id DESC')[1].username.should eq 'user005'
         | 
| 23 23 | 
             
                  User.order('id DESC')[2].username.should eq 'user003'
         | 
| 24 24 | 
             
                  User.count.should eq old_users_count + 5
         | 
| @@ -52,8 +52,10 @@ describe UserImportFile do | |
| 52 52 | 
             
                  user003.profile.save_search_history.should be_falsy
         | 
| 53 53 | 
             
                  user003.profile.share_bookmarks.should be_falsy
         | 
| 54 54 | 
             
                  User.where(username: 'user000').first.should be_nil
         | 
| 55 | 
            -
                  UserImportResult.count.should eq old_import_results_count +  | 
| 56 | 
            -
                  UserImportResult.order( | 
| 55 | 
            +
                  UserImportResult.count.should eq old_import_results_count + 10
         | 
| 56 | 
            +
                  UserImportResult.order('id DESC')[0].error_message.should eq 'line 10: User number has already been taken'
         | 
| 57 | 
            +
                  UserImportResult.order('id DESC')[1].error_message.should eq 'line 9: User number is invalid'
         | 
| 58 | 
            +
                  UserImportResult.order('id DESC')[2].error_message.should eq 'line 8: Password is too short (minimum is 6 characters)'
         | 
| 57 59 |  | 
| 58 60 | 
             
                  user005 = User.where(username: 'user005').first
         | 
| 59 61 | 
             
                  user005.role.name.should eq 'User'
         | 
| @@ -73,7 +75,8 @@ describe UserImportFile do | |
| 73 75 | 
             
                  @file.executed_at.should be_truthy
         | 
| 74 76 |  | 
| 75 77 | 
             
                  @file.reload
         | 
| 76 | 
            -
                  @file.error_message.should eq "The following column(s) were ignored: invalid"
         | 
| 78 | 
            +
                  @file.error_message.should eq "The following column(s) were ignored: invalid\nline 8: Password is too short (minimum is 6 characters)\nline 9: User number is invalid\nline 10: User number has already been taken"
         | 
| 79 | 
            +
                  @file.current_state.should eq 'failed'
         | 
| 77 80 | 
             
                end
         | 
| 78 81 |  | 
| 79 82 | 
             
                it "should send message when import is completed" do
         | 
| @@ -88,7 +91,7 @@ describe UserImportFile do | |
| 88 91 | 
             
                  old_users_count = User.count
         | 
| 89 92 | 
             
                  old_import_results_count = UserImportResult.count
         | 
| 90 93 | 
             
                  @file.user = User.where(username: 'librarian1').first
         | 
| 91 | 
            -
                  @file.import_start.should eq({:user_imported => 4, :user_found => 0, :failed =>  | 
| 94 | 
            +
                  @file.import_start.should eq({:user_imported => 4, :user_found => 0, :failed => 1, error: 3})
         | 
| 92 95 | 
             
                  User.order('id DESC')[1].username.should eq 'user005'
         | 
| 93 96 | 
             
                  User.count.should eq old_users_count + 4
         | 
| 94 97 | 
             
                end
         | 
    
        data/spec/models/user_spec.rb
    CHANGED
    
    | @@ -140,9 +140,11 @@ describe User do | |
| 140 140 | 
             
              describe ".export" do
         | 
| 141 141 | 
             
                it "should export all user's information" do
         | 
| 142 142 | 
             
                  lines = User.export
         | 
| 143 | 
            +
                  CSV.parse(lines, col_sep: "\t")
         | 
| 143 144 | 
             
                  expect(lines).not_to be_empty
         | 
| 144 | 
            -
                  expect(lines.split(/\ | 
| 145 | 
            +
                  expect(lines.split(/\n/).size).to eq User.count + 1
         | 
| 145 146 | 
             
                end
         | 
| 147 | 
            +
             | 
| 146 148 | 
             
                it "should export share_bookmarks and save_search_history" do
         | 
| 147 149 | 
             
                  user = FactoryGirl.create(:user,
         | 
| 148 150 | 
             
                    profile: FactoryGirl.create(:profile,
         | 
| @@ -157,14 +159,16 @@ describe User do | |
| 157 159 | 
             
                    end
         | 
| 158 160 | 
             
                  end
         | 
| 159 161 | 
             
                end
         | 
| 162 | 
            +
             | 
| 160 163 | 
             
                it "should work even if EnjuBookmark module is undefined" do
         | 
| 161 164 | 
             
                  Object.send(:remove_const, :EnjuBookmark)
         | 
| 162 165 | 
             
                  lines = User.export
         | 
| 163 166 | 
             
                  expect(lines).not_to be_empty
         | 
| 164 | 
            -
                  expect(lines.split(/\ | 
| 167 | 
            +
                  expect(lines.split(/\n/).size).to eq User.count + 1
         | 
| 165 168 | 
             
                end
         | 
| 166 169 | 
             
              end
         | 
| 167 170 | 
             
            end
         | 
| 171 | 
            +
             | 
| 168 172 | 
             
            # == Schema Information
         | 
| 169 173 | 
             
            #
         | 
| 170 174 | 
             
            # Table name: users
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: enju_leaf
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.1. | 
| 4 | 
            +
              version: 1.1.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Kosuke Tanabe
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2015-12- | 
| 11 | 
            +
            date: 2015-12-25 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rails
         | 
| @@ -936,6 +936,7 @@ files: | |
| 936 936 | 
             
            - spec/dummy/config/environments/development.rb
         | 
| 937 937 | 
             
            - spec/dummy/config/environments/production.rb
         | 
| 938 938 | 
             
            - spec/dummy/config/environments/test.rb
         | 
| 939 | 
            +
            - spec/dummy/config/initializers/assets.rb
         | 
| 939 940 | 
             
            - spec/dummy/config/initializers/backtrace_silencers.rb
         | 
| 940 941 | 
             
            - spec/dummy/config/initializers/devise.rb
         | 
| 941 942 | 
             
            - spec/dummy/config/initializers/friendly_id.rb
         | 
| @@ -1339,7 +1340,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 1339 1340 | 
             
                  version: '0'
         | 
| 1340 1341 | 
             
            requirements: []
         | 
| 1341 1342 | 
             
            rubyforge_project: 
         | 
| 1342 | 
            -
            rubygems_version: 2. | 
| 1343 | 
            +
            rubygems_version: 2.5.0
         | 
| 1343 1344 | 
             
            signing_key: 
         | 
| 1344 1345 | 
             
            specification_version: 4
         | 
| 1345 1346 | 
             
            summary: Next-L Enju Leaf
         | 
| @@ -1373,6 +1374,7 @@ test_files: | |
| 1373 1374 | 
             
            - spec/dummy/config/environments/development.rb
         | 
| 1374 1375 | 
             
            - spec/dummy/config/environments/production.rb
         | 
| 1375 1376 | 
             
            - spec/dummy/config/environments/test.rb
         | 
| 1377 | 
            +
            - spec/dummy/config/initializers/assets.rb
         | 
| 1376 1378 | 
             
            - spec/dummy/config/initializers/backtrace_silencers.rb
         | 
| 1377 1379 | 
             
            - spec/dummy/config/initializers/devise.rb
         | 
| 1378 1380 | 
             
            - spec/dummy/config/initializers/friendly_id.rb
         |