enju_trunk_message 0.1.14.pre3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +3 -0
  3. data/Rakefile +46 -0
  4. data/app/controllers/message_requests_controller.rb +62 -0
  5. data/app/controllers/message_templates_controller.rb +17 -0
  6. data/app/controllers/messages_controller.rb +159 -0
  7. data/app/helpers/messages_helper.rb +2 -0
  8. data/app/models/message.rb +85 -0
  9. data/app/models/message_request.rb +97 -0
  10. data/app/models/message_template.rb +39 -0
  11. data/app/views/layouts/messages.html.erb +24 -0
  12. data/app/views/message_requests/edit.html.erb +40 -0
  13. data/app/views/message_requests/index.html.erb +58 -0
  14. data/app/views/message_requests/new.html.erb +40 -0
  15. data/app/views/message_requests/show.html.erb +55 -0
  16. data/app/views/message_templates/_form.html.erb +27 -0
  17. data/app/views/message_templates/edit.html.erb +13 -0
  18. data/app/views/message_templates/index.html.erb +44 -0
  19. data/app/views/message_templates/new.html.erb +12 -0
  20. data/app/views/message_templates/show.html.erb +33 -0
  21. data/app/views/messages/_form.html.erb +37 -0
  22. data/app/views/messages/edit.html.erb +42 -0
  23. data/app/views/messages/index.atom.builder +15 -0
  24. data/app/views/messages/index.html.erb +66 -0
  25. data/app/views/messages/index.rss.builder +41 -0
  26. data/app/views/messages/new.html.erb +43 -0
  27. data/app/views/messages/show.html.erb +48 -0
  28. data/app/views/notifier/message_notification.en.text.erb +14 -0
  29. data/app/views/notifier/message_notification.ja.text.erb +14 -0
  30. data/config/locales/translation_en.yml +51 -0
  31. data/config/locales/translation_ja.yml +51 -0
  32. data/config/routes.rb +9 -0
  33. data/db/fixtures/message_templates.yml +70 -0
  34. data/db/migrate/149_create_message_templates.rb +18 -0
  35. data/db/migrate/154_create_messages.rb +24 -0
  36. data/db/migrate/20080819181903_create_message_requests.rb +20 -0
  37. data/db/migrate/20110913115320_add_lft_and_rgt_to_message.rb +11 -0
  38. data/db/migrate/20120125050502_add_depth_to_message.rb +6 -0
  39. data/lib/enju_message.rb +7 -0
  40. data/lib/enju_message/engine.rb +10 -0
  41. data/lib/enju_message/user.rb +28 -0
  42. data/lib/enju_message/version.rb +3 -0
  43. data/lib/generators/enju_message/views_generator.rb +21 -0
  44. data/lib/tasks/enju_message_tasks.rake +5 -0
  45. data/spec/controllers/message_requests_controller_spec.rb +275 -0
  46. data/spec/controllers/message_templates_controller_spec.rb +439 -0
  47. data/spec/controllers/messages_controller_spec.rb +443 -0
  48. data/spec/dummy/Rakefile +7 -0
  49. data/spec/dummy/app/assets/javascripts/application.js +9 -0
  50. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  51. data/spec/dummy/app/controllers/application_controller.rb +52 -0
  52. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  53. data/spec/dummy/app/mailers/notifier.rb +30 -0
  54. data/spec/dummy/app/models/ability.rb +30 -0
  55. data/spec/dummy/app/models/library_group.rb +86 -0
  56. data/spec/dummy/app/models/patron.rb +167 -0
  57. data/spec/dummy/app/models/patron_type.rb +19 -0
  58. data/spec/dummy/app/models/role.rb +8 -0
  59. data/spec/dummy/app/models/setting.rb +4 -0
  60. data/spec/dummy/app/models/user.rb +46 -0
  61. data/spec/dummy/app/models/user_group.rb +2 -0
  62. data/spec/dummy/app/models/user_has_role.rb +4 -0
  63. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  64. data/spec/dummy/app/views/page/403.html.erb +9 -0
  65. data/spec/dummy/app/views/page/403.mobile.erb +5 -0
  66. data/spec/dummy/app/views/page/403.xml.erb +4 -0
  67. data/spec/dummy/app/views/page/404.html.erb +9 -0
  68. data/spec/dummy/app/views/page/404.mobile.erb +5 -0
  69. data/spec/dummy/app/views/page/404.xml.erb +4 -0
  70. data/spec/dummy/config.ru +4 -0
  71. data/spec/dummy/config/application.rb +44 -0
  72. data/spec/dummy/config/application.yml +38 -0
  73. data/spec/dummy/config/boot.rb +10 -0
  74. data/spec/dummy/config/database.yml +25 -0
  75. data/spec/dummy/config/environment.rb +5 -0
  76. data/spec/dummy/config/environments/development.rb +30 -0
  77. data/spec/dummy/config/environments/production.rb +60 -0
  78. data/spec/dummy/config/environments/test.rb +39 -0
  79. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  80. data/spec/dummy/config/initializers/devise.rb +205 -0
  81. data/spec/dummy/config/initializers/inflections.rb +10 -0
  82. data/spec/dummy/config/initializers/mime_types.rb +6 -0
  83. data/spec/dummy/config/initializers/resque_mailer.rb +1 -0
  84. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  85. data/spec/dummy/config/initializers/session_store.rb +8 -0
  86. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  87. data/spec/dummy/config/locales/en.yml +5 -0
  88. data/spec/dummy/config/routes.rb +60 -0
  89. data/spec/dummy/db/migrate/001_create_patrons.rb +62 -0
  90. data/spec/dummy/db/migrate/080_create_library_groups.rb +25 -0
  91. data/spec/dummy/db/migrate/20080905191442_create_patron_types.rb +16 -0
  92. data/spec/dummy/db/migrate/20100211105551_add_admin_networks_to_library_group.rb +9 -0
  93. data/spec/dummy/db/migrate/20100222124420_add_allow_bookmark_external_url_to_library_group.rb +9 -0
  94. data/spec/dummy/db/migrate/20100527113752_create_delayed_jobs.rb +21 -0
  95. data/spec/dummy/db/migrate/20110115022329_add_position_to_library_group.rb +9 -0
  96. data/spec/dummy/db/migrate/20110222073537_add_url_to_library_group.rb +9 -0
  97. data/spec/dummy/db/migrate/20111020063828_remove_dsbl_from_library_group.rb +11 -0
  98. data/spec/dummy/db/migrate/20111201121636_create_languages.rb +16 -0
  99. data/spec/dummy/db/migrate/20111201121844_create_roles.rb +12 -0
  100. data/spec/dummy/db/migrate/20111201155456_create_users.rb +14 -0
  101. data/spec/dummy/db/migrate/20111201155513_add_devise_to_users.rb +52 -0
  102. data/spec/dummy/db/migrate/20111201163342_create_user_groups.rb +12 -0
  103. data/spec/dummy/db/migrate/20111201163718_create_user_has_roles.rb +10 -0
  104. data/spec/dummy/db/migrate/20120213092115_add_queue_to_delayed_jobs.rb +9 -0
  105. data/spec/dummy/db/schema.rb +236 -0
  106. data/spec/dummy/public/404.html +26 -0
  107. data/spec/dummy/public/422.html +26 -0
  108. data/spec/dummy/public/500.html +26 -0
  109. data/spec/dummy/public/favicon.ico +0 -0
  110. data/spec/dummy/script/delayed_job +5 -0
  111. data/spec/dummy/script/rails +6 -0
  112. data/spec/factories/message.rb +8 -0
  113. data/spec/factories/message_request.rb +8 -0
  114. data/spec/factories/message_template.rb +7 -0
  115. data/spec/factories/user.rb +34 -0
  116. data/spec/fixtures/library_groups.yml +34 -0
  117. data/spec/fixtures/message_requests.yml +30 -0
  118. data/spec/fixtures/message_templates.yml +85 -0
  119. data/spec/fixtures/messages.yml +62 -0
  120. data/spec/fixtures/patrons.yml +338 -0
  121. data/spec/fixtures/roles.yml +21 -0
  122. data/spec/fixtures/user_groups.yml +25 -0
  123. data/spec/fixtures/user_has_roles.yml +41 -0
  124. data/spec/fixtures/users.yml +71 -0
  125. data/spec/models/message_request_spec.rb +24 -0
  126. data/spec/models/message_spec.rb +59 -0
  127. data/spec/models/message_template_spec.rb +22 -0
  128. data/spec/spec_helper.rb +46 -0
  129. data/spec/support/controller_macros.rb +48 -0
  130. data/spec/support/devise.rb +4 -0
  131. metadata +440 -0
