enju_leaf 1.1.0.rc20 → 1.1.0.rc21

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 (47) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/unknown_resource.png +0 -0
  3. data/app/controllers/my_accounts_controller.rb +0 -11
  4. data/app/controllers/page_controller.rb +12 -0
  5. data/app/controllers/profiles_controller.rb +23 -5
  6. data/app/controllers/user_import_files_controller.rb +1 -0
  7. data/app/helpers/page_helper.rb +14 -0
  8. data/app/models/profile.rb +7 -1
  9. data/app/models/user_export_file.rb +1 -0
  10. data/app/models/user_import_file.rb +20 -10
  11. data/app/views/page/_menu.html.erb +40 -51
  12. data/app/views/page/advanced_search.html.erb +14 -3
  13. data/app/views/page/configuration.html.erb +3 -0
  14. data/app/views/page/statistics.html.erb +0 -14
  15. data/app/views/page/system_information.html.erb +13 -1
  16. data/app/views/profiles/_edit_profile.html.erb +2 -2
  17. data/app/views/user_import_files/_results.html.erb +22 -0
  18. data/app/views/user_import_files/show.html.erb +8 -12
  19. data/app/views/user_import_results/_list.html.erb +22 -0
  20. data/app/views/user_import_results/_list_lines.html.erb +24 -0
  21. data/app/views/user_import_results/index.html.erb +5 -30
  22. data/app/views/user_import_results/show.html.erb +1 -1
  23. data/config/locales/devise.ja.yml +3 -3
  24. data/config/locales/translation_en.yml +5 -1
  25. data/config/locales/translation_ja.yml +5 -1
  26. data/lib/enju_leaf/calculate_stat.rb +3 -0
  27. data/lib/enju_leaf/engine.rb +0 -1
  28. data/lib/enju_leaf/helper.rb +22 -7
  29. data/lib/enju_leaf/import_file.rb +4 -0
  30. data/lib/enju_leaf/master_model.rb +1 -0
  31. data/lib/enju_leaf/user.rb +52 -20
  32. data/lib/enju_leaf/version.rb +1 -1
  33. data/lib/generators/enju_leaf/setup/setup_generator.rb +1 -1
  34. data/spec/controllers/my_accounts_controller_spec.rb +2 -2
  35. data/spec/controllers/profiles_controller_spec.rb +19 -5
  36. data/spec/controllers/user_import_files_controller_spec.rb +8 -1
  37. data/spec/controllers/user_import_results_controller_spec.rb +21 -1
  38. data/spec/dummy/app/assets/javascripts/application.js +4 -6
  39. data/spec/dummy/config/initializers/kaminari_config.rb +10 -0
  40. data/spec/fixtures/user_import_files.yml +2 -0
  41. data/spec/models/user_import_file_spec.rb +32 -24
  42. data/spec/models/user_spec.rb +29 -1
  43. data/spec/rails_helper.rb +82 -0
  44. data/spec/spec_helper.rb +86 -51
  45. data/spec/views/page/configuration.html.erb_spec.rb +1 -1
  46. data/spec/views/user_import_results/index.html.erb_spec.rb +32 -0
  47. metadata +20 -11
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require 'spec_helper'
2
+ require 'rails_helper'
3
3
 
4
4
  describe ProfilesController do
5
5
  fixtures :all
@@ -192,10 +192,10 @@ describe ProfilesController do
192
192
  response.should be_forbidden
193
193
  assigns(:profile).should eq admin
194
194
  end
195
- it "should not be able to delete other librarian user" do
196
- librarian = FactoryGirl.create(:librarian_profile)
197
- ability = EnjuLeaf::Ability.new(@user, "0.0.0.0")
198
- ability.should_not be_able_to( :destroy, librarian )
195
+
196
+ it "should show icalendar feed" do
197
+ get :edit, id: profiles(:user1).id, mode: 'feed_token'
198
+ response.should render_template("profiles/_feed_token")
199
199
  end
