enju_news 0.1.1 → 0.2.0.beta.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +3 -3
  3. data/app/controllers/news_feeds_controller.rb +11 -1
  4. data/app/controllers/news_posts_controller.rb +12 -2
  5. data/app/models/news_post.rb +12 -0
  6. data/app/policies/news_feed_policy.rb +21 -0
  7. data/app/policies/news_post_policy.rb +21 -0
  8. data/app/views/news_feeds/index.html.erb +4 -2
  9. data/app/views/news_posts/index.html.erb +3 -1
  10. data/lib/enju_news/engine.rb +1 -1
  11. data/lib/enju_news/version.rb +1 -1
  12. data/spec/controllers/news_feeds_controller_spec.rb +12 -12
  13. data/spec/controllers/news_posts_controller_spec.rb +10 -10
  14. data/spec/dummy/app/controllers/application_controller.rb +5 -2
  15. data/spec/dummy/app/models/user.rb +1 -2
  16. data/spec/dummy/config/application.rb +7 -24
  17. data/spec/dummy/config/environments/development.rb +25 -14
  18. data/spec/dummy/config/environments/production.rb +50 -31
  19. data/spec/dummy/config/environments/test.rb +23 -18
  20. data/spec/dummy/db/migrate/149_create_message_templates.rb +18 -0
  21. data/spec/dummy/db/migrate/154_create_messages.rb +23 -0
  22. data/spec/dummy/db/migrate/20080819181903_create_message_requests.rb +18 -0
  23. data/spec/dummy/db/migrate/20110913115320_add_lft_and_rgt_to_message.rb +11 -0
  24. data/spec/dummy/db/migrate/20120125050502_add_depth_to_message.rb +6 -0
  25. data/spec/dummy/db/migrate/20140110122216_create_user_import_files.rb +1 -1
  26. data/spec/dummy/db/migrate/20140518111006_create_message_transitions.rb +18 -0
  27. data/spec/dummy/db/migrate/20140518135713_create_message_request_transitions.rb +18 -0
  28. data/spec/dummy/db/migrate/20140524074813_create_user_import_file_transitions.rb +5 -1
  29. data/spec/dummy/db/migrate/20140709113905_create_user_export_file_transitions.rb +5 -1
  30. data/spec/dummy/db/migrate/20140821151023_create_colors.rb +14 -0
  31. data/spec/dummy/db/migrate/20150506105356_add_error_message_to_user_import_result.rb +5 -0
  32. data/spec/dummy/db/migrate/20150924115059_create_withdraws.rb +13 -0
  33. data/spec/dummy/db/migrate/20151213070943_add_translation_table_to_library_group.rb +13 -0
  34. data/spec/dummy/db/migrate/20151213072705_add_footer_banner_to_library_group.rb +9 -0
  35. data/spec/dummy/db/migrate/20160610093229_add_html_snippet_to_library_group.rb +5 -0
  36. data/spec/dummy/db/migrate/20160627232219_add_most_recent_to_user_import_file_transitions.rb +9 -0
  37. data/spec/dummy/db/migrate/20160627232316_add_most_recent_to_user_export_file_transitions.rb +9 -0
  38. data/spec/dummy/db/migrate/20160703185015_add_most_recent_to_message_transitions.rb +9 -0
  39. data/spec/dummy/db/migrate/20160813191647_add_max_number_of_results_to_library_group.rb +5 -0
  40. data/spec/dummy/db/migrate/20160813191733_add_family_name_first_to_library_group.rb +5 -0
  41. data/spec/dummy/db/migrate/20160813192542_add_pub_year_facet_range_interval_to_library_group.rb +5 -0
  42. data/spec/dummy/db/migrate/20160813203039_add_user_id_to_library_group.rb +5 -0
  43. data/spec/dummy/db/migrate/20160814165332_add_most_recent_to_message_request_transitions.rb +9 -0
  44. data/spec/dummy/db/schema.rb +48 -5
  45. data/spec/fixtures/library_groups.yml +1 -6
  46. data/spec/models/news_feed_spec.rb +1 -1
  47. data/spec/models/news_post_spec.rb +1 -1
  48. data/spec/rails_helper.rb +60 -0
  49. data/spec/spec_helper.rb +84 -52
  50. data/spec/support/devise.rb +2 -2
  51. metadata +114 -17
  52. data/app/models/enju_news/ability.rb +0 -18
  53. data/spec/dummy/app/models/ability.rb +0 -18
  54. data/spec/dummy/config/application.yml +0 -42
