enju_leaf 1.2.0.beta.2 → 1.2.0.beta.3

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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/app/views/layouts/application.html.erb +1 -1
  3. data/app/views/page/configuration.html.erb +6 -2
  4. data/app/views/page/import.html.erb +3 -1
  5. data/lib/enju_leaf.rb +0 -3
  6. data/lib/enju_leaf/version.rb +1 -1
  7. data/lib/generators/enju_leaf/quick_install/quick_install_generator.rb +3 -0
  8. data/lib/generators/enju_leaf/setup/setup_generator.rb +3 -5
  9. data/lib/tasks/enju_leaf_tasks.rake +3 -6
  10. data/spec/dummy/app/models/user.rb +1 -3
  11. data/spec/dummy/config/application.rb +4 -2
  12. data/spec/dummy/db/migrate/20160813191533_add_book_jacket_source_to_library_group.rb +5 -0
  13. data/spec/dummy/db/migrate/20160813191647_add_max_number_of_results_to_library_group.rb +5 -0
  14. data/spec/dummy/db/migrate/20160813191733_add_family_name_first_to_library_group.rb +5 -0
  15. data/spec/dummy/db/migrate/20160813191820_add_screenshot_generator_to_library_group.rb +5 -0
  16. data/spec/dummy/db/migrate/20160813192542_add_pub_year_facet_range_interval_to_library_group.rb +5 -0
  17. data/spec/dummy/db/migrate/20160813203039_add_user_id_to_library_group.rb +5 -0
  18. data/spec/dummy/db/schema.rb +14 -6
  19. data/spec/fixtures/library_groups.yml +1 -2
  20. data/spec/views/page/about.html.erb_spec.rb +2 -3
  21. data/spec/views/page/advanced_search.html.erb_spec.rb +1 -2
  22. data/spec/views/page/configuration.html.erb_spec.rb +2 -3
  23. data/spec/views/page/export.html.erb_spec.rb +2 -3
  24. data/spec/views/page/import.html.erb_spec.rb +2 -3
  25. data/spec/views/page/index.html.erb_spec.rb +1 -1
  26. data/spec/views/page/opensearch.xml.builder_spec.rb +1 -2
  27. data/spec/views/page/statistics.html.erb_spec.rb +3 -4
  28. metadata +43 -46
  29. data/app/models/concerns/calculate_stat.rb +0 -35
  30. data/app/models/concerns/enju_leaf/enju_user.rb +0 -309
  31. data/app/models/concerns/export_file.rb +0 -19
  32. data/app/models/concerns/import_file.rb +0 -89
  33. data/app/models/concerns/master_model.rb +0 -38
  34. data/lib/enju_leaf/localized_name.rb +0 -15
  35. data/lib/enju_leaf/url_validator.rb +0 -12
  36. data/lib/generators/enju_leaf/setup/templates/config/initializers/enju_leaf.rb +0 -1
  37. data/lib/generators/enju_leaf/setup/templates/config/initializers/resque.rb +0 -3
  38. data/spec/dummy/config/initializers/enju_leaf.rb +0 -2
  39. data/spec/factories/checkout.rb +0 -9
  40. data/spec/models/user_spec.rb +0 -194