200
200
  end
201
201
 
@@ -405,6 +405,13 @@ describe ProfilesController do
405
405
  response.should redirect_to profile_url(assigns(:profile))
406
406
  assert_equal assigns(:profile).note, 'test'
407
407
  end
408
+
409
+ it "should update other user's locked status" do
410
+ put :update, id: profiles(:user1).id, profile: {:user_attributes => {:id => 3, :locked => '1', :username => 'user1'}}
411
+ response.should redirect_to profile_url(assigns(:profile))
412
+ assigns(:profile).user.locked_at.should be_truthy
413
+ assigns(:profile).user.access_locked?.should be_truthy
414
+ end
408
415
  end
409
416
 
410
417
  describe "When logged in as User" do
@@ -536,6 +543,12 @@ describe ProfilesController do
536
543
  delete :destroy, id: profiles(:librarian1).id
537
544
  response.should be_forbidden
538
545
  end
546
+
547
+ it "should not be able to delete other librarian user" do
548
+ librarian = FactoryGirl.create(:librarian_profile)
549
+ ability = EnjuLeaf::Ability.new(@user, "0.0.0.0")
550
+ ability.should_not be_able_to( :destroy, librarian )
551
+ end
539
552
  end
540
553
 
541
554
  describe "When logged in as User" do
@@ -559,6 +572,7 @@ describe ProfilesController do
559
572
  describe "When not logged in" do
560
573
  it "destroys the requested user" do
561
574
  delete :destroy, id: profiles(:user2).id
575
+ response.should redirect_to(new_user_session_url)
562
576
  end
563
577
 
564
578
  it "should be forbidden" do
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
3
  describe UserImportFilesController do
4
4
  fixtures :all
@@ -50,6 +50,13 @@ describe UserImportFilesController do
50
50
  assigns(:user_import_file).should eq(user_import_files(:two))
51
51
  expect(response).to be_success
52
52
  end
53
+
54
+ it "assigns user_import_results" do
55
+ get :show, id: user_import_files(:one).id
56
+ expect(response).to be_success
57
+ expect(assigns(:user_import_file)).to eq user_import_files(:one)
58
+ expect(assigns(:user_import_results)).to include user_import_results(:one)
59
+ end
53
60
  end
54
61
 
55
62
  describe "When logged in as Librarian" do
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require 'spec_helper'
2
+ require 'rails_helper'
3
3
 
4
4
  describe UserImportResultsController do
5
5
  fixtures :all
@@ -12,6 +12,26 @@ describe UserImportResultsController do
12
12
  get :index
13
13
  assigns(:user_import_results).should eq(UserImportResult.page(1))
14
14
  end
15
+
16
+ describe "With @user_import_file parameter" do
17
+ before (:each) do
18
+ @file = UserImportFile.create user_import: File.new("#{Rails.root}/../../examples/user_import_file_sample_long.tsv"), user: users(:admin)
19
+ @file.default_user_group = UserGroup.find(2)
20
+ @file.default_library = Library.find(3)
21
+ @file.save
22
+ result = @file.import_start
23
+ end
24
+ render_views
25
+ it "should assign all user_import_results for the user_import_file with a page parameter" do
26
+ get :index, user_import_file_id: @file.id
27
+ results = assigns(:user_import_results)
28
+ results.should_not be_empty
29
+ get :index, user_import_file_id: @file.id, page: 2
30
+ results2 = assigns(:user_import_results)
31
+ results2.first.should_not eq results.first
32
+ response.body.should match /<td>11<\/td>/
33
+ end
34
+ end
15
35
  end
16
36
 
17
37
  describe "When logged in as Librarian" do
@@ -2,14 +2,12 @@
2
2
  // listed below.
3
3
  //
4
4
  // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
6
  //
7
7
  // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // the compiled file.
8
+ // compiled file.
9
9
  //
