sufia 3.5.0 → 3.6.0

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 (103) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -3
  3. data/.travis.yml +4 -4
  4. data/README.md +1 -10
  5. data/SUFIA_VERSION +1 -1
  6. data/app/assets/images/audio.png +0 -0
  7. data/app/assets/javascripts/sufia/trophy.js +11 -5
  8. data/app/controllers/single_use_links_controller.rb +11 -1
  9. data/app/helpers/facets_helper.rb +3 -0
  10. data/app/helpers/sufia/facets_helper_behavior.rb +23 -0
  11. data/app/helpers/sufia_helper.rb +3 -21
  12. data/app/views/dashboard/_facet_limit.html.erb +2 -20
  13. data/app/views/dashboard/_index_partials/_thumbnail_display.html.erb +4 -2
  14. data/app/views/generic_files/_descriptions.html.erb +2 -18
  15. data/app/views/generic_files/_field_form.html.erb +7 -2
  16. data/app/views/generic_files/_media_display.html.erb +0 -16
  17. data/app/views/generic_files/_permission.html.erb +1 -17
  18. data/app/views/generic_files/_permission_form.html.erb +1 -1
  19. data/app/views/generic_files/_show_actions.html.erb +1 -8
  20. data/app/views/generic_files/_versioning.html.erb +1 -17
  21. data/app/views/generic_files/edit.html.erb +1 -17
  22. data/app/views/mailbox/index.html.erb +5 -3
  23. data/app/views/users/_activity.html.erb +3 -0
  24. data/app/views/users/_activity_log.html.erb +1 -17
  25. data/app/views/users/_contributions.html.erb +29 -0
  26. data/app/views/users/_follower_modal.html.erb +26 -0
  27. data/app/views/users/_following_modal.html.erb +26 -0
  28. data/app/views/users/_left_sidebar.html.erb +12 -0
  29. data/app/views/users/_notify_number.html.erb +0 -16
  30. data/app/views/users/_profile.html.erb +7 -0
  31. data/app/views/users/_profile_actions.html.erb +11 -0
  32. data/app/views/users/_profile_tabs.html.erb +11 -0
  33. data/app/views/users/_search_form.html.erb +1 -17
  34. data/app/views/users/_social_media_info.html.erb +20 -0
  35. data/app/views/users/_user_info.html.erb +0 -16
  36. data/app/views/users/_vitals.html.erb +4 -0
  37. data/app/views/users/edit.html.erb +1 -17
  38. data/app/views/users/index.html.erb +0 -16
  39. data/app/views/users/notifications_number.js.erb +0 -16
  40. data/app/views/users/show.html.erb +21 -58
  41. data/lib/sufia.rb +1 -3
  42. data/lib/sufia/controller.rb +0 -6
  43. data/lib/sufia/version.rb +1 -1
  44. data/spec/controllers/batch_edits_controller_spec.rb +8 -2
  45. data/spec/controllers/generic_files_controller_spec.rb +8 -28
  46. data/spec/controllers/single_use_links_controller_spec.rb +26 -2
  47. data/spec/factories/generic_files.rb +46 -0
  48. data/spec/factories/users.rb +6 -2
  49. data/spec/features/browse_dashboard_files_spec.rb +39 -0
  50. data/spec/features/browse_files_spec.rb +30 -0
  51. data/spec/features/{contact_form.rb → contact_form_spec.rb} +1 -1
  52. data/spec/features/{display_dashboard.rb → display_dashboard_spec.rb} +1 -7
  53. data/spec/features/{ingest_upload_files.rb → ingest_upload_files_spec.rb} +2 -2
  54. data/spec/features/notifications_spec.rb +20 -0
  55. data/spec/features/users_spec.rb +12 -0
  56. data/spec/helpers/sufia_helper_spec.rb +23 -0
  57. data/spec/lib/sufia/id_service_spec.rb +0 -38
  58. data/spec/support/features.rb +2 -0
  59. data/spec/support/features/session_helpers.rb +9 -1
  60. data/spec/support/fixture_helpers.rb +10 -0
  61. data/spec/views/dashboard/facet_limit.html.erb_spec.rb +15 -0
  62. data/spec/views/dashboard/index_partials/_thumbnail_display.html.erb_spec.rb +22 -0
  63. data/spec/views/generic_file/edit.html.erb_spec.rb +24 -0
  64. data/spec/views/users/show.html.erb_spec.rb +31 -0
  65. data/sufia-models/app/models/concerns/sufia/user.rb +2 -2
  66. data/sufia-models/lib/generators/sufia/models/install_generator.rb +2 -1
  67. data/sufia-models/lib/generators/sufia/models/templates/migrations/add_linkedin_to_users.rb +5 -0
  68. data/sufia-models/lib/sufia/models/generic_file/actions.rb +0 -1
  69. data/sufia-models/lib/sufia/models/version.rb +1 -1
  70. data/sufia-models/sufia-models.gemspec +3 -5
  71. data/tasks/sufia-dev.rake +0 -10
  72. metadata +43 -69
  73. data/app/views/generic_files/edit_fields/_type.html.erb +0 -12
  74. data/lib/tasks/fixtures.rake +0 -231
  75. data/spec/features/browse_dashboard_files.rb +0 -21
  76. data/spec/features/browse_files.rb +0 -31
  77. data/spec/fixtures/empty_file.txt +0 -0
  78. data/spec/fixtures/fits_datastream.xml +0 -42
  79. data/spec/fixtures/sufia/bg_header.jpg +0 -0
  80. data/spec/fixtures/sufia/sufia_test1.descMeta.txt +0 -12
  81. data/spec/fixtures/sufia/sufia_test1.foxml.erb +0 -89
  82. data/spec/fixtures/sufia/sufia_test1.txt +0 -1
  83. data/spec/fixtures/sufia/sufia_test2.descMeta.txt +0 -12
  84. data/spec/fixtures/sufia/sufia_test2.docx +0 -0
  85. data/spec/fixtures/sufia/sufia_test2.foxml.erb +0 -88
  86. data/spec/fixtures/sufia/sufia_test3.descMeta.txt +0 -12
  87. data/spec/fixtures/sufia/sufia_test3.foxml.erb +0 -91
  88. data/spec/fixtures/sufia/sufia_test3.xls +0 -0
  89. data/spec/fixtures/sufia/sufia_test4.descMeta.txt +0 -12
  90. data/spec/fixtures/sufia/sufia_test4.foxml.erb +0 -91
  91. data/spec/fixtures/sufia/sufia_test5.descMeta.txt +0 -19
  92. data/spec/fixtures/sufia/sufia_test5.foxml.erb +0 -90
  93. data/spec/fixtures/sufia/sufia_test5.txt +0 -1
  94. data/spec/fixtures/sufia/sufia_test6.descMeta.txt +0 -12
  95. data/spec/fixtures/sufia/sufia_test6.foxml.erb +0 -89
  96. data/spec/fixtures/sufia/sufia_test6.jp2 +0 -0
  97. data/spec/fixtures/sufia/sufia_test6.txt +0 -1
  98. data/spec/fixtures/sufia_generic_stub.descMeta.txt +0 -12
  99. data/spec/fixtures/sufia_generic_stub.foxml.erb +0 -79
  100. data/spec/models/unzip_job_spec.rb +0 -47
  101. data/spec/rake/sufia_fixtures_spec.rb +0 -74
  102. data/sufia-models/lib/sufia/models/jobs/unzip_job.rb +0 -38
  103. data/tasks/sufia-fixtures.rake +0 -232