@@ -1,30 +1,41 @@
1
- Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
3
 
4
4
  # In the development environment your application's code is reloaded on
5
- # every request. This slows down response time but is perfect for development
5
+ # every request. This slows down response time but is perfect for development
6
6
  # since you don't have to restart the web server when you make code changes.
7
7
  config.cache_classes = false
8
8
 
9
- # Log error messages when you accidentally call methods on nil.
10
- config.whiny_nils = true
9
+ # Do not eager load code on boot.
10
+ config.eager_load = false
11
11
 
12
- # Show full error reports and disable caching
12
+ # Show full error reports and disable caching.
13
13
  config.consider_all_requests_local = true
14
14
  config.action_controller.perform_caching = false
15
15
 
16
- # Don't care if the mailer can't send
16
+ # Don't care if the mailer can't send.
17
17
  config.action_mailer.raise_delivery_errors = false
18
18
 
19
- # Print deprecation notices to the Rails logger
19
+ # Print deprecation notices to the Rails logger.
20
20
  config.active_support.deprecation = :log
21
21
 
22
- # Only use best-standards-support built into browsers
23
- config.action_dispatch.best_standards_support = :builtin
22
+ # Raise an error on page load if there are pending migrations.
23
+ config.active_record.migration_error = :page_load
24
24
 
25
- # Do not compress assets
26
- config.assets.compress = false
27
-
28
- # Expands the lines which load the assets
25
+ # Debug mode disables concatenation and preprocessing of assets.
26
+ # This option may cause significant delays in view rendering with a large
27
+ # number of complex assets.
29
28
  config.assets.debug = true
29
+
30
+ # Asset digests allow you to set far-future HTTP expiration dates on all assets,
31
+ # yet still be able to expire them through the digest params.
32
+ config.assets.digest = true
33
+
34
+ # Adds additional error checking when serving assets at runtime.
35
+ # Checks for improperly declared sprockets dependencies.
36
+ # Raises helpful error messages.
37
+ config.assets.raise_runtime_errors = true
38
+
39
+ # Raises error for missing translations
40
+ # config.action_view.raise_on_missing_translations = true
30
41
  end
@@ -1,60 +1,79 @@
1
- Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
3
 
4
- # Code is not reloaded between requests
4
+ # Code is not reloaded between requests.
5
5
  config.cache_classes = true
6
6
 
7
- # Full error reports are disabled and caching is turned on
7
+ # Eager load code on boot. This eager loads most of Rails and
8
+ # your application in memory, allowing both threaded web servers
9
+ # and those relying on copy on write to perform better.
10
+ # Rake tasks automatically ignore this option for performance.
11
+ config.eager_load = true
12
+
13
+ # Full error reports are disabled and caching is turned on.
8
14
  config.consider_all_requests_local = false
9
15
  config.action_controller.perform_caching = true
10
16
 
11
- # Disable Rails's static asset server (Apache or nginx will already do this)
12
- config.serve_static_assets = false
17
+ # Enable Rack::Cache to put a simple HTTP cache in front of your application
18
+ # Add `rack-cache` to your Gemfile before enabling this.
19
+ # For large-scale production use, consider using a caching reverse proxy like
20
+ # NGINX, varnish or squid.
21
+ # config.action_dispatch.rack_cache = true
22
+
23
+ # Disable serving static files from the `/public` folder by default since
24
+ # Apache or NGINX already handles this.
25
+ config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
13
26
 