10
- // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
- // GO AFTER THE REQUIRES BELOW.
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
12
  //
13
- //= require jquery
14
- //= require jquery_ujs
15
13
  //= require_tree .
@@ -0,0 +1,10 @@
1
+ Kaminari.configure do |config|
2
+ config.default_per_page = 10
3
+ # config.max_per_page = nil
4
+ # config.window = 4
5
+ # config.outer_window = 0
6
+ # config.left = 0
7
+ # config.right = 0
8
+ # config.page_method_name = :page
9
+ # config.param_name = :page
10
+ end
@@ -1,6 +1,7 @@
1
1
  # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
2
 
3
3
  one:
4
+ id: 1
4
5
  user_id: 1
5
6
  note: MyText
6
7
  executed_at: 2014-01-10 21:22:16
@@ -13,6 +14,7 @@ one:
13
14
  error_message: MyText
14
15
 
15
16
  two:
17
+ id: 2
16
18
  user_id: 1
17
19
  note: MyText
18
20
  executed_at: 2014-01-10 21:22:16
@@ -1,12 +1,12 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require 'spec_helper'
2
+ require 'rails_helper'
3
3
 
4
4
  describe UserImportFile do
5
5
  fixtures :all
6
6
 
7
7
  describe "when its mode is 'create'" do
8
8
  before(:each) do
9
- @file = UserImportFile.new :user_import => File.new("#{Rails.root}/../../examples/user_import_file_sample.tsv")
9
+ @file = UserImportFile.new user_import: File.new("#{Rails.root}/../../examples/user_import_file_sample.tsv")
10
10
  @file.default_user_group = UserGroup.find(2)
11
11
  @file.default_library = Library.find(3)
12
12
  @file.user = users(:admin)
@@ -95,12 +95,15 @@ describe UserImportFile do
95
95
  end
96
96
 
97
97
  describe "when its mode is 'update'" do
98
- it "should update users" do
98
+ before(:each) do
99
99
  FactoryGirl.create(:user,
100
100
  username: 'user001',
101
101
  profile: FactoryGirl.create(:profile)
102
102
  )
103
- @file = UserImportFile.create :user_import => File.new("#{Rails.root}/../../examples/user_update_file.tsv")
103
+ end
104
+ it "should update users" do
105
+ @file = UserImportFile.create user_import: File.new("#{Rails.root}/../../examples/user_update_file.tsv"), user: users(:admin)
106
+ old_message_count = Message.count
104
107
  result = @file.modify
105
108
  result.should have_key(:user_updated)
106
109
  user001 = User.where(username: 'user001').first
@@ -110,21 +113,20 @@ describe UserImportFile do
110
113
  user001.profile.user_number.should eq 'user_number_1'
111
114
  user001.profile.note.should eq 'test'
112
115
  user001.profile.keyword_list.should eq 'keyword1 keyword2'
116
+ Message.count.should eq old_message_count + 1
113
117
  end
114
118
 
115
119
  it "should not overwrite with null value" do
116
- FactoryGirl.create(:user,
117
- username: 'user001',
118
- profile: FactoryGirl.create(:profile,
119
- user_number: '001',
120
- full_name: 'User 001',
121
- full_name_transcription: 'User 001',
122
- locale: 'ja',
123
- note: 'Note',
124
- keyword_list: 'keyword1 keyword2',
125
- date_of_birth: 10.years.ago)
126
- )
127
- @file = UserImportFile.create :user_import => File.new("#{Rails.root}/../../examples/user_update_file2.tsv")
120
+ user = User.where(username: 'user001').first
121
+ user.profile = FactoryGirl.create(:profile,
122
+ user_number: '001',
123
+ full_name: 'User 001',
124
+ full_name_transcription: 'User 001',
125
+ locale: 'ja',
126
+ note: 'Note',
127
+ keyword_list: 'keyword1 keyword2',
128
+ date_of_birth: 10.years.ago)
129
+ @file = UserImportFile.create user_import: File.new("#{Rails.root}/../../examples/user_update_file2.tsv"), user: users(:admin)
128
130
  result = @file.modify