data/lib/sufia/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sufia
2
- VERSION = "3.5.0"
2
+ VERSION = "3.6.0"
3
3
  end
@@ -50,8 +50,14 @@ describe BatchEditsController do
50
50
  it "should be successful" do
51
51
  put :update , update_type:"delete_all"
52
52
  response.should be_redirect
53
- expect {GenericFIle.find(@one.id)}.to raise_error
54
- expect {GenericFIle.find(@two.id)}.to raise_error
53
+ expect {GenericFile.find(@one.id)}.to raise_error(ActiveFedora::ObjectNotFoundError)
54
+ expect {GenericFile.find(@two.id)}.to raise_error(ActiveFedora::ObjectNotFoundError)
55
+ end
56
+ it "should update the records" do
57
+ put :update , update_type:"update", "generic_file"=>{"subject"=>["zzz"]}
58
+ response.should be_redirect
59
+ GenericFile.find(@one.id).subject.should == ["zzz"]
60
+ GenericFile.find(@two.id).subject.should == ["zzz"]
55
61
  end
56
62
  end
57
63
 
@@ -27,8 +27,6 @@ describe GenericFilesController do
27
27
  JSON.parse(response.body).first['error'].should match(/no file for upload/i)
28
28
  end
29
29
 
30
-
31
-
32
30
  it "should spawn a content deposit event job" do