@@ -0,0 +1,10 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format
4
+ # (all these examples are active by default):
5
+ # ActiveSupport::Inflector.inflections do |inflect|
6
+ # inflect.plural /^(ox)$/i, '\1en'
7
+ # inflect.singular /^(ox)en/i, '\1'
8
+ # inflect.irregular 'person', 'people'
9
+ # inflect.uncountable %w( fish sheep )
10
+ # end
@@ -0,0 +1,6 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone
6
+ Mime::Type.register_alias "text/html", :mobile
@@ -0,0 +1 @@
1
+ Resque::Mailer.excluded_environments = [:test, :cucumber]
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ Dummy::Application.config.secret_token = '9e365175b4255ddc2772a096bc9926017d8ad7a16a56970fe1db7ef57ae19776178228e20899dd3ba1726d29ca5c8075e168a243a06fc776788cbc5afc5525a2'
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
4
+
5
+ # Use the database for sessions instead of the cookie-based default,
6
+ # which shouldn't be used to store highly confidential information
7
+ # (create the session table with "rails generate session_migration")
8
+ # Dummy::Application.config.session_store :active_record_store
@@ -0,0 +1,14 @@
1
+ # Be sure to restart your server when you modify this file.
2
+ #
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json]
9
+ end
10
+
11
+ # Disable root element in JSON by default.
12
+ ActiveSupport.on_load(:active_record) do
13
+ self.include_root_in_json = false
14
+ end
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,60 @@
1
+ Dummy::Application.routes.draw do
2
+ devise_for :users
3
+
4
+ # The priority is based upon order of creation:
5
+ # first created -> highest priority.
6
+
7
+ # Sample of regular route:
8
+ # match 'products/:id' => 'catalog#view'
9
+ # Keep in mind you can assign values other than :controller and :action
10
+
11
+ # Sample of named route:
12
+ # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
13
+ # This route can be invoked with purchase_url(:id => product.id)
14
+
15
+ # Sample resource route (maps HTTP verbs to controller actions automatically):
16
+ # resources :products
17
+
18
+ # Sample resource route with options:
19
+ # resources :products do
20
+ # member do
21
+ # get 'short'
22
+ # post 'toggle'
23
+ # end
24
+ #
25
+ # collection do
26
+ # get 'sold'
27
+ # end
28
+ # end
29
+
30
+ # Sample resource route with sub-resources:
31
+ # resources :products do
32
+ # resources :comments, :sales
33
+ # resource :seller
34
+ # end
35
+
36
+ # Sample resource route with more complex sub-resources
37
+ # resources :products do
38
+ # resources :comments
39
+ # resources :sales do
40
+ # get 'recent', :on => :collection
41
+ # end
42
+ # end
43
+
44
+ # Sample resource route within a namespace:
45
+ # namespace :admin do
46
+ # # Directs /admin/products/* to Admin::ProductsController
47
+ # # (app/controllers/admin/products_controller.rb)
48
+ # resources :products
49
+ # end
50
+
51
+ # You can have the root of your site routed with "root"
52
+ # just remember to delete public/index.html.
53
+ # root :to => 'welcome#index'
54
+
55
+ # See how all your routes lay out with "rake routes"
56
+
57
+ # This is a legacy wild controller route that's not recommended for RESTful applications.
58
+ # Note: This route will make all actions in every controller accessible via GET requests.
59
+ # match ':controller(/:action(/:id(.:format)))'
60
+ end
@@ -0,0 +1,62 @@
1
+ class CreatePatrons < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :patrons do |t|
4
+ t.integer :user_id
5
+ t.string :last_name
6
+ t.string :middle_name
7
+ t.string :first_name
8
+ t.string :last_name_transcription
9
+ t.string :middle_name_transcription
10
+ t.string :first_name_transcription
11
+ t.string :corporate_name
12
+ t.string :corporate_name_transcription
13
+ t.string :full_name
14
+ t.text :full_name_transcription
15
+ t.text :full_name_alternative
16
+ t.timestamps
17
+ t.datetime :deleted_at
18
+ t.string :zip_code_1
19
+ t.string :zip_code_2
20
+ t.text :address_1
21
+ t.text :address_2
22
+ t.text :address_1_note
23
+ t.text :address_2_note
24
+ t.string :telephone_number_1
25
+ t.string :telephone_number_2
26
+ t.string :fax_number_1
27
+ t.string :fax_number_2
28
+ t.text :other_designation
29
+ t.text :place
30
+ t.string :postal_code
31
+ t.text :street
32
+ t.text :locality
33
+ t.text :region
34
+ t.datetime :date_of_birth
35
+ t.datetime :date_of_death
36
+ t.integer :language_id, :default => 1, :null => false
37
+ t.integer :country_id, :default => 1, :null => false
38
+ t.integer :patron_type_id, :default => 1, :null => false
39
+ t.integer :lock_version, :default => 0, :null => false
40
+ t.text :note
41
+ t.integer :creates_count, :default => 0, :null => false
42
+ t.integer :realizes_count, :default => 0, :null => false
43
+ t.integer :produces_count, :default => 0, :null => false
44
+ t.integer :owns_count, :default => 0, :null => false
45
+ #t.integer :resource_has_subjects_count, :default => 0, :null => false
46
+ t.integer :required_role_id, :default => 1, :null => false
47
+ t.integer :required_score, :default => 0, :null => false
48
+ t.string :state
49
+ t.text :email
50
+ t.text :url
51
+ end
52
+ add_index :patrons, :user_id, :unique => true
53
+ add_index :patrons, :language_id
54
+ add_index :patrons, :country_id
55
+ add_index :patrons, :required_role_id
56
+ add_index :patrons, :full_name
57
+ end
58
+
59
+ def self.down
60
+ drop_table :patrons
61
+ end
62
+ end
@@ -0,0 +1,25 @@
1
+ class CreateLibraryGroups < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :library_groups do |t|
4
+ t.string :name, :null => false
5
+ t.text :display_name
6
+ t.string :short_name, :null => false
7
+ t.string :email
8
+ t.text :my_networks
9
+ t.boolean :use_dsbl, :default => false, :null => false
10
+ t.text :dsbl_list
11
+ t.text :login_banner
12
+ t.text :note
13
+ t.integer :valid_period_for_new_user, :default => 365, :null => false
14
+ t.boolean :post_to_union_catalog, :default => false, :null => false
15
+ t.integer :country_id
16
+
17
+ t.timestamps
18
+ end
19
+ add_index :library_groups, :short_name
20
+ end
21
+
22
+ def self.down
23
+ drop_table :library_groups
24
+ end
25
+ end
@@ -0,0 +1,16 @@
1
+ class CreatePatronTypes < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :patron_types do |t|
4
+ t.string :name, :null => false
5
+ t.text :display_name
6
+ t.text :note
7
+ t.integer :position
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+
13
+ def self.down
14
+ drop_table :patron_types
15
+ end
16
+ end
@@ -0,0 +1,9 @@
1
+ class AddAdminNetworksToLibraryGroup < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :library_groups, :admin_networks, :text
4
+ end
5
+
6
+ def self.down
7
+ remove_column :library_groups, :admin_networks
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class AddAllowBookmarkExternalUrlToLibraryGroup < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :library_groups, :allow_bookmark_external_url, :boolean, :null => false, :default => false
4
+ end
5
+
6
+ def self.down
7
+ remove_column :library_groups, :allow_bookmark_external_url
8
+ end
9
+ end
@@ -0,0 +1,21 @@
1
+ class CreateDelayedJobs < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :delayed_jobs, :force => true do |table|
4
+ table.integer :priority, :default => 0 # Allows some jobs to jump to the front of the queue
5
+ table.integer :attempts, :default => 0 # Provides for retries, but still fail eventually.
6
+ table.text :handler # YAML-encoded string of the object that will do work
7
+ table.text :last_error # reason for last failure (See Note below)
8
+ table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future.
9
+ table.datetime :locked_at # Set when a client is working on this object
10
+ table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)
11
+ table.string :locked_by # Who is working on this object (if locked)
12
+ table.timestamps
13
+ end
14
+
15
+ add_index :delayed_jobs, [:priority, :run_at], :name => 'delayed_jobs_priority'
16
+ end
17
+
18
+ def self.down
19
+ drop_table :delayed_jobs
20
+ end
21
+ end
@@ -0,0 +1,9 @@
1
+ class AddPositionToLibraryGroup < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :library_groups, :position, :integer
4
+ end
5
+
6
+ def self.down
7
+ remove_column :library_groups, :position
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class AddUrlToLibraryGroup < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :library_groups, :url, :string, :default => 'http://localhost:3000/'
4
+ end
5
+
6
+ def self.down
7
+ remove_column :library_groups, :url
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ class RemoveDsblFromLibraryGroup < ActiveRecord::Migration
2
+ def up
3
+ remove_column :library_groups, :use_dsbl
4
+ remove_column :library_groups, :dsbl_list
5
+ end
6
+
7
+ def down
8
+ add_column :library_groups, :dsbl_list, :text
9
+ add_column :library_groups, :use_dsbl, :boolean
10
+ end
11
+ end
@@ -0,0 +1,16 @@
1
+ class CreateLanguages < ActiveRecord::Migration
2
+ def change
3
+ create_table :languages do |t|
4
+ t.string :name
5
+ t.string :native_name
6
+ t.text :display_name
7
+ t.string :iso_639_1
8
+ t.string :iso_639_2
9
+ t.string :iso_639_3
10
+ t.text :note
11
+ t.integer :position
12
+
13
+ t.timestamps
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,12 @@
1
+ class CreateRoles < ActiveRecord::Migration
2
+ def change
3
+ create_table :roles do |t|
4
+ t.string :name
5
+ t.text :display_name
6
+ t.text :note
7
+ t.integer :position
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ class CreateUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table :users do |t|
4
+ t.integer :user_group_id
5
+ t.integer :required_role_id
6
+ t.string :username
7
+ t.text :note
8
+ t.string :locale
9
+ t.string :user_number
10
+
11
+ t.timestamps
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,52 @@
1
+ class AddDeviseToUsers < ActiveRecord::Migration
2
+ def self.up
3
+ change_table(:users) do |t|
4
+ ## Database authenticatable
5
+ t.string :email, :null => false, :default => ""
6
+ t.string :encrypted_password, :null => false, :default => ""
7
+
8
+ ## Recoverable
9
+ t.string :reset_password_token
10
+ t.datetime :reset_password_sent_at
11
+
12
+ ## Rememberable
13
+ t.datetime :remember_created_at
14
+
15
+ ## Trackable
16
+ t.integer :sign_in_count, :default => 0
17
+ t.datetime :current_sign_in_at
18
+ t.datetime :last_sign_in_at
19
+ t.string :current_sign_in_ip
20
+ t.string :last_sign_in_ip
21
+
22
+ ## Encryptable
23
+ t.string :password_salt
24
+
25
+ ## Confirmable
26
+ t.string :confirmation_token
27
+ t.datetime :confirmed_at
28
+ t.datetime :confirmation_sent_at
29
+ t.string :unconfirmed_email # Only if using reconfirmable
30
+
31
+ ## Lockable
32
+ t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
33
+ t.string :unlock_token # Only if unlock strategy is :email or :both
34
+ t.datetime :locked_at
35
+
36
+ # Token authenticatable
37
+ t.string :authentication_token
38
+ end
39
+
40
+ add_index :users, :email #, :unique => true
41
+ add_index :users, :reset_password_token, :unique => true
42
+ # add_index :users, :confirmation_token, :unique => true
43
+ # add_index :users, :unlock_token, :unique => true
44
+ # add_index :users, :authentication_token, :unique => true
45
+ end
46
+
47
+ def self.down
48
+ # By default, we don't want to make any assumption about how to roll back a migration when your
49
+ # model already existed. Please edit below which fields you would like to remove in this migration.
50
+ raise ActiveRecord::IrreversibleMigration
51
+ end
52
+ end
@@ -0,0 +1,12 @@
1
+ class CreateUserGroups < ActiveRecord::Migration
2
+ def change
3
+ create_table :user_groups do |t|
4
+ t.string :name
5
+ t.text :display_name
6
+ t.text :note
7
+ t.integer :position
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,10 @@
1
+ class CreateUserHasRoles < ActiveRecord::Migration
2
+ def change
3
+ create_table :user_has_roles do |t|
4
+ t.integer :user_id
5
+ t.integer :role_id
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ class AddQueueToDelayedJobs < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :delayed_jobs, :queue, :string
4
+ end
5
+
6
+ def self.down
7
+ remove_column :delayed_jobs, :queue
8
+ end
9
+ end