129
131
  result.should have_key(:user_updated)
130
132
  user001 = User.find('user001')
@@ -135,20 +137,24 @@ describe UserImportFile do
135
137
  user001.profile.keyword_list.should eq 'keyword1 keyword2'
136
138
  end
137
139
  it "should update user_number" do
138
- FactoryGirl.create(:user,
139
- username: 'user001',
140
- profile: FactoryGirl.create(:profile))
141
- @file = UserImportFile.create :user_import => File.new("#{Rails.root}/../../examples/user_update_file3.tsv")
140
+ @file = UserImportFile.create user_import: File.new("#{Rails.root}/../../examples/user_update_file3.tsv"), user: users(:admin)
142
141
  result = @file.modify
143
142
  result.should have_key(:user_updated)
144
143
  user001 = User.where(username: 'user001').first
145
144
  user001.profile.user_number.should eq '0001'
146
145
  end
146
+ it "should update user's lock status" do
147
+ @file = UserImportFile.create user_import: File.new("#{Rails.root}/../../examples/user_update_file4.tsv"), user: users(:admin)
148
+ result = @file.modify
149
+ result.should have_key(:user_updated)
150
+ user001 = User.where(username: 'user001').first
151
+ user001.access_locked?.should be_truthy
152
+ end
147
153
  end
148
154
 
149
155
  describe "when its mode is 'destroy'" do
150
156
  before(:each) do
151
- @file = UserImportFile.new :user_import => File.new("#{Rails.root}/../../examples/user_import_file_sample.tsv")
157
+ @file = UserImportFile.new user_import: File.new("#{Rails.root}/../../examples/user_import_file_sample.tsv"), user: users(:admin)
152
158
  @file.user = users(:admin)
153
159
  @file.default_user_group = UserGroup.find(2)
154
160
  @file.default_library = Library.find(3)
@@ -158,24 +164,26 @@ describe UserImportFile do
158
164
 
159
165
  it "should remove users" do
160
166
  old_count = User.count
161
- @file = UserImportFile.create :user_import => File.new("#{Rails.root}/../../examples/user_delete_file.tsv")
167
+ @file = UserImportFile.create user_import: File.new("#{Rails.root}/../../examples/user_delete_file.tsv"), user: users(:admin)
162
168
  @file.user = users(:admin)
169
+ old_message_count = Message.count
163
170
  @file.remove
164
171
  User.count.should eq old_count - 2
172
+ Message.count.should eq old_message_count + 1
165
173
  end
166
174
 
167
175
  it "should not remove users if there are checkouts" do
168
176
  user001 = User.where(username: 'user001').first
169
177
  checkout = FactoryGirl.create(:checkout, user: user001, item: FactoryGirl.create(:item))
170
178
  old_count = User.count
171
- @file = UserImportFile.create :user_import => File.new("#{Rails.root}/../../examples/user_delete_file.tsv")
179
+ @file = UserImportFile.create user_import: File.new("#{Rails.root}/../../examples/user_delete_file.tsv"), user: users(:admin)
172
180
  @file.remove
173
181
  User.where(username: 'user001').should_not be_blank
174
182
  end
175
183
  end
176
184
 
177
185
  it "should import in background" do
178
- file = UserImportFile.new :user_import => File.new("#{Rails.root}/../../examples/user_import_file_sample.tsv")
186
+ file = UserImportFile.new user_import: File.new("#{Rails.root}/../../examples/user_import_file_sample.tsv"), user: users(:admin)
179
187
  file.user = users(:admin)
180
188
  file.default_user_group = UserGroup.find(2)
181
189
  file.default_library = Library.find(3)
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require 'spec_helper'
2
+ require 'rails_helper'
3
3
 