33
31
  file = fixture_file_upload('/world.png','image/png')
34
32
  s1 = double('one')
@@ -50,23 +48,6 @@ describe GenericFilesController do
50
48
  flash[:error].should include('A virus was found')
51
49
  end
52
50
 
53
- it "should expand zip files" do
54
- file = fixture_file_upload('/icons.zip','application/zip')
55
- s1 = double('one')
56
- ContentDepositEventJob.should_receive(:new).with('test:123', 'jilluser@example.com').and_return(s1)
57
- Sufia.queue.should_receive(:push).with(s1).once
58
-
59
- s2 = double('one')
60
- CharacterizeJob.should_receive(:new).with('test:123').and_return(s2)
61
- Sufia.queue.should_receive(:push).with(s2).once
62
-
63
- s3 = double('one')
64
- UnzipJob.should_receive(:new).with('test:123').and_return(s3)
65
- Sufia.queue.should_receive(:push).with(s3).once
66
-
67
- xhr :post, :create, :files=>[file], :Filename=>"The world", :batch_id => "sample:batch_id", :permission=>{"group"=>{"public"=>"read"} }, :terms_of_service => '1'
68
- end
69
-
70
51
  it "should create and save a file asset from the given params" do
71
52
  date_today = Date.today
72
53
  Date.stub(:today).and_return(date_today)
@@ -127,16 +108,16 @@ describe GenericFilesController do
127
108
  saved_file.to_solr.keys.should include('depositor_tesim')
128
109
  saved_file.to_solr['depositor_tesim'].should == ['jilluser@example.com']
129
110
  end
130
-
111
+
131
112
  it "should error out of create and save after on continuos rsolr error" do
132
- GenericFile.any_instance.stub(:save).and_raise(RSolr::Error::Http.new({},{}))
133
-
113
+ GenericFile.any_instance.stub(:save).and_raise(RSolr::Error::Http.new({},{}))
114
+
134
115
  file = fixture_file_upload('/world.png','image/png')
135
116
  xhr :post, :create, :files=>[file], :Filename=>"The world", :batch_id => "sample:batch_id", :permission=>{"group"=>{"public"=>"read"} }, :terms_of_service=>"1"
136
117
  response.body.should include("Error occurred while creating generic file.")
137
118
  end
138
119
  end
139
-
120
+
140
121
  describe "#create with local_file" do
141
122
  let (:mock_url) {"http://example.com"}
142
123
  before do
@@ -144,7 +125,7 @@ describe GenericFilesController do
144
125
  GenericFile.delete_all
145
126
  @mock_upload_directory = 'spec/mock_upload_directory'
146
127
  # Dir.mkdir @mock_upload_directory unless File.exists? @mock_upload_directory
147
- FileUtils.mkdir_p([File.join(@mock_upload_directory, "import/files"),File.join(@mock_upload_directory, "import/metadata")])
128
+ FileUtils.mkdir_p([File.join(@mock_upload_directory, "import/files"),File.join(@mock_upload_directory, "import/metadata")])
148
129
  FileUtils.copy(File.expand_path('../../fixtures/world.png', __FILE__), @mock_upload_directory)
149
130
  FileUtils.copy(File.expand_path('../../fixtures/image.jpg', __FILE__), @mock_upload_directory)
150
131
  FileUtils.copy(File.expand_path('../../fixtures/dublin_core_rdf_descMetadata.nt', __FILE__), File.join(@mock_upload_directory, "import/metadata"))
@@ -157,7 +138,7 @@ describe GenericFilesController do
157
138
  GenericFile.destroy_all
158
139
  end
159
140
  context "when User model defines a directory path" do
160
- before do
141
+ before do
161
142
  if $in_travis
162
143
  # In order to avoid an invalid derivative creation, just stub out the derivatives.
163
144
  GenericFile.any_instance.stub(:create_derivatives)
@@ -271,7 +252,7 @@ describe GenericFilesController do
271
252
  @user = FactoryGirl.find_or_create(:user)
272
253
  sign_in @user