@@ -1,38 +0,0 @@
1
- module MasterModel
2
- extend ActiveSupport::Concern
3
-
4
- included do
5
- acts_as_list
6
- validates_uniqueness_of :name, case_sensitive: false
7
- validates :name, presence: true
8
- validate :name do
9
- valid_name?
10
- end
11
- validate :display_name do
12
- valid_yaml?
13
- end
14
- validates :display_name, presence: true
15
- before_validation :set_display_name, on: :create
16
- strip_attributes only: :name
17
- end
18
-
19
- # 表示名を設定します。
20
- def set_display_name
21
- self.display_name = "#{I18n.locale}: #{name}" if display_name.blank?
22
- end
23
-
24
- private
25
- def valid_name?
26
- unless name =~ /\A[a-z][0-9a-z_]*[0-9a-z]\z/
27
- errors.add(:name, I18n.t('page.only_lowercase_letters_and_numbers_are_allowed'))
28
- end
29
- end
30
-
31
- def valid_yaml?
32
- begin
33
- YAML.load(display_name)
34
- rescue Psych::SyntaxError
35
- errors.add(:display_name, I18n.t('page.cannot_parse_yaml_header'))
36
- end
37
- end
38
- end
@@ -1,15 +0,0 @@
1
- module LocalizedName
2
- def localize(locale = I18n.locale)
3
- string = YAML.load(self)
4
- if string.is_a?(Hash) and string[locale.to_s]
5
- return string[locale.to_s]
6
- end
7
- self
8
- rescue NoMethodError
9
- self
10
- end
11
- end
12
-
13
- class String
14
- include LocalizedName
15
- end
@@ -1,12 +0,0 @@
1
- class UrlValidator < ActiveModel::EachValidator
2
- def validate_each(record, attribute, value)
3
- if value =~ /\Ahttps?:\/\/[^\n]+\z/i
4
- url = ::Addressable::URI.parse(value)
5
- unless ['http', 'https'].include?(url.scheme)
6
- record.errors.add(attribute.to_sym)
7
- end
8
- else
9
- record.errors.add(attribute.to_sym)
10
- end
11
- end
12
- end
@@ -1 +0,0 @@
1
- Item.include(EnjuLibrary::EnjuItem)
@@ -1,3 +0,0 @@
1
- if defined?(Resque)
2
- Resque.after_fork = Proc.new { ActiveRecord::Base.establish_connection }
3
- end
@@ -1,2 +0,0 @@
1
- Profile.include(EnjuCirculation::EnjuProfile)
2
- UserGroup.include(EnjuCirculation::EnjuUserGroup)
@@ -1,9 +0,0 @@
1
- FactoryGirl.define do
2
- factory :checkout, :class => Checkout do |f|
3
- f.due_date Time.zone.now.next_week
4
- f.association :item, factory: :item
5
- f.association :user, factory: :user
6
- f.association :librarian, factory: :librarian
7
- f.association :basket, factory: :basket
8
- end
9
- end
@@ -1,194 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require 'rails_helper'
3
-
4
- describe User do
5
- #pending "add some examples to (or delete) #{__FILE__}"
6
- fixtures :all
7
-
8
- it 'should create an user' do
9
- FactoryGirl.create(:user)
10
- end
11
-
12
- it 'should destroy an user' do
13
- user = FactoryGirl.create(:user)
14
- user.destroy.should be_truthy
15
- end
16
-
17
- it 'should respond to has_role(Administrator)' do
18
- admin = FactoryGirl.create(:admin)
19
- admin.has_role?('Administrator').should be_truthy
20
- end
21
-
22
- it 'should respond to has_role(Librarian)' do
23
- librarian = FactoryGirl.create(:librarian)
24
- librarian.has_role?('Administrator').should be_falsy
25
- librarian.has_role?('Librarian').should be_truthy
26
- librarian.has_role?('User').should be_truthy
27
- end
28
-
29
- it 'should respond to has_role(User)' do
30
- user = FactoryGirl.create(:user)
31
- user.has_role?('Administrator').should be_falsy
32
- user.has_role?('Librarian').should be_falsy
33
- user.has_role?('User').should be_truthy
34
- end
35
-
36
- it 'should lock an user' do
37
- user = FactoryGirl.create(:user)
38
- user.locked = '1'
39
- user.save
40
- user.active_for_authentication?.should be_falsy
41
- end
42
-
43
- it 'should unlock an user' do
44
- user = FactoryGirl.create(:user)
45
- user.lock_access!
46
- user.locked = '0'
47
- user.save
48
- user.active_for_authentication?.should be_truthy
49
- end
50
-
51
- it "should create user" do
52
- user = FactoryGirl.create(:user)
53
- assert !user.new_record?, "#{user.errors.full_messages.to_sentence}"
54
- end
55
-
56
- it "should require username" do
57
- old_count = User.count
58
- user = FactoryGirl.build(:user, :username => nil)
59
- user.save
60
- user.errors[:username].should be_truthy
61
- User.count.should eq old_count
62
- end
63
-
64
- it "should require password" do
65
- user = FactoryGirl.build(:user, :password => nil)
66
- user.save
67
- user.errors[:password].should be_truthy
68
- end
69
-
70
- it "should not require password_confirmation on create" do
71
- user = FactoryGirl.build(:user, :password => 'new_password', :password_confirmation => nil)
72
- user.save
73
- user.errors[:email].should be_empty
74
- end
75
-
76
- it "should reset password" do
77
- users(:user1).password = 'new password'
78
- users(:user1).password_confirmation = 'new password'
79
- users(:user1).save
80
- users(:user1).valid_password?('new password').should be_truthy
81
- end
82
-
83
- it "should set temporary_password" do
84
- user = users(:user1)
85
- old_password = user.encrypted_password
86
- user.set_auto_generated_password
87
- user.save
88
- old_password.should_not eq user.encrypted_password
89
- user.valid_password?('user1password').should be_falsy
90
- end
91
-
92
- it "should get highest_role" do
93
- users(:admin).role.name.should eq 'Administrator'
94
- end
95
-
96
- it "should lock all expired users" do
97
- User.lock_expired_users
98
- users(:user4).active_for_authentication?.should be_falsy
99
- end
100
-
101
- it "should lock_expired users" do
102
- user = users(:user1)
103
- users(:user1).active_for_authentication?.should be_truthy
104
- user.expired_at = 1.day.ago
105
- user.save
106
- users(:user1).active_for_authentication?.should be_falsy
107
- end
108
-
109
- if defined?(EnjuQuestion)
110
- it "should reset answer_feed_token" do
111
- users(:user1).reset_answer_feed_token
112
- users(:user1).answer_feed_token.should be_truthy
113
- end
114
-
115
- it "should delete answer_feed_token" do
116
- users(:user1).delete_answer_feed_token
117
- users(:user1).answer_feed_token.should be_nil
118
- end
119
- end
120
-
121
- if defined?(EnjuCirculation)
122
- it "should get checked_item_count" do
123
- count = users(:user1).checked_item_count
124
- count.should eq({:book=>2, :serial=>1, :cd=>0})
125
- end
126
-
127
- it "should get reserves_count" do
128
- users(:user1).reserves.waiting.count.should eq 1
129
- end
130
- end
131
-
132
- if defined?(EnjuCirculation)
133
- it "should send_message" do
134
- assert users(:librarian1).send_message('reservation_expired_for_patron', :manifestations => users(:librarian1).reserves.not_sent_expiration_notice_to_patron.collect(&:manifestation))
135
- users(:librarian1).reload
136
- users(:librarian1).reserves.not_sent_expiration_notice_to_patron.should be_empty
137
- end
138
- end
139
-
140
- describe ".export" do
141
- it "should export all user's information" do
142
- lines = User.export
143
- CSV.parse(lines, col_sep: "\t")
144
- expect(lines).not_to be_empty
145
- expect(lines.split(/\n/).size).to eq User.count + 1
146
- end
147
- end
148
- end
149
-
150
- # == Schema Information
151
- #
152
- # Table name: users
153
- #
154
- # id :integer not null, primary key
155
- # email :string(255) default(""), not null
156
- # encrypted_password :string(255) default(""), not null
157
- # reset_password_token :string(255)
158
- # reset_password_sent_at :datetime
159
- # remember_created_at :datetime
160
- # sign_in_count :integer default(0)
161
- # current_sign_in_at :datetime
162
- # last_sign_in_at :datetime
163
- # current_sign_in_ip :string(255)
164
- # last_sign_in_ip :string(255)
165
- # password_salt :string(255)
166
- # confirmation_token :string(255)
167
- # confirmed_at :datetime
168
- # confirmation_sent_at :datetime
169
- # unconfirmed_email :string(255)
170
- # failed_attempts :integer default(0)
171
- # unlock_token :string(255)
172
- # locked_at :datetime
173
- # authentication_token :string(255)
174
- # created_at :datetime not null
175
- # updated_at :datetime not null
176
- # deleted_at :datetime
177
- # username :string(255) not null
178
- # library_id :integer default(1), not null
179
- # user_group_id :integer default(1), not null
180
- # expired_at :datetime
181
- # required_role_id :integer default(1), not null
182
- # note :text
183
- # keyword_list :text
184
- # user_number :string(255)
185
- # state :string(255)
186
- # locale :string(255)
187
- # enju_access_key :string(255)
188
- # save_checkout_history :boolean default(FALSE), not null
189
- # checkout_icalendar_token :string(255)
190
- # share_bookmarks :boolean
191
- # save_search_history :boolean default(FALSE), not null
192
- # answer_feed_token :string(255)
193
- #
194
-