4
4
  describe User do
5
5
  #pending "add some examples to (or delete) #{__FILE__}"
@@ -136,6 +136,34 @@ describe User do
136
136
  users(:librarian1).reserves.not_sent_expiration_notice_to_patron.should be_empty
137
137
  end
138
138
  end
139
+
140
+ describe ".export" do
141
+ it "should export all user's information" do
142
+ lines = User.export
143
+ expect(lines).not_to be_empty
144
+ expect(lines.split(/\r\n/).size).to eq User.all.size + 1
145
+ end
146
+ it "should export share_bookmarks and save_search_history" do
147
+ user = FactoryGirl.create(:user,
148
+ profile: FactoryGirl.create(:profile,
149
+ share_bookmarks: true,
150
+ save_search_history: true))
151
+ lines = User.export
152
+ rows = CSV.new(lines, col_sep: "\t", headers: true)
153
+ rows.each do |row|
154
+ if row["username"] == user.username
155
+ expect(row["share_bookmarks"]).to eq "true"
156
+ expect(row["save_search_history"]).to eq "true"
157
+ end
158
+ end
159
+ end
160
+ it "should work even if EnjuBookmark module is undefined" do
161
+ Object.send(:remove_const, :EnjuBookmark)
162
+ lines = User.export
163
+ expect(lines).not_to be_empty
164
+ expect(lines.split(/\r\n/).size).to eq User.all.size + 1
165
+ end
166
+ end
139
167
  end
140
168
  # == Schema Information
141
169
  #
@@ -0,0 +1,82 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+ SimpleCov.start 'rails'
4
+ Coveralls.wear!
5
+
6
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
7
+ ENV['RAILS_ENV'] ||= 'test'
8
+ require File.expand_path('../../spec/dummy/config/environment', __FILE__)
9
+ # Prevent database truncation if the environment is production
10
+ abort("The Rails environment is running in production mode!") if Rails.env.production?
11
+ require 'spec_helper'
12
+ require 'rspec/rails'
13
+ # Add additional requires below this line. Rails is not loaded until this point!
14
+ require 'vcr'
15
+ require 'factory_girl'
16
+ require 'sunspot-rails-tester'
17
+ require 'rspec/active_model/mocks'
18
+ require 'capybara/rspec'
19
+ require 'cancan/matchers'
20
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
21
+
22
+ # Requires supporting ruby files with custom matchers and macros, etc, in
23
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
24
+ # run as spec files by default. This means that files in spec/support that end
25
+ # in _spec.rb will both be required and run as specs, causing the specs to be
26
+ # run twice. It is recommended that you do not name files matching this glob to
27
+ # end with _spec.rb. You can configure this pattern with the --pattern
28
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
29
+ #
30
+ # The following line is provided for convenience purposes. It has the downside
31
+ # of increasing the boot-up time by auto-requiring all files in the support
32
+ # directory. Alternatively, in the individual `*_spec.rb` files, manually
33
+ # require only the support files necessary.
34
+ #
35
+ # Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
36
+
37
+ # Checks for pending migrations before tests are run.
38
+ # If you are not using ActiveRecord, you can remove this line.
39
+ ActiveRecord::Migration.maintain_test_schema! if Rails::VERSION::MAJOR >= 4
40
+
41
+ RSpec.configure do |config|
42
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
43
+ config.fixture_path = "#{::Rails.root}/../../spec/fixtures"
44
+
45
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
46
+ # examples within a transaction, remove the following line or assign false
47
+ # instead of true.
48
+ config.use_transactional_fixtures = true
49
+
50
+ # RSpec Rails can automatically mix in different behaviours to your tests
51
+ # based on their file location, for example enabling you to call `get` and
52
+ # `post` in specs under `spec/controllers`.
53
+ #
54
+ # You can disable this behaviour by removing the line below, and instead
55
+ # explicitly tag your specs with their type, e.g.:
56
+ #
57
+ # RSpec.describe UsersController, :type => :controller do
58
+ # # ...
59
+ # end
60
+ #
61
+ # The different available types are documented in the features, such as in
62
+ # https://relishapp.com/rspec/rspec-rails/docs
63
+ config.infer_spec_type_from_file_location!
64
+
65
+ config.extend ControllerMacros, :type => :controller
66
+
67
+ $original_sunspot_session = Sunspot.session
68
+
69
+ config.before do
70
+ Sunspot.session = Sunspot::Rails::StubSessionProxy.new($original_sunspot_session)
71
+ end
72
+
73
+ config.before :each, :solr => true do
74
+ Sunspot::Rails::Tester.start_original_sunspot_session
75
+ Sunspot.session = $original_sunspot_session
76
+ Sunspot.remove_all!
77
+ end
78
+ end
79
+
80
+ FactoryGirl.definition_file_paths << "#{::Rails.root}/../../spec/factories"
81
+ FactoryGirl.find_definitions
82
+
data/spec/spec_helper.rb CHANGED
@@ -1,57 +1,92 @@
1
- require 'simplecov'
2
- require 'coveralls'
3
- SimpleCov.start 'rails'
4
- Coveralls.wear!
5
-
6
- require 'capybara/rspec'
7
- require 'cancan/matchers'
8
-
9
- # This file is copied to spec/ when you run 'rails generate rspec:install'
10
- ENV["RAILS_ENV"] ||= 'test'
11
- require File.expand_path("../dummy/config/environment", __FILE__)
12
- require 'rspec/rails'
13
- require 'vcr'
14
- require 'factory_girl'
15
- require 'sunspot-rails-tester'
16
- require 'rspec/active_model/mocks'
17
-
18
- # Requires supporting ruby files with custom matchers and macros, etc,
19
- # in spec/support/ and its subdirectories.
20
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
21
-
1
+ # This file was generated by the `rails generate rspec:install` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # The `.rspec` file also contains a few flags that are not defaults but that
16
+ # users commonly want.
17
+ #
18
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
22
19
  RSpec.configure do |config|