273
254
  post :update, :id=>@generic_file.pid, :generic_file=>{:title=>'new_title', :tag=>[''], :permissions=>{:new_user_name=>{'archivist1'=>'edit'}}}
274
- @user.delete
255
+ @user.delete
275
256
  end
276
257
 
277
258
  it "should spawn a content new version event job" do
@@ -319,7 +300,6 @@ describe GenericFilesController do
319
300
  @user.delete
320
301
  end
321
302
 
322
-
323
303
  it "should record what user added a new version" do
324
304
  @user = FactoryGirl.find_or_create(:user)
325
305
  sign_in @user
@@ -407,7 +387,7 @@ describe GenericFilesController do
407
387
  it "should go back to edit on an error" do
408
388
  GenericFile.any_instance.should_receive(:valid?).and_return(false)
409
389
  post :update, :id=>@generic_file.pid, :generic_file=>{:tag=>['']}
410
- response.should be_successful
390
+ response.should be_successful
411
391
  response.should render_template('edit')
412
392
  assigns[:generic_file].should == @generic_file
413
393
  end
@@ -21,9 +21,8 @@ describe SingleUseLinksController do
21
21
  controller.stub(:has_access?).and_return(true)
22
22
  controller.stub(:clear_session_user) ## Don't clear out the authenticated session
23
23
  end
24
- describe "logged in user" do
24
+ describe "logged in user with edit permission" do
25
25
  before do
26
- @user = FactoryGirl.find_or_create(:user)
27
26
  sign_in @user
28
27
  @now = DateTime.now
29
28
  DateTime.stub(:now).and_return(@now)
@@ -50,6 +49,31 @@ describe SingleUseLinksController do
50
49
  end
51
50
  end
52
51
 
52
+ describe "logged in user without edit permission" do
53
+ before do
54
+ @other_user = FactoryGirl.find_or_create(:archivist)
55
+ @file.read_users << @other_user
56
+ @file.save
57
+ sign_in @other_user
58
+ end
59
+
60
+ describe "GET 'download'" do
61
+ it "and_return http success" do
62
+ get 'new_download', id:@file.pid
63
+ response.should_not be_success
64
+ end
65
+
66
+ end
67
+
68
+ describe "GET 'show'" do
69
+ it "and_return http success" do
70
+ get 'new_show', id:@file.pid
71
+ response.should_not be_success
72
+ end
73
+
74
+ end
75
+ end
76
+
53
77
  describe "unkown user" do
54
78
  describe "GET 'download'" do
55
79
  it "and_return http failure" do
@@ -0,0 +1,46 @@
1
+ FactoryGirl.define do
2
+
3
+ factory :fixture, :class => GenericFile do
4
+ factory :public_pdf do
5
+ ignore do
6
+ pid "sufia:fixture-pdf"
7
+ end
8
+ initialize_with { new(pid: pid) }
9
+ read_groups ["public"]
10
+ resource_type "Dissertation"
11
+ subject %w"lorem ipsum dolor sit amet"
12
+ before(:create) do |gf|
13
+ gf.apply_depositor_metadata "archivist1@example.com"
14
+ gf.title = "Fake Document Title"
15
+ gf.label = "fake_document.pdf"
16
+ end
17
+ end
18
+ factory :public_mp3 do
19
+ ignore do
20
+ pid "sufia:fixture-mp3"
21
+ end
22
+ initialize_with { new(pid: pid) }
23
+ subject %w"consectetur adipisicing elit"
24
+ before(:create) do |gf|
25
+ gf.apply_depositor_metadata "archivist1@example.com"
26
+ gf.inner_object.pid = "sufia:fixture-mp3"
27
+ gf.label = "Test Document MP3.mp3"
28
+ end
29
+ read_groups ["public"]
30
+ end
31
+ factory :public_wav do
32
+ ignore do
33
+ pid "sufia:fixture-wav"
34
+ end
35
+ initialize_with { new(pid: pid) }
36
+ resource_type ["Audio", "Dataset"]
37
+ read_groups ["public"]
38
+ subject %w"sed do eiusmod tempor incididunt ut labore"
39
+ before(:create) do |gf|
40
+ gf.apply_depositor_metadata "archivist1@example.com"
41
+ gf.label = "Fake Wav File.wav"
42
+ end
43
+ end
44
+ end
45
+
46
+ end
@@ -4,14 +4,18 @@ FactoryGirl.define do
4
4
  password 'password'
