date_book 0.0.1

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 (203) hide show
  1. checksums.yaml +7 -0
  2. data/.idea/vcs.xml +6 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +23 -0
  5. data/.rubocop_todo.yml +7 -0
  6. data/.ruby-gemset +1 -0
  7. data/.ruby-version +1 -0
  8. data/.travis.yml +3 -0
  9. data/Gemfile +94 -0
  10. data/Gemfile.lock +385 -0
  11. data/LICENSE.txt +20 -0
  12. data/README.md +64 -0
  13. data/Rakefile +30 -0
  14. data/VERSION +1 -0
  15. data/app/assets/images/date_book/.keep +0 -0
  16. data/app/assets/javascripts/date_book.js +21 -0
  17. data/app/assets/javascripts/date_book/calendar_events.js +57 -0
  18. data/app/assets/javascripts/date_book/event_form.js +31 -0
  19. data/app/assets/javascripts/date_book/popovers.js +3 -0
  20. data/app/assets/javascripts/date_book/wysiwyg.js +8 -0
  21. data/app/assets/stylesheets/date_book.css.scss +46 -0
  22. data/app/controllers/date_book/calendars_controller.rb +60 -0
  23. data/app/controllers/date_book/date_book_controller.rb +24 -0
  24. data/app/controllers/date_book/events_controller.rb +105 -0
  25. data/app/controllers/date_book/graphql_controller.rb +35 -0
  26. data/app/graphql/date_book_schema.rb +18 -0
  27. data/app/graphql/types/calendar_type.rb +14 -0
  28. data/app/graphql/types/date_time_type.rb +7 -0
  29. data/app/graphql/types/event_occurrence_type.rb +11 -0
  30. data/app/graphql/types/event_type.rb +19 -0
  31. data/app/graphql/types/mutation_type.rb +5 -0
  32. data/app/graphql/types/profile_type.rb +7 -0
  33. data/app/graphql/types/query_type.rb +57 -0
  34. data/app/helpers/date_book/application_helper.rb +35 -0
  35. data/app/helpers/date_book/calendar_helper.rb +4 -0
  36. data/app/helpers/date_book/events_helper.rb +42 -0
  37. data/app/jobs/date_book/application_job.rb +6 -0
  38. data/app/mailers/date_book/application_mailer.rb +9 -0
  39. data/app/views/date_book/application/_all_day_checkbox.html.haml +1 -0
  40. data/app/views/date_book/application/_date_range.html.haml +8 -0
  41. data/app/views/date_book/application/_wysiwyg.html.haml +65 -0
  42. data/app/views/date_book/calendars/_form.html.haml +6 -0
  43. data/app/views/date_book/calendars/edit.html.haml +5 -0
  44. data/app/views/date_book/calendars/index.html.haml +28 -0
  45. data/app/views/date_book/calendars/new.html.haml +5 -0
  46. data/app/views/date_book/calendars/show.html.haml +28 -0
  47. data/app/views/date_book/events/_event.json.jbuilder +12 -0
  48. data/app/views/date_book/events/_form.html.haml +16 -0
  49. data/app/views/date_book/events/_occurrence_dates.html.haml +11 -0
  50. data/app/views/date_book/events/edit.html.haml +5 -0
  51. data/app/views/date_book/events/fields/_date.html.haml +1 -0
  52. data/app/views/date_book/events/fields/_day.html.haml +1 -0
  53. data/app/views/date_book/events/fields/_day_of_week.html.haml +19 -0
  54. data/app/views/date_book/events/fields/_duration.html.haml +6 -0
  55. data/app/views/date_book/events/fields/_interval.html.haml +1 -0
  56. data/app/views/date_book/events/fields/_time.html.haml +1 -0
  57. data/app/views/date_book/events/index.html.haml +16 -0
  58. data/app/views/date_book/events/new.html.haml +5 -0
  59. data/app/views/date_book/events/popover.html.haml +7 -0
  60. data/app/views/date_book/events/rules/_daily.html.haml +4 -0
  61. data/app/views/date_book/events/rules/_monthly.html.haml +5 -0
  62. data/app/views/date_book/events/rules/_singular.html.haml +4 -0
  63. data/app/views/date_book/events/rules/_weekly.html.haml +5 -0
  64. data/app/views/date_book/events/show.html.haml +16 -0
  65. data/app/views/layouts/_date_book_scripts.html.haml +4 -0
  66. data/app/views/layouts/blank.html.haml +1 -0
  67. data/bin/rails +15 -0
  68. data/config/locales/en.yml +44 -0
  69. data/config/routes.rb +12 -0
  70. data/date_book.gemspec +337 -0
  71. data/db/migrate/20170807133845_create_calendars.rb +11 -0
  72. data/db/migrate/20170807133846_create_events.rb +20 -0
  73. data/db/migrate/20170807133847_create_schedules.rb +25 -0
  74. data/db/migrate/20170807133848_add_fields_to_schedule.rb +6 -0
  75. data/db/migrate/20170807133849_create_event_occurrences.rb +16 -0
  76. data/db/migrate/20170807133850_add_fields_to_event_occurrences.rb +5 -0
  77. data/lib/date_book.rb +40 -0
  78. data/lib/date_book/concerns/ability.rb +27 -0
  79. data/lib/date_book/concerns/acts_as_calendar.rb +29 -0
  80. data/lib/date_book/concerns/acts_as_event.rb +66 -0
  81. data/lib/date_book/concerns/acts_as_event_occurrence.rb +67 -0
  82. data/lib/date_book/concerns/acts_as_ownable.rb +29 -0
  83. data/lib/date_book/concerns/acts_as_owner.rb +18 -0
  84. data/lib/date_book/concerns/acts_as_schedule.rb +44 -0
  85. data/lib/date_book/configuration.rb +43 -0
  86. data/lib/date_book/engine.rb +40 -0
  87. data/lib/date_book/localization.rb +32 -0
  88. data/lib/date_book/version.rb +8 -0
  89. data/lib/generators/date_book/install/install_generator.rb +110 -0
  90. data/lib/generators/date_book/install/templates/app/models/ability.rb +16 -0
  91. data/lib/generators/date_book/install/templates/app/models/calendar.rb +3 -0
  92. data/lib/generators/date_book/install/templates/app/models/event.rb +3 -0
  93. data/lib/generators/date_book/install/templates/app/models/event_occurrence.rb +3 -0
  94. data/lib/generators/date_book/install/templates/app/models/schedule.rb +3 -0
  95. data/lib/generators/date_book/install/templates/config/initializers/date_book.rb +5 -0
  96. data/lib/generators/date_book/utils.rb +25 -0
  97. data/lib/tasks/date_book_tasks.rake +5 -0
  98. data/spec/abilities/calendar_spec.rb +39 -0
  99. data/spec/abilities/event_spec.rb +44 -0
  100. data/spec/controllers/date_book/calendars_controller_spec.rb +259 -0
  101. data/spec/controllers/date_book/events_controller_spec.rb +283 -0
  102. data/spec/dummy/Rakefile +9 -0
  103. data/spec/dummy/app/assets/config/manifest.js +5 -0
  104. data/spec/dummy/app/assets/images/.keep +0 -0
  105. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  106. data/spec/dummy/app/assets/stylesheets/application.css.scss +4 -0
  107. data/spec/dummy/app/assets/stylesheets/bootstrap-everything.scss +54 -0
  108. data/spec/dummy/app/controllers/application_controller.rb +21 -0
  109. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  110. data/spec/dummy/app/helpers/application_helper.rb +4 -0
  111. data/spec/dummy/app/mailers/application_mailer.rb +6 -0
  112. data/spec/dummy/app/models/ability.rb +16 -0
  113. data/spec/dummy/app/models/application_record.rb +5 -0
  114. data/spec/dummy/app/models/calendar.rb +3 -0
  115. data/spec/dummy/app/models/concerns/.keep +0 -0
  116. data/spec/dummy/app/models/event.rb +3 -0
  117. data/spec/dummy/app/models/event_occurrence.rb +3 -0
  118. data/spec/dummy/app/models/role.rb +13 -0
  119. data/spec/dummy/app/models/schedule.rb +3 -0
  120. data/spec/dummy/app/models/user.rb +9 -0
  121. data/spec/dummy/app/views/application/403.html.haml +9 -0
  122. data/spec/dummy/app/views/application/404.html.haml +9 -0
  123. data/spec/dummy/app/views/layouts/application.html.haml +43 -0
  124. data/spec/dummy/app/views/pages/index.html.haml +1 -0
  125. data/spec/dummy/bin/bundle +5 -0
  126. data/spec/dummy/bin/rails +6 -0
  127. data/spec/dummy/bin/rake +6 -0
  128. data/spec/dummy/bin/setup +36 -0
  129. data/spec/dummy/bin/update +31 -0
  130. data/spec/dummy/config.ru +7 -0
  131. data/spec/dummy/config/application.rb +38 -0
  132. data/spec/dummy/config/boot.rb +7 -0
  133. data/spec/dummy/config/cable.yml +9 -0
  134. data/spec/dummy/config/database.yml +25 -0
  135. data/spec/dummy/config/environment.rb +7 -0
  136. data/spec/dummy/config/environments/development.rb +60 -0
  137. data/spec/dummy/config/environments/test.rb +45 -0
  138. data/spec/dummy/config/initializers/application_controller_renderer.rb +7 -0
  139. data/spec/dummy/config/initializers/assets.rb +14 -0
  140. data/spec/dummy/config/initializers/backtrace_silencers.rb +10 -0
  141. data/spec/dummy/config/initializers/bootstrap_leather.rb +9 -0
  142. data/spec/dummy/config/initializers/cookies_serializer.rb +7 -0
  143. data/spec/dummy/config/initializers/date_book.rb +5 -0
  144. data/spec/dummy/config/initializers/devise.rb +277 -0
  145. data/spec/dummy/config/initializers/filter_parameter_logging.rb +6 -0
  146. data/spec/dummy/config/initializers/high_voltage.rb +3 -0
  147. data/spec/dummy/config/initializers/inflections.rb +17 -0
  148. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  149. data/spec/dummy/config/initializers/new_framework_defaults.rb +29 -0
  150. data/spec/dummy/config/initializers/rolify.rb +7 -0
  151. data/spec/dummy/config/initializers/session_store.rb +5 -0
  152. data/spec/dummy/config/initializers/wrap_parameters.rb +17 -0
  153. data/spec/dummy/config/locales/devise.en.yml +64 -0
  154. data/spec/dummy/config/locales/en.yml +23 -0
  155. data/spec/dummy/config/puma.rb +49 -0
  156. data/spec/dummy/config/routes.rb +15 -0
  157. data/spec/dummy/config/secrets.yml +22 -0
  158. data/spec/dummy/config/spring.rb +8 -0
  159. data/spec/dummy/db/migrate/20170728171103_create_users_table.rb +7 -0
  160. data/spec/dummy/db/migrate/20170807134122_add_devise_to_users.rb +49 -0
  161. data/spec/dummy/db/migrate/20170807134128_rolify_create_roles.rb +19 -0
  162. data/spec/dummy/db/migrate/20170807134137_create_calendars.date_book.rb +12 -0
  163. data/spec/dummy/db/migrate/20170807134138_create_events.date_book.rb +21 -0
  164. data/spec/dummy/db/migrate/20170807134139_create_schedules.date_book.rb +26 -0
  165. data/spec/dummy/db/migrate/20170807134140_add_fields_to_schedule.date_book.rb +7 -0
  166. data/spec/dummy/db/migrate/20170807134141_create_event_occurrences.date_book.rb +17 -0
  167. data/spec/dummy/db/migrate/20170807134142_add_fields_to_event_occurrences.date_book.rb +6 -0
  168. data/spec/dummy/db/schema.rb +101 -0
  169. data/spec/dummy/db/seeds.rb +0 -0
  170. data/spec/dummy/db/seeds/calendars.seeds.rb +22 -0
  171. data/spec/dummy/db/seeds/events.seeds.rb +89 -0
  172. data/spec/dummy/db/seeds/users.seeds.rb +16 -0
  173. data/spec/dummy/lib/assets/.keep +0 -0
  174. data/spec/dummy/lib/basic_benchmark.rb +9 -0
  175. data/spec/dummy/log/.keep +0 -0
  176. data/spec/factories/calendars.rb +11 -0
  177. data/spec/factories/events.rb +12 -0
  178. data/spec/factories/roles.rb +5 -0
  179. data/spec/factories/users.rb +9 -0
  180. data/spec/features/calendars_spec.rb +185 -0
  181. data/spec/features/events_spec.rb +201 -0
  182. data/spec/helpers/date_book/calendar_helper_spec.rb +17 -0
  183. data/spec/helpers/date_book/events_helper_spec.rb +17 -0
  184. data/spec/models/calendar_spec.rb +26 -0
  185. data/spec/models/event_spec.rb +67 -0
  186. data/spec/models/role_spec.rb +5 -0
  187. data/spec/rails_helper.rb +116 -0
  188. data/spec/requests/date_book/events_spec.rb +56 -0
  189. data/spec/routing/date_book/calendars_routing_spec.rb +49 -0
  190. data/spec/routing/date_book/events_routing_spec.rb +54 -0
  191. data/spec/spec_helper.rb +102 -0
  192. data/spec/support/controller_behaviors.rb +101 -0
  193. data/spec/support/controller_macros.rb +25 -0
  194. data/spec/support/factory_girl.rb +3 -0
  195. data/spec/support/feature_behaviors.rb +150 -0
  196. data/spec/support/loaded_site.rb +5 -0
  197. data/spec/support/loaded_site/calendars.rb +5 -0
  198. data/spec/support/loaded_site/events.rb +6 -0
  199. data/spec/support/loaded_site/users.rb +5 -0
  200. data/spec/support/request_behaviors.rb +89 -0
  201. data/spec/support/shared_connection.rb +14 -0
  202. data/spec/support/utilities.rb +53 -0
  203. metadata +817 -0
