enju_inventory 0.0.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 (85) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +3 -0
  3. data/Rakefile +36 -0
  4. data/app/controllers/inventories_controller.rb +8 -0
  5. data/app/controllers/inventory_files_controller.rb +83 -0
  6. data/app/models/inventory.rb +25 -0
  7. data/app/models/inventory_file.rb +49 -0
  8. data/app/views/inventories/edit.html.erb +33 -0
  9. data/app/views/inventories/index.html.erb +34 -0
  10. data/app/views/inventories/new.html.erb +32 -0
  11. data/app/views/inventories/show.html.erb +29 -0
  12. data/app/views/inventory_files/edit.html.erb +45 -0
  13. data/app/views/inventory_files/index.html.erb +39 -0
  14. data/app/views/inventory_files/new.html.erb +25 -0
  15. data/app/views/inventory_files/show.html.erb +44 -0
  16. data/config/routes.rb +4 -0
  17. data/db/migrate/20081117143156_create_inventory_files.rb +20 -0
  18. data/db/migrate/20081117143455_create_inventories.rb +17 -0
  19. data/db/migrate/20090706125521_add_attachments_inventory_to_inventory_file.rb +15 -0
  20. data/lib/enju_inventory.rb +4 -0
  21. data/lib/enju_inventory/engine.rb +11 -0
  22. data/lib/enju_inventory/version.rb +3 -0
  23. data/lib/tasks/enju_inventory_tasks.rake +4 -0
  24. data/spec/controllers/inventories_controller_spec.rb +162 -0
  25. data/spec/controllers/inventory_files_controller_spec.rb +289 -0
  26. data/spec/dummy/Rakefile +7 -0
  27. data/spec/dummy/app/assets/javascripts/application.js +9 -0
  28. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  29. data/spec/dummy/app/controllers/application_controller.rb +65 -0
  30. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  31. data/spec/dummy/app/models/ability.rb +18 -0
  32. data/spec/dummy/app/models/item.rb +20 -0
  33. data/spec/dummy/app/models/role.rb +5 -0
  34. data/spec/dummy/app/models/user.rb +28 -0
  35. data/spec/dummy/app/models/user_has_role.rb +4 -0
  36. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  37. data/spec/dummy/app/views/page/403.html.erb +9 -0
  38. data/spec/dummy/app/views/page/403.mobile.erb +5 -0
  39. data/spec/dummy/app/views/page/403.xml.erb +4 -0
  40. data/spec/dummy/app/views/page/404.html.erb +9 -0
  41. data/spec/dummy/app/views/page/404.mobile.erb +5 -0
  42. data/spec/dummy/app/views/page/404.xml.erb +4 -0
  43. data/spec/dummy/config.ru +4 -0
  44. data/spec/dummy/config/application.rb +45 -0
  45. data/spec/dummy/config/boot.rb +10 -0
  46. data/spec/dummy/config/database.yml +25 -0
  47. data/spec/dummy/config/environment.rb +5 -0
  48. data/spec/dummy/config/environments/development.rb +30 -0
  49. data/spec/dummy/config/environments/production.rb +60 -0
  50. data/spec/dummy/config/environments/test.rb +39 -0
  51. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  52. data/spec/dummy/config/initializers/devise.rb +209 -0
  53. data/spec/dummy/config/initializers/inflections.rb +10 -0
  54. data/spec/dummy/config/initializers/mime_types.rb +6 -0
  55. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  56. data/spec/dummy/config/initializers/session_store.rb +8 -0
  57. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  58. data/spec/dummy/config/locales/en.yml +5 -0
  59. data/spec/dummy/config/routes.rb +60 -0
  60. data/spec/dummy/db/migrate/006_create_items.rb +36 -0
  61. data/spec/dummy/db/migrate/20111201121844_create_roles.rb +12 -0
  62. data/spec/dummy/db/migrate/20111201155456_create_users.rb +13 -0
  63. data/spec/dummy/db/migrate/20111201155513_add_devise_to_users.rb +31 -0
  64. data/spec/dummy/db/migrate/20111201163718_create_user_has_roles.rb +10 -0
  65. data/spec/dummy/db/schema.rb +113 -0
  66. data/spec/dummy/db/test.sqlite3 +0 -0
  67. data/spec/dummy/log/test.log +8481 -0
  68. data/spec/dummy/private/system/inventories/4/original/inventory_file_sample.tsv +7 -0
  69. data/spec/dummy/public/404.html +26 -0
  70. data/spec/dummy/public/422.html +26 -0
  71. data/spec/dummy/public/500.html +26 -0
  72. data/spec/dummy/public/favicon.ico +0 -0
  73. data/spec/dummy/script/rails +6 -0
  74. data/spec/factories/user.rb +31 -0
  75. data/spec/fixtures/inventories.yml +26 -0
  76. data/spec/fixtures/inventory_files.yml +43 -0
  77. data/spec/fixtures/roles.yml +21 -0
  78. data/spec/fixtures/user_has_roles.yml +41 -0
  79. data/spec/fixtures/users.yml +69 -0
  80. data/spec/models/inventory_file_spec.rb +32 -0
  81. data/spec/models/inventory_spec.rb +20 -0
  82. data/spec/spec_helper.rb +33 -0
  83. data/spec/support/controller_macros.rb +48 -0
  84. data/spec/support/devise.rb +4 -0
  85. metadata +311 -0