5
5
  end
6
6
 
7
- factory :archivist, :class => User do |u|
7
+ factory :archivist, aliases: [:user_with_fixtures], :class => User do |u|
8
8
  email 'archivist1@example.com'
9
9
  password 'password'
10
10
  end
11
11
 
12
- factory :user_with_fixtures, :class => User do |u|
12
+ factory :user_with_mail, :class => User do |u|
13
13
  email 'archivist2@example.com'
14
14
  password 'password'
15
+ after(:create) do |user|
16
+ message = '<span class="batchid ui-helper-hidden">fake_batch_noid</span>You\'ve got mail.'
17
+ User.batchuser().send_message(user, message, "Sample notification.")
18
+ end
15
19
  end
16
20
 
17
21
  factory :curator, :class => User do |u|
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Browse Dashboard files" do
4
+
5
+ before do
6
+ find_or_create_file_fixtures
7
+ sign_in :user_with_fixtures
8
+ end
9
+
10
+ it "should show me some files (from the fixtures)" do
11
+ click_link "dashboard"
12
+ page.should have_content "Edit File"
13
+ page.should have_content "Download File"
14
+ fill_in "dashboard_search", with: "PDF"
15
+ click_button "dashboard_submit"
16
+ page.should have_content "Fake Document Title"
17
+ end
18
+
19
+ it "should allow you to browse facets" do
20
+ # TODO: fix more facets link!
21
+ pending "Until more facets link is fixed..."
22
+ visit '/'
23
+ click_link "more Subjects"
24
+ click_link "consectetur"
25
+ #page.should have_content "1 - 5 of 5"
26
+ click_link "Test Document MP3.mp3"
27
+ page.should have_content "Download"
28
+ page.should_not have_content "Edit"
29
+ end
30
+
31
+ it "should allow me to edit files (from the fixtures)" do
32
+ click_link "dashboard"
33
+ fill_in "dashboard_search", with: "Wav"
34
+ click_button "dashboard_submit"
35
+ click_link "Edit File"
36
+ page.should have_content "Edit Fake Wav File.wav"
37
+ end
38
+
39
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Browse files" do
4
+
5
+ before(:all) do
6
+ find_or_create_file_fixtures
7
+ end
8
+
9
+ describe "when not logged in" do
10
+ it "should let us browse some of the fixtures" do
11
+ visit '/'
12
+ #click_link "more Keywords"
13
+ #click_link "test"
14
+ #page.should have_content "1 - 5 of 5"
15
+ click_link "Fake Document Title"
16
+ page.should have_content "Download"
17
+ page.should_not have_content "Edit"
18
+ end
19
+ it "should allow you to browse facets" do
20
+ # TODO: fix more facets link!
21
+ pending "Until more facets link is fixed..."
22
+ visit '/'
23
+ click_link "more Subjects"
24
+ click_link "consectetur"
25
+ click_link "Test Document MP3.mp3"
26
+ page.should have_content "Download"
27
+ page.should_not have_content "Edit"
28
+ end
29
+ end
30
+ end
@@ -94,6 +94,6 @@ describe "Sending an email via the contact form" do
94
94
  fill_in "contact_form_message", with: "I am contacting you regarding ScholarSphere."
95
95
  select "Depositing content", from: "contact_form_category"
96
96
  click_button "Send"
97
- page.should have_content "Sorry, this message was not delivered"
97
+ page.should have_content "Sorry, this message was not sent successfully"
98
98
  end
99
99
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe "Display Dashboard files" do
4
4
 
5
5
  before do
6
- sign_in :user
6
+ sign_in :user_with_fixtures
7
7
  end
8
8
 
9
9
  it "should display the dashboard and have search" do
@@ -21,12 +21,6 @@ describe "Display Dashboard files" do
21
21
  page.should have_content "Upload"
22
22
  end
23
23
 
24
- it "should display the dashboard and want to upload files" do
25
- click_link 'dashboard'
26
- click_link 'Upload File(s)'
27
- page.should have_content "Upload"
28
- end
29
-
30
24
  it "should display the dashboard and want to search the whole system" do
31
25
  fill_in "search-field-header", with: "system search"
32
26
  click_button "search-submit-header"
@@ -16,8 +16,8 @@ describe "Uploading files via web form" do
16
16
 
17
17
  it "should require checking the terms of service" do
18
18
  click_link "upload"