@@ -0,0 +1,23 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # To learn more, please read the Rails Internationalization guide
20
+ # available at http://guides.rubyonrails.org/i18n.html.
21
+
22
+ en:
23
+ hello: "Hello world"
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Puma can serve each request in a thread from an internal thread pool.
4
+ # The `threads` method setting takes two numbers a minimum and maximum.
5
+ # Any libraries that use thread pools should be configured to match
6
+ # the maximum value specified for Puma. Default is set to 5 threads for minimum
7
+ # and maximum, this matches the default thread size of Active Record.
8
+ #
9
+ threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }.to_i
10
+ threads threads_count, threads_count
11
+
12
+ # Specifies the `port` that Puma will listen on to receive requests,
13
+ # default is 3000.
14
+ port ENV.fetch('PORT') { 3000 }
15
+
16
+ # Specifies the `environment` that Puma will run in.
17
+ #
18
+ environment ENV.fetch('RAILS_ENV') { 'development' }
19
+
20
+ # Specifies the number of `workers` to boot in clustered mode.
21
+ # Workers are forked webserver processes. If using threads and workers together
22
+ # the concurrency of the application would be max `threads` * `workers`.
23
+ # Workers do not work on JRuby or Windows (both of which do not support
24
+ # processes).
25
+ #
26
+ # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
27
+
28
+ # Use the `preload_app!` method when specifying a `workers` number.
29
+ # This directive tells Puma to first boot the application and load code
30
+ # before forking the application. This takes advantage of Copy On Write
31
+ # process behavior so workers use less memory. If you use this option
32
+ # you need to make sure to reconnect any threads in the `on_worker_boot`
33
+ # block.
34
+ #
35
+ # preload_app!
36
+
37
+ # The code in the `on_worker_boot` will be called if you are using
38
+ # clustered mode by specifying a number of `workers`. After each worker
39
+ # process is booted this block will be run, if you are using `preload_app!`
40
+ # option you will want to use this block to reconnect to any threads
41
+ # or connections that may have been created at application boot, Ruby
42
+ # cannot share connections between processes.
43
+ #
44
+ # on_worker_boot do
45
+ # ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
46
+ # end
47
+
48
+ # Allow puma to be restarted by `rails restart` command.
49
+ plugin :tmp_restart
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.routes.draw do
4
+
5
+
6
+
7
+ mount DateBook::Engine => '/date_book', as: 'date_book'
8
+ if Rails.env.development?
9
+ mount GraphiQL::Rails::Engine, at: "/graphiql", graphql_path: "/date_book/api"
10
+ end
11
+
12
+
13
+ devise_for :users
14
+
15
+ end
@@ -0,0 +1,22 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rails secret` to generate a secure secret key.
9
+
10
+ # Make sure the secrets in this file are kept private
11
+ # if you're sharing your code publicly.
12
+
13
+ development:
14
+ secret_key_base: 78be21acd2b18cb0497414742c7c525422b1a577d440feb2e9e7b54c7eb7acaddcca8c53a3756975f1a79f93ac31235339219d3fcb4998100be482aa453c935a
15
+
16
+ test:
17
+ secret_key_base: 005e11b247f2ba012ad0d7aab9cff4286a9943b4c0d7c143682ccce90cd12ae22b3fb525ce11111550325aab21d603819f6d2602e419d59eb88c2bdcffb021ca
18
+
19
+ # Do not keep production secrets in the repository,
20
+ # instead read values from the environment.
21
+ production:
22
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ %w[
4
+ .ruby-version
5
+ .rbenv-vars
6
+ tmp/restart.txt
7
+ tmp/caching-dev.txt
8
+ ].each { |path| Spring.watch(path) }
@@ -0,0 +1,7 @@
1
+ class CreateUsersTable < ActiveRecord::Migration[5.1]
2
+ def change
3
+ create_table :users do |t|
4
+ t.string :name
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,49 @@
1
+ class AddDeviseToUsers < ActiveRecord::Migration[5.1]
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, null: false
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
+ ## Confirmable
23
+ # t.string :confirmation_token
24
+ # t.datetime :confirmed_at
25
+ # t.datetime :confirmation_sent_at
26
+ # t.string :unconfirmed_email # Only if using reconfirmable
27
+
28
+ ## Lockable
29
+ # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
30
+ # t.string :unlock_token # Only if unlock strategy is :email or :both
31
+ # t.datetime :locked_at
32
+
33
+
34
+ # Uncomment below if timestamps were not included in your original model.
35
+ # t.timestamps null: false
36
+ end
37
+
38
+ add_index :users, :email, unique: true
39
+ add_index :users, :reset_password_token, unique: true
40
+ # add_index :users, :confirmation_token, unique: true
41
+ # add_index :users, :unlock_token, unique: true
42
+ end
43
+
44
+ def self.down
45
+ # By default, we don't want to make any assumption about how to roll back a migration when your
46
+ # model already existed. Please edit below which fields you would like to remove in this migration.
47
+ raise ActiveRecord::IrreversibleMigration
48
+ end
49
+ end
@@ -0,0 +1,19 @@
1
+ class RolifyCreateRoles < ActiveRecord::Migration[5.1]
2
+ def change
3
+ create_table(:roles) do |t|
4
+ t.string :name
5
+ t.references :resource, :polymorphic => true
6
+
7
+ t.timestamps
8
+ end
9
+
10
+ create_table(:users_roles, :id => false) do |t|
11
+ t.references :user
12
+ t.references :role
13
+ end
14
+
15
+ add_index(:roles, :name)
16
+ add_index(:roles, [ :name, :resource_type, :resource_id ])
17
+ add_index(:users_roles, [ :user_id, :role_id ])
18
+ end
19
+ end
@@ -0,0 +1,12 @@
1
+ # This migration comes from date_book (originally 20170807133845)
2
+ class CreateCalendars < ActiveRecord::Migration[5.1]
3
+ def change
4
+ create_table :calendars do |t|
5
+ t.string :name
6
+ t.string :slug
7
+ t.text :description
8
+ t.string :css_class
9
+ end
10
+ add_index :calendars, :slug, unique: true
11
+ end
12
+ end
@@ -0,0 +1,21 @@
1
+ # This migration comes from date_book (originally 20170807133846)
2
+ class CreateEvents < ActiveRecord::Migration[5.1]
3
+ def change
4
+ create_table :events do |t|
5
+ t.references :calendar
6
+
7
+ t.string :name
8
+ t.string :slug, unique: true
9
+ t.text :description
10
+ t.string :css_class
11
+
12
+ t.date :start_date
13
+ t.time :start_time
14
+
15
+ t.integer :duration
16
+ t.boolean :all_day
17
+
18
+ t.timestamps
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,26 @@
1
+ # This migration comes from date_book (originally 20170807133847)
2
+ class CreateSchedules < ActiveRecord::Migration[5.1]
3
+ def self.up
4
+ create_table :schedules do |t|
5
+ t.references :schedulable, polymorphic: true
6
+
7
+ t.date :date
8
+ t.time :time
9
+
10
+ t.string :rule
11
+ t.string :interval
12
+
13
+ t.text :day
14
+ t.text :day_of_week
15
+
16
+ t.datetime :until
17
+ t.integer :count
18
+
19
+ t.timestamps
20
+ end
21
+ end
22
+
23
+ def self.down
24
+ drop_table :schedules
25
+ end
26
+ end
@@ -0,0 +1,7 @@
1
+ # This migration comes from date_book (originally 20170807133848)
2
+ class AddFieldsToSchedule < ActiveRecord::Migration[5.1]
3
+ def change
4
+ add_column :schedules, :duration, :integer, default: 3600
5
+ add_column :schedules, :all_day, :boolean, default: false
6
+ end
7
+ end
@@ -0,0 +1,17 @@
1
+ # This migration comes from date_book (originally 20170807133849)
2
+ class CreateEventOccurrences < ActiveRecord::Migration[5.1]
3
+ def self.up
4
+ create_table :event_occurrences do |t|
5
+
6
+ t.references :schedulable, polymorphic: true
7
+ t.datetime :date
8
+
9
+ t.timestamps
10
+
11
+ end
12
+ end
13
+
14
+ def self.down
15
+ drop_table :event_occurrences
16
+ end
17
+ end
@@ -0,0 +1,6 @@
1
+ # This migration comes from date_book (originally 20170807133850)
2
+ class AddFieldsToEventOccurrences < ActiveRecord::Migration[5.1]
3
+ def change
4
+ add_column :event_occurrences, :end_date, :datetime
5
+ end
6
+ end
@@ -0,0 +1,101 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # Note that this schema.rb definition is the authoritative source for your
6
+ # database schema. If you need to create the application database on another
7
+ # system, you should be using db:schema:load, not running all the migrations
8
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
10
+ #
11
+ # It's strongly recommended that you check this file into your version control system.
12
+
13
+ ActiveRecord::Schema.define(version: 20170807134142) do
14
+
15
+ create_table "calendars", force: :cascade do |t|
16
+ t.string "name"
17
+ t.string "slug"
18
+ t.text "description"
19
+ t.string "css_class"
20
+ t.index ["slug"], name: "index_calendars_on_slug", unique: true
21
+ end
22
+
23
+ create_table "event_occurrences", force: :cascade do |t|
24
+ t.string "schedulable_type"
25
+ t.integer "schedulable_id"
26
+ t.datetime "date"
27
+ t.datetime "created_at", null: false
28
+ t.datetime "updated_at", null: false
29
+ t.datetime "end_date"
30
+ t.index ["schedulable_type", "schedulable_id"], name: "index_event_occurrences_on_schedulable_type_and_schedulable_id"
31
+ end
32
+
33
+ create_table "events", force: :cascade do |t|
34
+ t.integer "calendar_id"
35
+ t.string "name"
36
+ t.string "slug"
37
+ t.text "description"
38
+ t.string "css_class"
39
+ t.date "start_date"
40
+ t.time "start_time"
41
+ t.integer "duration"
42
+ t.boolean "all_day"
43
+ t.datetime "created_at", null: false
44
+ t.datetime "updated_at", null: false
45
+ t.index ["calendar_id"], name: "index_events_on_calendar_id"
46
+ end
47
+
48
+ create_table "roles", force: :cascade do |t|
49
+ t.string "name"
50
+ t.string "resource_type"
51
+ t.integer "resource_id"
52
+ t.datetime "created_at", null: false
53
+ t.datetime "updated_at", null: false
54
+ t.index ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id"
55
+ t.index ["name"], name: "index_roles_on_name"
56
+ t.index ["resource_type", "resource_id"], name: "index_roles_on_resource_type_and_resource_id"
57
+ end
58
+
59
+ create_table "schedules", force: :cascade do |t|
60
+ t.string "schedulable_type"
61
+ t.integer "schedulable_id"
62
+ t.date "date"
63
+ t.time "time"
64
+ t.string "rule"
65
+ t.string "interval"
66
+ t.text "day"
67
+ t.text "day_of_week"
68
+ t.datetime "until"
69
+ t.integer "count"
70
+ t.datetime "created_at", null: false
71
+ t.datetime "updated_at", null: false
72
+ t.integer "duration", default: 3600
73
+ t.boolean "all_day", default: false
74
+ t.index ["schedulable_type", "schedulable_id"], name: "index_schedules_on_schedulable_type_and_schedulable_id"
75
+ end
76
+
77
+ create_table "users", force: :cascade do |t|
78
+ t.string "name"
79
+ t.string "email", default: "", null: false
80
+ t.string "encrypted_password", default: "", null: false
81
+ t.string "reset_password_token"
82
+ t.datetime "reset_password_sent_at"
83
+ t.datetime "remember_created_at"
84
+ t.integer "sign_in_count", default: 0, null: false
85
+ t.datetime "current_sign_in_at"
86
+ t.datetime "last_sign_in_at"
87
+ t.string "current_sign_in_ip"
88
+ t.string "last_sign_in_ip"
89
+ t.index ["email"], name: "index_users_on_email", unique: true
90
+ t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
91
+ end
92
+
93
+ create_table "users_roles", id: false, force: :cascade do |t|
94
+ t.integer "user_id"
95
+ t.integer "role_id"
96
+ t.index ["role_id"], name: "index_users_roles_on_role_id"
97
+ t.index ["user_id", "role_id"], name: "index_users_roles_on_user_id_and_role_id"
98
+ t.index ["user_id"], name: "index_users_roles_on_user_id"
99
+ end
100
+
101
+ end
File without changes
@@ -0,0 +1,22 @@
1
+ after :users do
2
+ BasicBenchmark.new "Seeding #{Rails.env} Calendars" do
3
+ FactoryGirl.create(
4
+ :calendar,
5
+ name: 'Admin Calendar',
6
+ css_class: 'admin-calendar'
7
+ )
8
+ FactoryGirl.create(
9
+ :calendar,
10
+ name: 'Regular Calendar',
11
+ css_class: 'regular-calendar',
12
+ owner: User.find_by_name('Regular User')
13
+ )
14
+ FactoryGirl.create(
15
+ :calendar,
16
+ name: 'Other Calendar',
17
+ css_class: 'other-calendar',
18
+ owner: User.find_by_name('Other User')
19
+ )
20
+ end
21
+ end
22
+
@@ -0,0 +1,89 @@
1
+ after :users, :calendars do
2
+ BasicBenchmark.new "Seeding #{Rails.env} Events" do
3
+ FactoryGirl.create(
4
+ :event,
5
+ name: 'Monday',
6
+ css_class: 'weekday',
7
+ owner: User.find_by_name('Other User'),
8
+ calendar: Calendar.friendly.find('other-calendar'),
9
+ schedule_attributes: {
10
+ rule: 'weekly',
11
+ day: %w(monday),
12
+ time: '00:00',
13
+ duration: 1.day,
14
+ all_day: true
15
+ }
16
+ )
17
+
18
+ FactoryGirl.create(
19
+ :event,
20
+ name: 'The work week',
21
+ css_class: 'week',
22
+ schedule_attributes: {
23
+ rule: 'weekly',
24
+ day: %w(monday),
25
+ time: '00:00',
26
+ duration: 5.days,
27
+ all_day: true
28
+ }
29
+ )
30
+
31
+ FactoryGirl.create(
32
+ :event,
33
+ name: 'Breakfast',
34
+ schedule_attributes: {
35
+ rule: 'daily',
36
+ time: '8:00 AM',
37
+ duration: 1.hour
38
+ }
39
+ )
40
+
41
+ FactoryGirl.create(
42
+ :event,
43
+ name: 'Midnight Pilates',
44
+ schedule_attributes: {
45
+ rule: 'daily',
46
+ time: '11:30 PM',
47
+ duration: 1.hour
48
+ }
49
+ )
50
+
51
+ FactoryGirl.create(
52
+ :event,
53
+ name: "Yesterday's Event",
54
+ schedule_attributes: {
55
+ rule: 'singular',
56
+ date: 1.day.ago,
57
+ time: '5:30 PM',
58
+ duration: 1.hour
59
+ }
60
+ )
61
+
62
+ FactoryGirl.create(
63
+ :event,
64
+ name: "Tomorrow's Event",
65
+ schedule_attributes: {
66
+ rule: 'singular',
67
+ date: 1.day.from_now,
68
+ time: '6:30 PM',
69
+ duration: 1.hour
70
+ }
71
+ )
72
+
73
+ FactoryGirl.create(
74
+ :event,
75
+ name: 'Science Fiction Club',
76
+ owner: User.find_by_name('Regular User'),
77
+ calendar: Calendar.friendly.find('regular-calendar'),
78
+ schedule_attributes: {
79
+ rule: 'monthly',
80
+ day_of_week: { tuesday: [ '1' ] },
81
+ time: '5:00 PM',
82
+ interval: 1,
83
+ duration: 1.hour
84
+ }
85
+ )
86
+
87
+ end
88
+ end
89
+