14
- # Compress JavaScripts and CSS
15
- config.assets.compress = true
27
+ # Compress JavaScripts and CSS.
28
+ config.assets.js_compressor = :uglifier
29
+ # config.assets.css_compressor = :sass
16
30
 
17
- # Don't fallback to assets pipeline if a precompiled asset is missed
31
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
18
32
  config.assets.compile = false
19
33
 
20
- # Generate digests for assets URLs
34
+ # Asset digests allow you to set far-future HTTP expiration dates on all assets,
35
+ # yet still be able to expire them through the digest params.
21
36
  config.assets.digest = true
22
37
 
23
- # Defaults to Rails.root.join("public/assets")
24
- # config.assets.manifest = YOUR_PATH
38
+ # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
25
39
 
26
- # Specifies the header that your server uses for sending files
27
- # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
28
- # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
40
+ # Specifies the header that your server uses for sending files.
41
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
42
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
29
43
 
30
44
  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
31
45
  # config.force_ssl = true
32
46
 
33
- # See everything in the log (default is :info)
34
- # config.log_level = :debug
47
+ # Use the lowest log level to ensure availability of diagnostic information
48
+ # when problems arise.
49
+ config.log_level = :debug
35
50
 
36
- # Use a different logger for distributed setups
37
- # config.logger = SyslogLogger.new
51
+ # Prepend all log lines with the following tags.
52
+ # config.log_tags = [ :subdomain, :uuid ]
38
53
 
39
- # Use a different cache store in production
40
- # config.cache_store = :mem_cache_store
54
+ # Use a different logger for distributed setups.
55
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
41
56
 
42
- # Enable serving of images, stylesheets, and JavaScripts from an asset server
43
- # config.action_controller.asset_host = "http://assets.example.com"
57
+ # Use a different cache store in production.
58
+ # config.cache_store = :mem_cache_store
44
59
 
45
- # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
46
- # config.assets.precompile += %w( search.js )
60
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
61
+ # config.action_controller.asset_host = 'http://assets.example.com'
47
62
 
48
- # Disable delivery errors, bad email addresses will be ignored
63
+ # Ignore bad email addresses and do not raise email delivery errors.
64
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
49
65
  # config.action_mailer.raise_delivery_errors = false
50
66
 
51
- # Enable threaded mode
52
- # config.threadsafe!
53
-
54
67
  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
55
- # the I18n.default_locale when a translation can not be found)
68
+ # the I18n.default_locale when a translation cannot be found).
56
69
  config.i18n.fallbacks = true
57
70
 
58
- # Send deprecation notices to registered listeners
71
+ # Send deprecation notices to registered listeners.
59
72
  config.active_support.deprecation = :notify
73
+
74
+ # Use default logging formatter so that PID and timestamp are not suppressed.
75
+ config.log_formatter = ::Logger::Formatter.new
76
+
77
+ # Do not dump schema after migrations.
78
+ config.active_record.dump_schema_after_migration = false
60
79
  end
@@ -1,39 +1,44 @@
1
- Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
3
 
4
4
  # The test environment is used exclusively to run your application's
5
- # test suite. You never need to work with it otherwise. Remember that
5
+ # test suite. You never need to work with it otherwise. Remember that
6
6
  # your test database is "scratch space" for the test suite and is wiped
7
- # and recreated between test runs. Don't rely on the data there!
7
+ # and recreated between test runs. Don't rely on the data there!
8
8
  config.cache_classes = true
9
9
 
10
- # Configure static asset server for tests with Cache-Control for performance
11
- config.serve_static_assets = true
12
- config.static_cache_control = "public, max-age=3600"
10
+ # Do not eager load code on boot. This avoids loading your whole application
11
+ # just for the purpose of running a single test. If you are using a tool that
12
+ # preloads Rails for running tests, you may have to set it to true.
13
+ config.eager_load = false
13
14
 
14
- # Log error messages when you accidentally call methods on nil
15
- config.whiny_nils = true
15
+ # Configure static file server for tests with Cache-Control for performance.
16
+ config.serve_static_files = true
17
+ config.static_cache_control = 'public, max-age=3600'
16
18
 