19
- attach_file("files[]", "spec/fixtures/image.jp2")
20
- attach_file("files[]", "spec/fixtures/jp2_fits.xml")
19
+ attach_file("files[]", File.dirname(__FILE__)+"/../../spec/fixtures/image.jp2")
20
+ attach_file("files[]", File.dirname(__FILE__)+"/../../spec/fixtures/jp2_fits.xml")
21
21
  click_button 'Start upload'
22
22
  page.should have_content "You must accept the terms of service!"
23
23
  end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Notifications page" do
4
+
5
+ before do
6
+ sign_in :user_with_mail
7
+ end
8
+
9
+ it "should list notifications with date, subject and message" do
10
+ visit "/notifications"
11
+ page.should have_content "User Notifications"
12
+ page.find(:xpath, '//thead/tr').should have_content "Date"
13
+ page.find(:xpath, '//thead/tr').should have_content "Subject"
14
+ page.find(:xpath, '//thead/tr').should have_content "Message"
15
+ page.should have_content "Sample notification."
16
+ page.should have_content "less than a minute ago"
17
+ page.should have_content "You've got mail."
18
+ end
19
+
20
+ end
@@ -25,4 +25,16 @@ describe "User Profile" do
25
25
  click_link "View Users"
26
26
  page.should have_xpath("//td/a[@href='/users/curator1@example-dot-com']")
27
27
  end
28
+
29
+ it "should be searchable" do
30
+ @archivist = FactoryGirl.find_or_create(:archivist)
31
+ click_link "curator1@example.com"
32
+ click_link "View Users"
33
+ page.should have_xpath("//td/a[@href='/users/curator1@example-dot-com']")
34
+ page.should have_xpath("//td/a[@href='/users/archivist1@example-dot-com']")
35
+ fill_in 'user_search', with: 'archivist1@example.com'
36
+ click_button "user_submit"
37
+ page.should_not have_xpath("//td/a[@href='/users/curator1@example-dot-com']")
38
+ page.should have_xpath("//td/a[@href='/users/archivist1@example-dot-com']")
39
+ end
28
40
  end
@@ -10,6 +10,29 @@ describe SufiaHelper do
10
10
  end
11
11
  end
12
12
 
13
+ describe "number_of_deposits" do
14
+ let(:conn) { ActiveFedora::SolrService.instance.conn }
15
+ before do
16
+ # More than 10 times, because the pagination threshold is 10
17
+ 12.times do |t|
18
+ conn.add :id => "199#{t}", Solrizer.solr_name('depositor', :stored_searchable) => user.user_key
19
+ end
20
+ conn.commit
21
+ end
22
+ after do
23
+ 12.times do |t|
24
+ conn.delete_by_id "199#{t}"
25
+ end
26
+ conn.commit
27
+ end
28
+
29
+ let(:user) { double(user_key: 'justin') }
30
+
31
+ it "should return the correct number" do
32
+ expect(number_of_deposits(user)).to eq 12
33
+ end
34
+ end
35
+
13
36
  describe "selected facet" do
14
37
  let(:blacklight_config) { Blacklight::Configuration.new }
15
38
 
@@ -11,44 +11,6 @@ describe Sufia::IdService do
11
11
  it "should not mint the same id twice in a row" do
12
12
  other_id = Sufia::IdService.mint
13
13
  other_id.should_not == @id
14
- end
15
- it "should create many unique ids" do
16
- a = []
17
- threads = (1..10).map do
18
- Thread.new do
19
- 100.times do
20
- a << Sufia::IdService.mint
21
- end
22
- end
23
- end
24
- threads.each(&:join)
25
- a.uniq.count.should == a.count
26
- end
27
- it "should create many unique ids when hit by multiple processes " do
28
- rd, wr = IO.pipe
29
- 2.times do
30
- pid = fork do
31
- rd.close
32
- threads = (1..10).map do
33
- Thread.new do
34
- 20.times do
35
- wr.write Sufia::IdService.mint
36
- wr.write " "
37
- end
38
- end
39
- end
40
- threads.each(&:join)
41
- wr.close
42
- end
43
- end
44
- wr.close
45
- 2.times do
46
- Process.wait
47
- end
48
- s = rd.read
49
- rd.close
50
- a = s.split(" ")
51
- a.uniq.count.should == a.count
52
14
  end
53
15
  end
54
16
  end