23
- # == Mock Framework
24
- #
25
- # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
26
- #
27
- # config.mock_with :mocha
28
- # config.mock_with :flexmock
29
- # config.mock_with :rr
30
- config.mock_with :rspec
31
-
32
- # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
33
- config.fixture_path = "#{::Rails.root}/../../spec/fixtures"
34
-
35
- # If you're not using ActiveRecord, or you'd prefer not to run each of your
36
- # examples within a transaction, remove the following line or assign false
37
- # instead of true.
38
- config.use_transactional_fixtures = true
39
- config.extend ControllerMacros, :type => :controller
40
-
41
- $original_sunspot_session = Sunspot.session
42
-
43
- config.before do
44
- Sunspot.session = Sunspot::Rails::StubSessionProxy.new($original_sunspot_session)
20
+ # rspec-expectations config goes here. You can use an alternate
21
+ # assertion/expectation library such as wrong or the stdlib/minitest
22
+ # assertions if you prefer.
23
+ config.expect_with :rspec do |expectations|
24
+ # This option will default to `true` in RSpec 4. It makes the `description`
25
+ # and `failure_message` of custom matchers include text for helper methods
26
+ # defined using `chain`, e.g.:
27
+ # be_bigger_than(2).and_smaller_than(4).description
28
+ # # => "be bigger than 2 and smaller than 4"
29
+ # ...rather than:
30
+ # # => "be bigger than 2"
31
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
45
32
  end
46
33
 
