date_book 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.idea/vcs.xml +6 -0
- data/.rspec +2 -0
- data/.rubocop.yml +23 -0
- data/.rubocop_todo.yml +7 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +3 -0
- data/Gemfile +94 -0
- data/Gemfile.lock +385 -0
- data/LICENSE.txt +20 -0
- data/README.md +64 -0
- data/Rakefile +30 -0
- data/VERSION +1 -0
- data/app/assets/images/date_book/.keep +0 -0
- data/app/assets/javascripts/date_book.js +21 -0
- data/app/assets/javascripts/date_book/calendar_events.js +57 -0
- data/app/assets/javascripts/date_book/event_form.js +31 -0
- data/app/assets/javascripts/date_book/popovers.js +3 -0
- data/app/assets/javascripts/date_book/wysiwyg.js +8 -0
- data/app/assets/stylesheets/date_book.css.scss +46 -0
- data/app/controllers/date_book/calendars_controller.rb +60 -0
- data/app/controllers/date_book/date_book_controller.rb +24 -0
- data/app/controllers/date_book/events_controller.rb +105 -0
- data/app/controllers/date_book/graphql_controller.rb +35 -0
- data/app/graphql/date_book_schema.rb +18 -0
- data/app/graphql/types/calendar_type.rb +14 -0
- data/app/graphql/types/date_time_type.rb +7 -0
- data/app/graphql/types/event_occurrence_type.rb +11 -0
- data/app/graphql/types/event_type.rb +19 -0
- data/app/graphql/types/mutation_type.rb +5 -0
- data/app/graphql/types/profile_type.rb +7 -0
- data/app/graphql/types/query_type.rb +57 -0
- data/app/helpers/date_book/application_helper.rb +35 -0
- data/app/helpers/date_book/calendar_helper.rb +4 -0
- data/app/helpers/date_book/events_helper.rb +42 -0
- data/app/jobs/date_book/application_job.rb +6 -0
- data/app/mailers/date_book/application_mailer.rb +9 -0
- data/app/views/date_book/application/_all_day_checkbox.html.haml +1 -0
- data/app/views/date_book/application/_date_range.html.haml +8 -0
- data/app/views/date_book/application/_wysiwyg.html.haml +65 -0
- data/app/views/date_book/calendars/_form.html.haml +6 -0
- data/app/views/date_book/calendars/edit.html.haml +5 -0
- data/app/views/date_book/calendars/index.html.haml +28 -0
- data/app/views/date_book/calendars/new.html.haml +5 -0
- data/app/views/date_book/calendars/show.html.haml +28 -0
- data/app/views/date_book/events/_event.json.jbuilder +12 -0
- data/app/views/date_book/events/_form.html.haml +16 -0
- data/app/views/date_book/events/_occurrence_dates.html.haml +11 -0
- data/app/views/date_book/events/edit.html.haml +5 -0
- data/app/views/date_book/events/fields/_date.html.haml +1 -0
- data/app/views/date_book/events/fields/_day.html.haml +1 -0
- data/app/views/date_book/events/fields/_day_of_week.html.haml +19 -0
- data/app/views/date_book/events/fields/_duration.html.haml +6 -0
- data/app/views/date_book/events/fields/_interval.html.haml +1 -0
- data/app/views/date_book/events/fields/_time.html.haml +1 -0
- data/app/views/date_book/events/index.html.haml +16 -0
- data/app/views/date_book/events/new.html.haml +5 -0
- data/app/views/date_book/events/popover.html.haml +7 -0
- data/app/views/date_book/events/rules/_daily.html.haml +4 -0
- data/app/views/date_book/events/rules/_monthly.html.haml +5 -0
- data/app/views/date_book/events/rules/_singular.html.haml +4 -0
- data/app/views/date_book/events/rules/_weekly.html.haml +5 -0
- data/app/views/date_book/events/show.html.haml +16 -0
- data/app/views/layouts/_date_book_scripts.html.haml +4 -0
- data/app/views/layouts/blank.html.haml +1 -0
- data/bin/rails +15 -0
- data/config/locales/en.yml +44 -0
- data/config/routes.rb +12 -0
- data/date_book.gemspec +337 -0
- data/db/migrate/20170807133845_create_calendars.rb +11 -0
- data/db/migrate/20170807133846_create_events.rb +20 -0
- data/db/migrate/20170807133847_create_schedules.rb +25 -0
- data/db/migrate/20170807133848_add_fields_to_schedule.rb +6 -0
- data/db/migrate/20170807133849_create_event_occurrences.rb +16 -0
- data/db/migrate/20170807133850_add_fields_to_event_occurrences.rb +5 -0
- data/lib/date_book.rb +40 -0
- data/lib/date_book/concerns/ability.rb +27 -0
- data/lib/date_book/concerns/acts_as_calendar.rb +29 -0
- data/lib/date_book/concerns/acts_as_event.rb +66 -0
- data/lib/date_book/concerns/acts_as_event_occurrence.rb +67 -0
- data/lib/date_book/concerns/acts_as_ownable.rb +29 -0
- data/lib/date_book/concerns/acts_as_owner.rb +18 -0
- data/lib/date_book/concerns/acts_as_schedule.rb +44 -0
- data/lib/date_book/configuration.rb +43 -0
- data/lib/date_book/engine.rb +40 -0
- data/lib/date_book/localization.rb +32 -0
- data/lib/date_book/version.rb +8 -0
- data/lib/generators/date_book/install/install_generator.rb +110 -0
- data/lib/generators/date_book/install/templates/app/models/ability.rb +16 -0
- data/lib/generators/date_book/install/templates/app/models/calendar.rb +3 -0
- data/lib/generators/date_book/install/templates/app/models/event.rb +3 -0
- data/lib/generators/date_book/install/templates/app/models/event_occurrence.rb +3 -0
- data/lib/generators/date_book/install/templates/app/models/schedule.rb +3 -0
- data/lib/generators/date_book/install/templates/config/initializers/date_book.rb +5 -0
- data/lib/generators/date_book/utils.rb +25 -0
- data/lib/tasks/date_book_tasks.rake +5 -0
- data/spec/abilities/calendar_spec.rb +39 -0
- data/spec/abilities/event_spec.rb +44 -0
- data/spec/controllers/date_book/calendars_controller_spec.rb +259 -0
- data/spec/controllers/date_book/events_controller_spec.rb +283 -0
- data/spec/dummy/Rakefile +9 -0
- data/spec/dummy/app/assets/config/manifest.js +5 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css.scss +4 -0
- data/spec/dummy/app/assets/stylesheets/bootstrap-everything.scss +54 -0
- data/spec/dummy/app/controllers/application_controller.rb +21 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +4 -0
- data/spec/dummy/app/mailers/application_mailer.rb +6 -0
- data/spec/dummy/app/models/ability.rb +16 -0
- data/spec/dummy/app/models/application_record.rb +5 -0
- data/spec/dummy/app/models/calendar.rb +3 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/models/event.rb +3 -0
- data/spec/dummy/app/models/event_occurrence.rb +3 -0
- data/spec/dummy/app/models/role.rb +13 -0
- data/spec/dummy/app/models/schedule.rb +3 -0
- data/spec/dummy/app/models/user.rb +9 -0
- data/spec/dummy/app/views/application/403.html.haml +9 -0
- data/spec/dummy/app/views/application/404.html.haml +9 -0
- data/spec/dummy/app/views/layouts/application.html.haml +43 -0
- data/spec/dummy/app/views/pages/index.html.haml +1 -0
- data/spec/dummy/bin/bundle +5 -0
- data/spec/dummy/bin/rails +6 -0
- data/spec/dummy/bin/rake +6 -0
- data/spec/dummy/bin/setup +36 -0
- data/spec/dummy/bin/update +31 -0
- data/spec/dummy/config.ru +7 -0
- data/spec/dummy/config/application.rb +38 -0
- data/spec/dummy/config/boot.rb +7 -0
- data/spec/dummy/config/cable.yml +9 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +7 -0
- data/spec/dummy/config/environments/development.rb +60 -0
- data/spec/dummy/config/environments/test.rb +45 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +7 -0
- data/spec/dummy/config/initializers/assets.rb +14 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +10 -0
- data/spec/dummy/config/initializers/bootstrap_leather.rb +9 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +7 -0
- data/spec/dummy/config/initializers/date_book.rb +5 -0
- data/spec/dummy/config/initializers/devise.rb +277 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +6 -0
- data/spec/dummy/config/initializers/high_voltage.rb +3 -0
- data/spec/dummy/config/initializers/inflections.rb +17 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/new_framework_defaults.rb +29 -0
- data/spec/dummy/config/initializers/rolify.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +5 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +17 -0
- data/spec/dummy/config/locales/devise.en.yml +64 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/puma.rb +49 -0
- data/spec/dummy/config/routes.rb +15 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/config/spring.rb +8 -0
- data/spec/dummy/db/migrate/20170728171103_create_users_table.rb +7 -0
- data/spec/dummy/db/migrate/20170807134122_add_devise_to_users.rb +49 -0
- data/spec/dummy/db/migrate/20170807134128_rolify_create_roles.rb +19 -0
- data/spec/dummy/db/migrate/20170807134137_create_calendars.date_book.rb +12 -0
- data/spec/dummy/db/migrate/20170807134138_create_events.date_book.rb +21 -0
- data/spec/dummy/db/migrate/20170807134139_create_schedules.date_book.rb +26 -0
- data/spec/dummy/db/migrate/20170807134140_add_fields_to_schedule.date_book.rb +7 -0
- data/spec/dummy/db/migrate/20170807134141_create_event_occurrences.date_book.rb +17 -0
- data/spec/dummy/db/migrate/20170807134142_add_fields_to_event_occurrences.date_book.rb +6 -0
- data/spec/dummy/db/schema.rb +101 -0
- data/spec/dummy/db/seeds.rb +0 -0
- data/spec/dummy/db/seeds/calendars.seeds.rb +22 -0
- data/spec/dummy/db/seeds/events.seeds.rb +89 -0
- data/spec/dummy/db/seeds/users.seeds.rb +16 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/lib/basic_benchmark.rb +9 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/factories/calendars.rb +11 -0
- data/spec/factories/events.rb +12 -0
- data/spec/factories/roles.rb +5 -0
- data/spec/factories/users.rb +9 -0
- data/spec/features/calendars_spec.rb +185 -0
- data/spec/features/events_spec.rb +201 -0
- data/spec/helpers/date_book/calendar_helper_spec.rb +17 -0
- data/spec/helpers/date_book/events_helper_spec.rb +17 -0
- data/spec/models/calendar_spec.rb +26 -0
- data/spec/models/event_spec.rb +67 -0
- data/spec/models/role_spec.rb +5 -0
- data/spec/rails_helper.rb +116 -0
- data/spec/requests/date_book/events_spec.rb +56 -0
- data/spec/routing/date_book/calendars_routing_spec.rb +49 -0
- data/spec/routing/date_book/events_routing_spec.rb +54 -0
- data/spec/spec_helper.rb +102 -0
- data/spec/support/controller_behaviors.rb +101 -0
- data/spec/support/controller_macros.rb +25 -0
- data/spec/support/factory_girl.rb +3 -0
- data/spec/support/feature_behaviors.rb +150 -0
- data/spec/support/loaded_site.rb +5 -0
- data/spec/support/loaded_site/calendars.rb +5 -0
- data/spec/support/loaded_site/events.rb +6 -0
- data/spec/support/loaded_site/users.rb +5 -0
- data/spec/support/request_behaviors.rb +89 -0
- data/spec/support/shared_connection.rb +14 -0
- data/spec/support/utilities.rb +53 -0
- metadata +817 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
# Specs in this file have access to a helper object that includes
|
4
|
+
# the CalendarHelper. For example:
|
5
|
+
#
|
6
|
+
# describe CalendarHelper do
|
7
|
+
# describe "string concat" do
|
8
|
+
# it "concats two strings with spaces" do
|
9
|
+
# expect(helper.concat_strings("this","that")).to eq("this that")
|
10
|
+
# end
|
11
|
+
# end
|
12
|
+
# end
|
13
|
+
module DateBook
|
14
|
+
RSpec.describe CalendarHelper, folder: :helpers do
|
15
|
+
pending "add some examples to (or delete) #{__FILE__}"
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
# Specs in this file have access to a helper object that includes
|
4
|
+
# the EventsHelper. For example:
|
5
|
+
#
|
6
|
+
# describe EventsHelper do
|
7
|
+
# describe "string concat" do
|
8
|
+
# it "concats two strings with spaces" do
|
9
|
+
# expect(helper.concat_strings("this","that")).to eq("this that")
|
10
|
+
# end
|
11
|
+
# end
|
12
|
+
# end
|
13
|
+
module DateBook
|
14
|
+
RSpec.describe EventsHelper, folder: :helpers do
|
15
|
+
pending "add some examples to (or delete) #{__FILE__}"
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe Calendar, folder: :models do
|
4
|
+
include_context 'loaded site'
|
5
|
+
|
6
|
+
describe 'Model' do
|
7
|
+
# Rolify Gem
|
8
|
+
it { should have_many(:roles) }
|
9
|
+
|
10
|
+
# Validations
|
11
|
+
it { should validate_presence_of(:name) }
|
12
|
+
it { should validate_presence_of(:slug) }
|
13
|
+
|
14
|
+
# Relationships
|
15
|
+
it { should have_many(:events) }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'Class' do
|
19
|
+
subject { Calendar }
|
20
|
+
# FriendlyId Gem
|
21
|
+
it { should respond_to(:friendly) }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'Scopes and Methods' do
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe Event, folder: :models do
|
4
|
+
include_context 'loaded site'
|
5
|
+
|
6
|
+
describe 'Model' do
|
7
|
+
# Rolify Gem
|
8
|
+
it { should have_many(:roles) }
|
9
|
+
|
10
|
+
# Schedulable Gem
|
11
|
+
it { should have_one(:schedule) }
|
12
|
+
|
13
|
+
# Validations
|
14
|
+
it { should validate_presence_of(:name) }
|
15
|
+
it { should validate_presence_of(:slug) }
|
16
|
+
it { should validate_presence_of(:calendar) }
|
17
|
+
|
18
|
+
# Relationships
|
19
|
+
it { should belong_to(:calendar) }
|
20
|
+
|
21
|
+
# Nested Attributes
|
22
|
+
it { should accept_nested_attributes_for :schedule }
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'Class' do
|
26
|
+
subject { Event }
|
27
|
+
# FriendlyId Gem
|
28
|
+
it { should respond_to(:friendly) }
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'Scopes and Methods' do
|
32
|
+
describe '#ending_after' do
|
33
|
+
subject { Event.ending_after(Time.zone.now) }
|
34
|
+
it { should include tomorrows_event }
|
35
|
+
it { should_not include yesterdays_event }
|
36
|
+
end
|
37
|
+
describe '#starting_before' do
|
38
|
+
subject { Event.starting_before(Time.zone.now) }
|
39
|
+
it { should include yesterdays_event }
|
40
|
+
it { should_not include tomorrows_event }
|
41
|
+
end
|
42
|
+
describe '#to_list' do
|
43
|
+
subject { Event.all.to_list }
|
44
|
+
its(:first) { should be_a ::Hash }
|
45
|
+
it { should have_at_least(3).items }
|
46
|
+
end
|
47
|
+
describe '.schedule' do
|
48
|
+
describe 'with a new record' do
|
49
|
+
subject { Event.new }
|
50
|
+
its(:schedule) { should be_a_new Schedule }
|
51
|
+
end
|
52
|
+
describe 'with a saved record' do
|
53
|
+
subject { monday_event }
|
54
|
+
its(:schedule) { should be_a Schedule }
|
55
|
+
its(:schedule) { should_not be_a_new Schedule }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
describe '.next_occurrence' do
|
59
|
+
subject { tomorrows_event.next_occurrence }
|
60
|
+
its(:start_date) { should be > Time.now }
|
61
|
+
end
|
62
|
+
describe '.previous_occurrence' do
|
63
|
+
subject { yesterdays_event.previous_occurrence }
|
64
|
+
its(:end_date) { should be < Time.now }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'coveralls'
|
4
|
+
Coveralls.wear!
|
5
|
+
|
6
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
7
|
+
ENV['RAILS_ENV'] ||= 'test'
|
8
|
+
require File.expand_path('../dummy/config/environment', __FILE__)
|
9
|
+
# Prevent database truncation if the environment is production
|
10
|
+
abort('Rails is running in production mode!') if Rails.env.production?
|
11
|
+
require 'spec_helper'
|
12
|
+
require 'rspec/rails'
|
13
|
+
# Add additional requires below this line. Rails is not loaded until this point!
|
14
|
+
require 'shoulda/matchers'
|
15
|
+
require 'factory_girl_rails'
|
16
|
+
require 'capybara/rspec'
|
17
|
+
require 'capybara/poltergeist'
|
18
|
+
require 'database_cleaner'
|
19
|
+
require 'rake'
|
20
|
+
|
21
|
+
# Requires supporting ruby files with custom matchers and macros, etc, in
|
22
|
+
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
23
|
+
# run as spec files by default. This means that files in spec/support that end
|
24
|
+
# in _spec.rb will both be required and run as specs, causing the specs to be
|
25
|
+
# run twice. It is recommended that you do not name files matching this glob to
|
26
|
+
# end with _spec.rb. You can configure this pattern with the --pattern
|
27
|
+
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
|
28
|
+
#
|
29
|
+
# The following line is provided for convenience purposes. It has the downside
|
30
|
+
# of increasing the boot-up time by auto-requiring all files in the support
|
31
|
+
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
32
|
+
# require only the support files necessary.
|
33
|
+
Dir[DateBook::Engine.root.join('spec/support/*.rb')]
|
34
|
+
.each { |f| require f }
|
35
|
+
Dir[DateBook::Engine.root.join('spec/support/**/*.rb')]
|
36
|
+
.each { |f| require f }
|
37
|
+
|
38
|
+
# Checks for pending migration and applies them before tests are run.
|
39
|
+
# If you are not using ActiveRecord, you can remove this line.
|
40
|
+
ActiveRecord::Migrator.migrations_paths = 'spec/dummy/db/migrate'
|
41
|
+
ActiveRecord::Migration.maintain_test_schema!
|
42
|
+
|
43
|
+
Capybara.javascript_driver = :webkit
|
44
|
+
|
45
|
+
Shoulda::Matchers.configure do |config|
|
46
|
+
config.integrate do |with|
|
47
|
+
with.test_framework :rspec
|
48
|
+
with.library :rails
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
RSpec.configure do |config|
|
53
|
+
config.use_transactional_fixtures = false
|
54
|
+
config.before(:suite) do
|
55
|
+
DatabaseCleaner.strategy = :transaction
|
56
|
+
DatabaseCleaner.clean_with(:truncation)
|
57
|
+
Dummy::Application.load_tasks
|
58
|
+
Rake::Task['db:seed'].invoke # loading seeds
|
59
|
+
end
|
60
|
+
|
61
|
+
config.around(:each) do |example|
|
62
|
+
DatabaseCleaner.cleaning do
|
63
|
+
example.run
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
config.include Rails.application.routes.url_helpers
|
68
|
+
|
69
|
+
config.include RSpecHtmlMatchers, folder: :helper
|
70
|
+
|
71
|
+
# In order to tell Rspec how to use Devise, as per
|
72
|
+
# https://github.com/plataformatec/devise/wiki/How-To:-Test-controllers-with-Rails-3-and-4-%28and-RSpec%29
|
73
|
+
config.include Devise::Test::ControllerHelpers, type: :controller
|
74
|
+
config.extend ControllerMacros, type: :controller
|
75
|
+
config.include Warden::Test::Helpers
|
76
|
+
|
77
|
+
config.before :suite do
|
78
|
+
Warden.test_mode!
|
79
|
+
end
|
80
|
+
|
81
|
+
# RSpec Rails can automatically mix in different behaviours to your tests
|
82
|
+
# based on their file location, for example enabling you to call `get` and
|
83
|
+
# `post` in specs under `spec/controllers`.
|
84
|
+
#
|
85
|
+
# You can disable this behaviour by removing the line below, and instead
|
86
|
+
# explicitly tag your specs with their type, e.g.:
|
87
|
+
#
|
88
|
+
# RSpec.describe UsersController, :type => :controller do
|
89
|
+
# # ...
|
90
|
+
# end
|
91
|
+
#
|
92
|
+
# The different available types are documented in the features, such as in
|
93
|
+
# https://relishapp.com/rspec/rspec-rails/docs
|
94
|
+
config.infer_spec_type_from_file_location!
|
95
|
+
|
96
|
+
# Filter lines from Rails gems in backtraces.
|
97
|
+
config.filter_rails_from_backtrace!
|
98
|
+
# arbitrary gems may also be filtered via:
|
99
|
+
# config.filter_gems_from_backtrace("gem name")
|
100
|
+
|
101
|
+
config.register_ordering(:global) do |items|
|
102
|
+
items.sort_by do |item|
|
103
|
+
case item.metadata[:folder]
|
104
|
+
when :models then 10
|
105
|
+
when :abilities then 20
|
106
|
+
when :routing then 30
|
107
|
+
when :controllers then 40
|
108
|
+
when :helpers then 50
|
109
|
+
when :features then 60
|
110
|
+
when :requests then 70
|
111
|
+
when :mailers then 80
|
112
|
+
else 5
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'Events Requests', folder: :requests do
|
4
|
+
include_context 'loaded site'
|
5
|
+
|
6
|
+
let(:valid_attributes) do
|
7
|
+
{ event: { name: 'Test Event', schedule_attributes: { date: Date.today, time: Time.zone.now } } }
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:invalid_attributes) do
|
11
|
+
{ event: { name: nil } }
|
12
|
+
end
|
13
|
+
|
14
|
+
pending 'Browsing Events' do
|
15
|
+
describe 'at /date_book/events' do
|
16
|
+
describe 'without a query' do
|
17
|
+
before do
|
18
|
+
get '/date_book/events.json'
|
19
|
+
end
|
20
|
+
it_behaves_like(
|
21
|
+
'a json object listing a collection of items',
|
22
|
+
Event,
|
23
|
+
minimum: 2
|
24
|
+
)
|
25
|
+
end
|
26
|
+
describe 'with a query' do
|
27
|
+
before do
|
28
|
+
get(
|
29
|
+
'/date_book/events.json',
|
30
|
+
params: {
|
31
|
+
start: Date.today
|
32
|
+
}
|
33
|
+
)
|
34
|
+
end
|
35
|
+
it_behaves_like(
|
36
|
+
'a json object listing a collection of items',
|
37
|
+
Event,
|
38
|
+
minimum: 1
|
39
|
+
)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
pending 'Showing Events' do
|
45
|
+
describe 'at /date_book/events/monday' do
|
46
|
+
before do
|
47
|
+
get '/date_book/events/monday.json'
|
48
|
+
end
|
49
|
+
it_behaves_like(
|
50
|
+
'a json object showing an item',
|
51
|
+
Event,
|
52
|
+
'Monday'
|
53
|
+
)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
module DateBook
|
4
|
+
RSpec.describe CalendarsController, folder: :routing do
|
5
|
+
routes { DateBook::Engine.routes }
|
6
|
+
|
7
|
+
describe 'Routing' do
|
8
|
+
it 'routes to #index' do
|
9
|
+
expect(get: '/calendars').
|
10
|
+
to route_to(controller: 'date_book/calendars', action: 'index')
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'routes to #new' do
|
14
|
+
expect(get: '/calendars/new')
|
15
|
+
.to route_to('date_book/calendars#new')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'routes to #show' do
|
19
|
+
expect(get: '/calendars/slug')
|
20
|
+
.to route_to('date_book/calendars#show', id: 'slug')
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'routes to #edit' do
|
24
|
+
expect(get: '/calendars/slug/edit')
|
25
|
+
.to route_to('date_book/calendars#edit', id: 'slug')
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'routes to #create' do
|
29
|
+
expect(post: '/calendars')
|
30
|
+
.to route_to('date_book/calendars#create')
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'routes to #update via PUT' do
|
34
|
+
expect(put: '/calendars/slug')
|
35
|
+
.to route_to('date_book/calendars#update', id: 'slug')
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'routes to #update via PATCH' do
|
39
|
+
expect(patch: '/calendars/slug')
|
40
|
+
.to route_to('date_book/calendars#update', id: 'slug')
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'routes to #destroy' do
|
44
|
+
expect(delete: '/calendars/slug')
|
45
|
+
.to route_to('date_book/calendars#destroy', id: 'slug')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
module DateBook
|
4
|
+
RSpec.describe EventsController, folder: :routing do
|
5
|
+
routes { DateBook::Engine.routes }
|
6
|
+
|
7
|
+
describe 'Routing' do
|
8
|
+
it 'routes to #index' do
|
9
|
+
expect(get: '/calendars/calendar-slug/events').
|
10
|
+
to route_to(controller: 'date_book/events', action: 'index', calendar_id: 'calendar-slug')
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'routes to #new' do
|
14
|
+
expect(get: '/calendars/calendar-slug/events/new')
|
15
|
+
.to route_to('date_book/events#new', calendar_id: 'calendar-slug')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'routes to #show' do
|
19
|
+
expect(get: '/calendars/calendar-slug/events/slug')
|
20
|
+
.to route_to('date_book/events#show', id: 'slug', calendar_id: 'calendar-slug')
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'routes to #popover' do
|
24
|
+
expect(get: '/calendars/calendar-slug/events/slug/popover')
|
25
|
+
.to route_to('date_book/events#popover', id: 'slug', calendar_id: 'calendar-slug')
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'routes to #edit' do
|
29
|
+
expect(get: '/calendars/calendar-slug/events/slug/edit')
|
30
|
+
.to route_to('date_book/events#edit', id: 'slug', calendar_id: 'calendar-slug')
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'routes to #create' do
|
34
|
+
expect(post: '/calendars/calendar-slug/events')
|
35
|
+
.to route_to('date_book/events#create', calendar_id: 'calendar-slug')
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'routes to #update via PUT' do
|
39
|
+
expect(put: '/calendars/calendar-slug/events/slug')
|
40
|
+
.to route_to('date_book/events#update', id: 'slug', calendar_id: 'calendar-slug')
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'routes to #update via PATCH' do
|
44
|
+
expect(patch: '/calendars/calendar-slug/events/slug')
|
45
|
+
.to route_to('date_book/events#update', id: 'slug', calendar_id: 'calendar-slug')
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'routes to #destroy' do
|
49
|
+
expect(delete: '/calendars/calendar-slug/events/slug')
|
50
|
+
.to route_to('date_book/events#destroy', id: 'slug', calendar_id: 'calendar-slug')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This file was generated by the `rails generate rspec:install` command.
|
4
|
+
# Conventionally, all specs live under a `spec` directory, which RSpec adds to
|
5
|
+
# the `$LOAD_PATH`.
|
6
|
+
#
|
7
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
8
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
9
|
+
# files.
|
10
|
+
#
|
11
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
12
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
13
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
14
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
15
|
+
# a separate helper file that requires the additional dependencies and performs
|
16
|
+
# the additional setup, and require it from the spec files that actually need
|
17
|
+
# it.
|
18
|
+
#
|
19
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
20
|
+
# users commonly want.
|
21
|
+
#
|
22
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
23
|
+
RSpec.configure do |config|
|
24
|
+
# rspec-expectations config goes here. You can use an alternate
|
25
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
26
|
+
# assertions if you prefer.
|
27
|
+
config.expect_with :rspec do |expectations|
|
28
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
29
|
+
# and `failure_message` of custom matchers include text for helper methods
|
30
|
+
# defined using `chain`, e.g.:
|
31
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
32
|
+
# # => "be bigger than 2 and smaller than 4"
|
33
|
+
# ...rather than:
|
34
|
+
# # => "be bigger than 2"
|
35
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
36
|
+
end
|
37
|
+
|
38
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
39
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
40
|
+
config.mock_with :rspec do |mocks|
|
41
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
42
|
+
# a real object. This is generally recommended, and will default to
|
43
|
+
# `true` in RSpec 4.
|
44
|
+
mocks.verify_partial_doubles = true
|
45
|
+
end
|
46
|
+
|
47
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
48
|
+
# have no way to turn it off -- the option exists only for backwards
|
49
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
50
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
51
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
52
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
53
|
+
|
54
|
+
# The settings below are suggested to provide a good initial experience
|
55
|
+
# with RSpec, but feel free to customize to your heart's content.
|
56
|
+
#
|
57
|
+
# # This allows you to limit a spec run to individual examples or groups
|
58
|
+
# # you care about by tagging them with `:focus` metadata. When nothing
|
59
|
+
# # is tagged with `:focus`, all examples get run. RSpec also provides
|
60
|
+
# # aliases for `it`, `describe`, and `context` that include `:focus`
|
61
|
+
# # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
62
|
+
# config.filter_run_when_matching :focus
|
63
|
+
#
|
64
|
+
# # Allows RSpec to persist some state between runs in order to support
|
65
|
+
# # the `--only-failures` and `--next-failure` CLI options. We recommend
|
66
|
+
# # you configure your source control system to ignore this file.
|
67
|
+
# config.example_status_persistence_file_path = "spec/examples.txt"
|
68
|
+
#
|
69
|
+
# # Limits the available syntax to the non-monkey patched syntax that is
|
70
|
+
# # recommended. For more details, see:
|
71
|
+
# # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
72
|
+
# # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
73
|
+
# # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
74
|
+
# config.disable_monkey_patching!
|
75
|
+
#
|
76
|
+
# # Many RSpec users commonly either run the entire suite or an individual
|
77
|
+
# # file, and it's useful to allow more verbose output when running an
|
78
|
+
# # individual spec file.
|
79
|
+
# if config.files_to_run.one?
|
80
|
+
# # Use the documentation formatter for detailed output,
|
81
|
+
# # unless a formatter has already been configured
|
82
|
+
# # (e.g. via a command-line flag).
|
83
|
+
# config.default_formatter = 'doc'
|
84
|
+
# end
|
85
|
+
#
|
86
|
+
# # Print the 10 slowest examples and example groups at the
|
87
|
+
# # end of the spec run, to help surface which specs are running
|
88
|
+
# # particularly slow.
|
89
|
+
# config.profile_examples = 10
|
90
|
+
#
|
91
|
+
# # Run specs in random order to surface order dependencies. If you find an
|
92
|
+
# # order dependency and want to debug it, you can fix the order by providing
|
93
|
+
# # the seed, which is printed after each run.
|
94
|
+
# # --seed 1234
|
95
|
+
# config.order = :random
|
96
|
+
#
|
97
|
+
# # Seed global randomization in this process using the `--seed` CLI option.
|
98
|
+
# # Setting this allows you to use `--seed` to deterministically reproduce
|
99
|
+
# # test failures related to randomization by passing the same `--seed` value
|
100
|
+
# # as the one that triggered the failure.
|
101
|
+
# Kernel.srand config.seed
|
102
|
+
end
|