@@ -0,0 +1,7 @@
1
+ 00001
2
+ 00002
3
+ 00003
4
+ 00001
5
+ 99997
6
+ 99998
7
+ 99999
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ <p>We've been notified about this issue and we'll take a look at it shortly.</p>
24
+ </div>
25
+ </body>
26
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,31 @@
1
+ FactoryGirl.define do
2
+ factory :admin, :class => User do |f|
3
+ f.sequence(:username){|n| "admin_#{n}"}
4
+ f.sequence(:email){|n| "admin_#{n}@example.jp"}
5
+ f.role {Role.find_by_name('Administrator')}
6
+ f.password 'adminpassword'
7
+ f.password_confirmation 'adminpassword'
8
+ f.required_role {Role.find_by_name('User')}
9
+ end
10
+
11
+ factory :librarian, :class => User do |f|
12
+ f.sequence(:username){|n| "librarian_#{n}"}
13
+ f.sequence(:email){|n| "librarian_#{n}@example.jp"}
14
+ f.role {Role.find_by_name('Librarian')}
15
+ f.password 'librarianpassword'
16
+ f.password_confirmation 'librarianpassword'
17
+ f.required_role {Role.find_by_name('User')}
18
+ end
19
+
20
+ factory :user, :class => User do |f|
21
+ f.sequence(:username){|n| "user_#{n}"}
22
+ f.sequence(:email){|n| "user_#{n}@example.jp"}
23
+ f.role {Role.find_by_name('User')}
24
+ f.password 'userpassword'
25
+ f.password_confirmation 'userpassword'
26
+ f.required_role {Role.find_by_name('User')}
27
+ end
28
+
29
+ factory :invalid_user, :class => User do |f|
30
+ end
31
+ end
@@ -0,0 +1,26 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ inventory_00001:
4
+ id: 1
5
+ item_id: 1
6
+ inventory_file_id: 1
7
+ note: MyText
8
+
9
+ inventory_00002:
10
+ id: 2
11
+ item_id: 2
12
+ inventory_file_id: 1
13
+ note: MyText
14
+
15
+ # == Schema Information
16
+ #
17
+ # Table name: inventories
18
+ #
19
+ # id :integer not null, primary key
20
+ # item_id :integer
21
+ # inventory_file_id :integer
22
+ # note :text
23
+ # created_at :datetime
24
+ # updated_at :datetime
25
+ #
26
+
@@ -0,0 +1,43 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ inventory_file_00001:
4
+ id: 1
5
+ inventory_file_name: MyString
6
+ inventory_file_size: 1
7
+ file_hash: MyString
8
+ user_id: 1
9
+ inventory_content_type: text/csv
10
+ inventory_file_00002:
11
+ id: 2
12
+ inventory_file_name: MyString
13
+ inventory_file_size: 1
14
+ file_hash: MyString
15
+ user_id: 1
16
+ inventory_content_type: text/csv
17
+ inventory_file_00003:
18
+ id: 3
19
+ inventory_file_name: MyString
20
+ inventory_file_size: 1
21
+ file_hash: MyString
22
+ user_id: 1
23
+ inventory_content_type: text/csv
24
+
25
+ # == Schema Information
26
+ #
27
+ # Table name: inventory_files
28
+ #
29
+ # id :integer not null, primary key
30
+ # filename :string(255)
31
+ # content_type :string(255)
32
+ # size :integer
33
+ # file_hash :string(255)
34
+ # user_id :integer
35
+ # note :text
36
+ # created_at :datetime
37
+ # updated_at :datetime
38
+ # inventory_file_name :string(255)
39
+ # inventory_content_type :string(255)
40
+ # inventory_file_size :integer
41
+ # inventory_updated_at :datetime
42
+ #
43
+
@@ -0,0 +1,21 @@
1
+ ---
2
+ role_00001:
3
+ name: Guest
4
+ display_name: Guest
5
+ id: 1
6
+ note:
7
+ role_00002:
8
+ name: User
9
+ display_name: User
10
+ id: 2
11
+ note:
12
+ role_00003:
13
+ name: Librarian
14
+ display_name: Librarian
15
+ id: 3
16
+ note:
17
+ role_00004:
18
+ name: Administrator
19
+ display_name: Administrator
20
+ id: 4
21
+ note:
@@ -0,0 +1,41 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ admin:
4
+ user_id: 1
5
+ role_id: 4
6
+
7
+ librarian1:
8
+ user_id: 2
9
+ role_id: 3
10
+
11
+ user1:
12
+ user_id: 3
13
+ role_id: 2
14
+
15
+ librarian2:
16
+ user_id: 4
17
+ role_id: 3
18
+
19
+ user2:
20
+ user_id: 5
21
+ role_id: 2
22
+
23
+ user3:
24
+ user_id: 6
25
+ role_id: 2
26
+
27
+ user4:
28
+ user_id: 7
29
+ role_id: 2
30
+
31
+ # == Schema Information
32
+ #
33
+ # Table name: user_has_roles
34
+ #
35
+ # id :integer not null, primary key
36
+ # user_id :integer
37
+ # role_id :integer
38
+ # created_at :datetime
39
+ # updated_at :datetime
40
+ #
41
+
@@ -0,0 +1,69 @@
1
+ ---
2
+ admin:
3
+ updated_at: 2008-05-31 13:16:30.163731 +09:00
4
+ encrypted_password: $2a$10$vHohD1WflnTIqAa8zMkF9evwAgIZRw3XuR4d3bi29M.jph/MB/AJi
5
+ user_group_id: 2
6
+ id: 1
7
+ note:
8
+ username: admin
9
+ email: tanabe@kamata.lib.teu.ac.jp
10
+ created_at: 2007-11-19 16:58:32.111941 +09:00
11
+ required_role_id: 4
12
+ librarian1:
13
+ updated_at: 2008-05-31 12:41:16.337474 +09:00
14
+ encrypted_password: $2a$10$9O2VuTccN4gHq36ARg0QReSrb1D7WrBBhZZ759RM9moHbB0W5zCzS
15
+ user_group_id: 1
16
+ id: 2
17
+ note:
18
+ username: librarian1
19
+ email: librarian1@kamata.lib.teu.ac.jp
20
+ created_at: 2007-11-19 16:58:33.172441 +09:00
21
+ required_role_id: 1
22
+ user1:
23
+ updated_at: 2008-05-31 13:02:25.101261 +09:00
24
+ encrypted_password: $2a$10$JthS59A0BNkDOoFpCXM0V.GhhffKaoWKbzpPahYp/vTFrOyM7h/uW
25
+ user_group_id: 1
26
+ id: 3
27
+ note:
28
+ username: user1
29
+ email: user1@kamata.lib.teu.ac.jp
30
+ created_at: 2007-11-19 16:58:34.637413 +09:00
31
+ required_role_id: 3
32
+ librarian2:
33
+ updated_at: 2008-05-31 12:42:23.340575 +09:00
34
+ encrypted_password: $2a$10$YmmTGrYQ1Ir6oc7wXnp.GuNeO1eYLoP3sv8wMSIrTdaGw2BPwRrpS
35
+ user_group_id: 1
36
+ id: 4
37
+ note:
38
+ username: librarian2
39
+ created_at: 2008-01-18 12:24:04.222344 +09:00
40
+ required_role_id: 1
41
+ user2:
42
+ updated_at: 2008-05-31 12:42:44.711117 +09:00
43
+ encrypted_password: $2a$10$i7UjJhLVrJM/J7qaTwW39OXw1NiwowUEbtNHVDV0sqMLjX9.UO9ca
44
+ user_group_id: 1
45
+ id: 5
46
+ note:
47
+ username: user2
48
+ created_at: 2008-01-18 13:29:06.922728 +09:00
49
+ required_role_id: 2
50
+ user3:
51
+ updated_at: 2008-05-31 13:02:25.101261 +09:00
52
+ encrypted_password: cc53de0c2d9a1a228daa9a673ec824473747e17507a6c3c4f7e5eff8821f531d4b9e23616b3ddc66fe17006b2298a556fbd567ac080e87f00f37eef8cee6c417
53
+ user_group_id: 1
54
+ id: 6
55
+ note:
56
+ username: user3
57
+ email: user3@kamata.lib.teu.ac.jp
58
+ created_at: 2007-11-19 16:58:34.637413 +09:00
59
+ required_role_id: 3
60
+ user4:
61
+ updated_at: 2008-05-31 13:02:25.101261 +09:00
62
+ encrypted_password: cc53de0c2d9a1a228daa9a673ec824473747e17507a6c3c4f7e5eff8821f531d4b9e23616b3ddc66fe17006b2298a556fbd567ac080e87f00f37eef8cee6c417
63
+ user_group_id: 1
64
+ id: 7
65
+ note:
66
+ username: user4
67
+ email: user4@kamata.lib.teu.ac.jp
68
+ created_at: 2007-11-19 16:58:34.637413 +09:00
69
+ required_role_id: 3
@@ -0,0 +1,32 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe InventoryFile do
5
+ before(:each) do
6
+ @file = InventoryFile.create :inventory => File.new("#{Rails.root.to_s}/../../examples/inventory_file_sample.tsv"), :user => FactoryGirl.create(:user)
7
+ end
8
+
9
+ it "should be imported" do
10
+ @file.import.should be_true
11
+ end
12
+ end
13
+
14
+ # == Schema Information
15
+ #
16
+ # Table name: inventory_files
17
+ #
18
+ # id :integer not null, primary key
19
+ # filename :string(255)
20
+ # content_type :string(255)
21
+ # size :integer
22
+ # file_hash :string(255)
23
+ # user_id :integer
24
+ # note :text
25
+ # created_at :datetime
26
+ # updated_at :datetime
27
+ # inventory_file_name :string(255)
28
+ # inventory_content_type :string(255)
29
+ # inventory_file_size :integer
30
+ # inventory_updated_at :datetime
31
+ #
32
+
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe Inventory do
5
+ #pending "add some examples to (or delete) #{__FILE__}"
6
+
7
+ end
8
+
9
+ # == Schema Information
10
+ #
11
+ # Table name: inventories
12
+ #
13
+ # id :integer not null, primary key
14
+ # item_id :integer
15
+ # inventory_file_id :integer
16
+ # note :text
17
+ # created_at :datetime
18
+ # updated_at :datetime
19
+ #
20
+
@@ -0,0 +1,33 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV["RAILS_ENV"] ||= 'test'
3
+ require File.expand_path("../dummy/config/environment", __FILE__)
4
+ require 'rspec/rails'
5
+ require 'factory_girl'
6
+
7
+ # Requires supporting ruby files with custom matchers and macros, etc,
8
+ # in spec/support/ and its subdirectories.
9
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
10
+
11
+ RSpec.configure do |config|
12
+ # == Mock Framework
13
+ #
14
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
15
+ #
16
+ # config.mock_with :mocha
17
+ # config.mock_with :flexmock
18
+ # config.mock_with :rr
19
+ config.mock_with :rspec
20
+
21
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
22
+ config.fixture_path = "#{::Rails.root}/../../spec/fixtures"
23
+
24
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
25
+ # examples within a transaction, remove the following line or assign false
26
+ # instead of true.
27
+ config.use_transactional_fixtures = true
28
+
29
+ config.extend ControllerMacros, :type => :controller
30
+ end
31
+
32
+ FactoryGirl.definition_file_paths << "#{::Rails.root}/../../spec/factories"
33
+ FactoryGirl.find_definitions
@@ -0,0 +1,48 @@
1
+ module ControllerMacros
2
+ def login_admin
3
+ before(:each) do
4
+ @request.env["devise.mapping"] = Devise.mappings[:admin]
5
+ sign_in Factory.create(:admin)
6
+ end
7
+ end
8
+
9
+ def login_librarian
10
+ before(:each) do
11
+ @request.env["devise.mapping"] = Devise.mappings[:user]
12
+ user = Factory.create(:librarian)
13
+ sign_in user
14
+ end
15
+ end
16
+
17
+ def login_user
18
+ before(:each) do
19
+ @request.env["devise.mapping"] = Devise.mappings[:user]
20
+ user = Factory.create(:user)
21
+ sign_in user
22
+ end
23
+ end
24
+
25
+ def login_fixture_admin
26
+ before(:each) do
27
+ @request.env["devise.mapping"] = Devise.mappings[:admin]
28
+ @user = users(:admin)
29
+ sign_in @user
30
+ end
31
+ end
32
+
33
+ def login_fixture_librarian
34
+ before(:each) do
35
+ @request.env["devise.mapping"] = Devise.mappings[:user]
36
+ @user = users(:librarian1)
37
+ sign_in @user
38
+ end
39
+ end
40
+
41
+ def login_fixture_user
42
+ before(:each) do
43
+ @request.env["devise.mapping"] = Devise.mappings[:user]
44
+ @user = users(:user1)
45
+ sign_in @user
46
+ end
47
+ end
48
+ end