47
- config.before :each, :solr => true do
48
- Sunspot::Rails::Tester.start_original_sunspot_session
49
- Sunspot.session = $original_sunspot_session
50
- Sunspot.remove_all!
34
+ # rspec-mocks config goes here. You can use an alternate test double
35
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
36
+ config.mock_with :rspec do |mocks|
37
+ # Prevents you from mocking or stubbing a method that does not exist on
38
+ # a real object. This is generally recommended, and will default to
39
+ # `true` in RSpec 4.
40
+ mocks.verify_partial_doubles = true
51
41
  end
52
42
 
53
- config.infer_spec_type_from_file_location!
54
- end
43
+ # The settings below are suggested to provide a good initial experience
44
+ # with RSpec, but feel free to customize to your heart's content.
45
+ =begin
46
+ # These two settings work together to allow you to limit a spec run
47
+ # to individual examples or groups you care about by tagging them with
48
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
49
+ # get run.
50
+ config.filter_run :focus
51
+ config.run_all_when_everything_filtered = true
52
+
53
+ # Allows RSpec to persist some state between runs in order to support
54
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
55
+ # you configure your source control system to ignore this file.
56
+ config.example_status_persistence_file_path = "spec/examples.txt"
55
57
 
56
- FactoryGirl.definition_file_paths << "#{::Rails.root}/../../spec/factories"
57
- FactoryGirl.find_definitions
58
+ # Limits the available syntax to the non-monkey patched syntax that is
59
+ # recommended. For more details, see:
60
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
61
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
62
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
63
+ config.disable_monkey_patching!
64
+
65
+ # Many RSpec users commonly either run the entire suite or an individual
66
+ # file, and it's useful to allow more verbose output when running an
67
+ # individual spec file.
68
+ if config.files_to_run.one?
69
+ # Use the documentation formatter for detailed output,
70
+ # unless a formatter has already been configured
71
+ # (e.g. via a command-line flag).
72
+ config.default_formatter = 'doc'
73
+ end
74
+
75
+ # Print the 10 slowest examples and example groups at the
76
+ # end of the spec run, to help surface which specs are running
77
+ # particularly slow.
78
+ config.profile_examples = 10
79
+
80
+ # Run specs in random order to surface order dependencies. If you find an
81
+ # order dependency and want to debug it, you can fix the order by providing
82
+ # the seed, which is printed after each run.
83
+ # --seed 1234
84
+ config.order = :random
85
+
86
+ # Seed global randomization in this process using the `--seed` CLI option.
87
+ # Setting this allows you to use `--seed` to deterministically reproduce
88
+ # test failures related to randomization by passing the same `--seed` value
89
+ # as the one that triggered the failure.
90
+ Kernel.srand config.seed
91
+ =end
92
+ end
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require 'spec_helper'
2
+ require 'rails_helper'
3
3
 
4
4
  describe "page/configuration" do
5
5
  fixtures :all
@@ -0,0 +1,32 @@
1
+ require 'rails_helper'
2
+
3
+ describe "user_import_results/index" do
4
+ fixtures :all
5
+
6
+ before(:each) do
7
+ assign(:user_import_results, UserImportResult.page(1))
8
+ admin = User.find('enjuadmin')
9
+ view.stub(:current_user).and_return(admin)
10
+ @ability = EnjuLeaf::Ability.new(admin, '0.0.0.0')
11
+ @ability.extend(CanCan::Ability)
12
+ controller.stub(:current_ability) { @ability }
13
+ end
14
+
15
+ it "renders a list of user_import_results" do
16
+ render
17
+ expect(rendered).to match /MyString/
18
+ end
19
+
20
+ context "with @user_import_file" do
21
+ before(:each) do
22
+ @user_import_file = UserImportFile.find(1)
23
+ @user_import_results = UserImportResult.where(user_import_file_id: 1).page(1)
24
+ end
25
+ it "renders a list of user_import_results for the user_import_file" do
26
+ render
27
+ expect(view).to render_template "user_import_results/_list_lines"
28
+ expect(rendered).to match /MyString/
29
+ expect(rendered).to match /<td>1<\/td>/
30
+ end
31
+ end
32
+ end