17
- # Show full error reports and disable caching
19
+ # Show full error reports and disable caching.
18
20
  config.consider_all_requests_local = true
19
21
  config.action_controller.perform_caching = false
20
22
 
21
- # Raise exceptions instead of rendering exception templates
23
+ # Raise exceptions instead of rendering exception templates.
22
24
  config.action_dispatch.show_exceptions = false
23
25
 
24
- # Disable request forgery protection in test environment
25
- config.action_controller.allow_forgery_protection = false
26
+ # Disable request forgery protection in test environment.
27
+ config.action_controller.allow_forgery_protection = false
26
28
 
27
29
  # Tell Action Mailer not to deliver emails to the real world.
28
30
  # The :test delivery method accumulates sent emails in the
29
31
  # ActionMailer::Base.deliveries array.
30
32
  config.action_mailer.delivery_method = :test
31
33
 
32
- # Use SQL instead of Active Record's schema dumper when creating the test database.
33
- # This is necessary if your schema can't be completely dumped by the schema dumper,
34
- # like if you have constraints or database-specific column types
35
- # config.active_record.schema_format = :sql
34
+ # Randomize the order test cases are executed.
35
+ config.active_support.test_order = :random
36
36
 
37
- # Print deprecation notices to the stderr
37
+ # Print deprecation notices to the stderr.
38
38
  config.active_support.deprecation = :stderr
39
+
40
+ # Raises error for missing translations
41
+ # config.action_view.raise_on_missing_translations = true
42
+
43
+ config.action_mailer.default_url_options = {:host => 'localhost:3000'}
39
44
  end
@@ -0,0 +1,18 @@
1
+ class CreateMessageTemplates < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :message_templates do |t|
4
+ t.string :status, :null => false
5
+ t.text :title, :null => false
6
+ t.text :body, :null => false
7
+ t.integer :position
8
+ t.string :locale, :default => I18n.default_locale.to_s
9
+
10
+ t.timestamps
11
+ end
12
+ add_index :message_templates, :status, :unique => true
13
+ end
14
+
15
+ def self.down
16
+ drop_table :message_templates
17
+ end
18
+ end
@@ -0,0 +1,23 @@
1
+ class CreateMessages < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :messages, :force => true do |t|
4
+ t.datetime :read_at
5
+ t.integer :receiver_id, :sender_id
6
+ t.string :subject, :null => false
7
+ t.text :body
8
+ t.integer :message_request_id
9
+ t.integer :parent_id
10
+
11
+ t.timestamps
12
+ end
13
+
14
+ add_index :messages, :sender_id
15
+ add_index :messages, :receiver_id
16
+ add_index :messages, :message_request_id
17
+ add_index :messages, :parent_id
18
+ end
19
+
20
+ def self.down
21
+ drop_table :messages
22
+ end
23
+ end
@@ -0,0 +1,18 @@
1
+ class CreateMessageRequests < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :message_requests do |t|
4
+ t.integer :sender_id
5
+ t.integer :receiver_id
6
+ t.integer :message_template_id
7
+ t.datetime :sent_at
8
+ t.datetime :deleted_at
9
+ t.text :body
10
+
11
+ t.timestamps
12
+ end
13
+ end
14
+
15
+ def self.down
16
+ drop_table :message_requests
17
+ end
18
+ end
@@ -0,0 +1,11 @@
1
+ class AddLftAndRgtToMessage < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :messages, :lft, :integer
4
+ add_column :messages, :rgt, :integer
5
+ end
6
+
7
+ def self.down
8
+ remove_column :messages, :rgt
9
+ remove_column :messages, :lft
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+ class AddDepthToMessage < ActiveRecord::Migration
2
+ def change
3
+ add_column :messages, :depth, :integer
4
+
5
+ end
6
+ end
@@ -6,7 +6,7 @@ class CreateUserImportFiles < ActiveRecord::Migration
6
6
  t.datetime :executed_at
7
7
  t.string :user_import_file_name
8
8
  t.string :user_import_content_type
9
- t.string :user_import_file_size
9
+ t.integer :user_import_file_size
10
10
  t.datetime :user_import_updated_at
11
11
  t.string :user_import_fingerprint
12
12
  t.string :edit_mode
@@ -0,0 +1,18 @@
1
+ class CreateMessageTransitions < ActiveRecord::Migration
2
+ def change
3
+ create_table :message_transitions do |t|
4
+ t.string :to_state
5
+ if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
6
+ t.text :metadata
7
+ else
8
+ t.text :metadata, default: "{}"
9
+ end
10
+ t.integer :sort_key
11
+ t.integer :message_id
12
+ t.timestamps
13
+ end
14
+
15
+ add_index :message_transitions, :message_id
16
+ add_index :message_transitions, [:sort_key, :message_id], unique: true
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ class CreateMessageRequestTransitions < ActiveRecord::Migration
2
+ def change
3
+ create_table :message_request_transitions do |t|
4
+ t.string :to_state
5
+ if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
6
+ t.text :metadata
7
+ else
8
+ t.text :metadata, default: "{}"
9
+ end
10
+ t.integer :sort_key
11
+ t.integer :message_request_id
12
+ t.timestamps
13
+ end
14
+
15
+ add_index :message_request_transitions, :message_request_id
16
+ add_index :message_request_transitions, [:sort_key, :message_request_id], unique: true, name: "index_message_request_transitions_on_sort_key_and_request_id"
17
+ end
18
+ end
@@ -2,7 +2,11 @@ class CreateUserImportFileTransitions < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :user_import_file_transitions do |t|
4
4
  t.string :to_state
5
- t.text :metadata, default: "{}"
5
+ if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
6
+ t.text :metadata
7
+ else
8
+ t.text :metadata, default: "{}"
9
+ end
6
10
  t.integer :sort_key
7
11
  t.integer :user_import_file_id
8
12
  t.timestamps
@@ -2,7 +2,11 @@ class CreateUserExportFileTransitions < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :user_export_file_transitions do |t|
4
4
  t.string :to_state
5
- t.text :metadata, default: "{}"
5
+ if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
6
+ t.text :metadata
7
+ else
8
+ t.text :metadata, default: "{}"
9
+ end
6
10
  t.integer :sort_key
7
11
  t.integer :user_export_file_id
8
12
  t.timestamps
@@ -0,0 +1,14 @@
1
+ class CreateColors < ActiveRecord::Migration
2
+ def change
3
+ create_table :colors do |t|
4
+ t.integer :library_group_id
5
+ t.string :property
6
+ t.string :code
7
+ t.integer :position
8
+
9
+ t.timestamps
10
+ end
11
+
12
+ add_index :colors, :library_group_id
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ class AddErrorMessageToUserImportResult < ActiveRecord::Migration
2
+ def change
3
+ add_column :user_import_results, :error_message, :text
4
+ end
5
+ end
@@ -0,0 +1,13 @@
1
+ class CreateWithdraws < ActiveRecord::Migration
2
+ def change
3
+ create_table :withdraws do |t|
4
+ t.integer :basket_id
5
+ t.integer :item_id
6
+ t.integer :librarian_id
7
+
8
+ t.timestamps null: false
9
+ end
10
+ add_index :withdraws, :basket_id
11
+ add_index :withdraws, :item_id
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ class AddTranslationTableToLibraryGroup < ActiveRecord::Migration
2
+ def up
3
+ LibraryGroup.create_translation_table!({
4
+ login_banner: :text
5
+ }, {
6
+ migrate_data: true
7
+ })
8
+ end
9
+
10
+ def down
11
+ LibraryGroup.drop_translation_table! migrate_data: true
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ class AddFooterBannerToLibraryGroup < ActiveRecord::Migration
2
+ def up
3
+ LibraryGroup.add_translation_fields! footer_banner: :text
4
+ end
5
+
6
+ def down
7
+ remove_column :library_group_translations, :footer_banner
8
+ end
9
+ end