date_book 0.0.6 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +9 -1
  3. data/.rubocop_todo.yml +2 -1
  4. data/.travis.yml +3 -0
  5. data/Gemfile +16 -4
  6. data/Gemfile.lock +14 -2
  7. data/VERSION +1 -1
  8. data/app/assets/javascripts/date_book/calendar_events.js +3 -3
  9. data/app/assets/stylesheets/date_book.css.scss +31 -2
  10. data/app/controllers/date_book/calendars_controller.rb +30 -19
  11. data/app/controllers/date_book/date_book_controller.rb +1 -1
  12. data/app/controllers/date_book/events_controller.rb +60 -62
  13. data/app/controllers/date_book/graphql_controller.rb +10 -11
  14. data/app/graphql/date_book_schema.rb +4 -4
  15. data/app/graphql/types/calendar_type.rb +4 -2
  16. data/app/graphql/types/date_time_type.rb +9 -5
  17. data/app/graphql/types/event_occurrence_type.rb +4 -2
  18. data/app/graphql/types/event_type.rb +4 -2
  19. data/app/graphql/types/mutation_type.rb +3 -1
  20. data/app/graphql/types/query_type.rb +12 -26
  21. data/app/helpers/date_book/application_helper.rb +4 -7
  22. data/app/helpers/date_book/events_helper.rb +43 -23
  23. data/app/views/date_book/application/_date_range.html.haml +3 -3
  24. data/app/views/date_book/calendars/index.html.haml +19 -3
  25. data/app/views/date_book/calendars/show.html.haml +29 -4
  26. data/app/views/date_book/events/_event.json.jbuilder +3 -1
  27. data/app/views/date_book/events/_form.html.haml +4 -4
  28. data/app/views/date_book/events/_occurrence_dates.html.haml +3 -3
  29. data/app/views/date_book/events/fields/_date.html.haml +1 -1
  30. data/app/views/date_book/events/fields/_day.html.haml +1 -1
  31. data/app/views/date_book/events/fields/_day_of_week.html.haml +3 -3
  32. data/app/views/date_book/events/fields/_duration.html.haml +3 -3
  33. data/app/views/date_book/events/fields/_interval.html.haml +1 -1
  34. data/app/views/date_book/events/fields/_time.html.haml +1 -1
  35. data/app/views/date_book/events/index.html.haml +1 -1
  36. data/app/views/date_book/events/rules/_daily.html.haml +3 -3
  37. data/app/views/date_book/events/rules/_monthly.html.haml +4 -4
  38. data/app/views/date_book/events/rules/_singular.html.haml +3 -3
  39. data/app/views/date_book/events/rules/_weekly.html.haml +4 -4
  40. data/app/views/date_book/events/show.html.haml +1 -1
  41. data/app/views/layouts/_date_book_scripts.html.haml +2 -4
  42. data/config/locales/en.yml +2 -0
  43. data/config/routes.rb +1 -1
  44. data/date_book.gemspec +25 -22
  45. data/db/migrate/20170807133845_create_calendars.rb +3 -0
  46. data/db/migrate/20170807133846_create_events.rb +3 -0
  47. data/db/migrate/20170807133847_create_schedules.rb +9 -6
  48. data/db/migrate/20170807133848_add_fields_to_schedule.rb +3 -0
  49. data/db/migrate/20170807133849_create_event_occurrences.rb +4 -3
  50. data/db/migrate/20170807133850_add_fields_to_event_occurrences.rb +3 -0
  51. data/lib/date_book.rb +11 -2
  52. data/lib/date_book/concerns/ability.rb +9 -12
  53. data/lib/date_book/concerns/acts_as_calendar.rb +5 -6
  54. data/lib/date_book/concerns/acts_as_event.rb +30 -9
  55. data/lib/date_book/concerns/acts_as_event_occurrence.rb +21 -9
  56. data/lib/date_book/concerns/acts_as_ownable.rb +9 -3
  57. data/lib/date_book/concerns/acts_as_owner.rb +5 -6
  58. data/lib/date_book/concerns/acts_as_schedule.rb +14 -7
  59. data/lib/date_book/configuration.rb +14 -11
  60. data/lib/date_book/engine.rb +7 -5
  61. data/lib/date_book/version.rb +2 -0
  62. data/lib/generators/date_book/install/install_generator.rb +27 -29
  63. data/lib/generators/date_book/install/templates/app/models/calendar.rb +4 -1
  64. data/lib/generators/date_book/install/templates/app/models/event.rb +4 -1
  65. data/lib/generators/date_book/install/templates/app/models/event_occurrence.rb +4 -1
  66. data/lib/generators/date_book/install/templates/app/models/schedule.rb +4 -1
  67. data/spec/abilities/event_spec.rb +1 -1
  68. data/spec/controllers/date_book/calendars_controller_spec.rb +48 -20
  69. data/spec/controllers/date_book/events_controller_spec.rb +145 -39
  70. data/spec/dummy/app/models/calendar.rb +3 -1
  71. data/spec/dummy/app/models/event.rb +3 -1
  72. data/spec/dummy/app/models/event_occurrence.rb +3 -1
  73. data/spec/dummy/app/models/role.rb +7 -5
  74. data/spec/dummy/app/models/schedule.rb +3 -1
  75. data/spec/dummy/app/models/user.rb +3 -3
  76. data/spec/dummy/config/initializers/devise.rb +61 -40
  77. data/spec/dummy/config/initializers/high_voltage.rb +2 -0
  78. data/spec/dummy/config/initializers/rolify.rb +5 -2
  79. data/spec/dummy/config/routes.rb +6 -9
  80. data/spec/dummy/db/development.sqlite3 +0 -0
  81. data/spec/dummy/db/migrate/20170728171103_create_users_table.rb +2 -0
  82. data/spec/dummy/db/migrate/20170807134122_add_devise_to_users.rb +4 -3
  83. data/spec/dummy/db/migrate/20170807134128_rolify_create_roles.rb +6 -4
  84. data/spec/dummy/db/migrate/{20170808150915_create_calendars.date_book.rb → 20170808200808_create_calendars.date_book.rb} +3 -0
  85. data/spec/dummy/db/migrate/{20170808150916_create_events.date_book.rb → 20170808200809_create_events.date_book.rb} +3 -0
  86. data/spec/dummy/db/migrate/{20170808150917_create_schedules.date_book.rb → 20170808200810_create_schedules.date_book.rb} +9 -6
  87. data/spec/dummy/db/migrate/{20170808150918_add_fields_to_schedule.date_book.rb → 20170808200811_add_fields_to_schedule.date_book.rb} +3 -0
  88. data/spec/dummy/db/migrate/{20170808150919_create_event_occurrences.date_book.rb → 20170808200812_create_event_occurrences.date_book.rb} +4 -3
  89. data/spec/dummy/db/migrate/{20170808150920_add_fields_to_event_occurrences.date_book.rb → 20170808200813_add_fields_to_event_occurrences.date_book.rb} +3 -0
  90. data/spec/dummy/db/schema.rb +1 -1
  91. data/spec/dummy/db/seeds/calendars.seeds.rb +2 -1
  92. data/spec/dummy/db/seeds/events.seeds.rb +5 -5
  93. data/spec/dummy/db/seeds/users.seeds.rb +3 -1
  94. data/spec/dummy/db/test.sqlite3 +0 -0
  95. data/spec/dummy/lib/basic_benchmark.rb +2 -0
  96. data/spec/factories/calendars.rb +2 -0
  97. data/spec/factories/events.rb +2 -0
  98. data/spec/factories/roles.rb +2 -1
  99. data/spec/factories/users.rb +2 -0
  100. data/spec/features/calendars_spec.rb +47 -5
  101. data/spec/features/events_spec.rb +35 -9
  102. data/spec/helpers/date_book/application_helper_spec.rb +32 -0
  103. data/spec/helpers/date_book/events_helper_spec.rb +181 -13
  104. data/spec/models/calendar_spec.rb +3 -1
  105. data/spec/models/event_spec.rb +3 -1
  106. data/spec/models/role_spec.rb +1 -0
  107. data/spec/rails_helper.rb +6 -1
  108. data/spec/requests/date_book/api_spec.rb +76 -0
  109. data/spec/routing/date_book/calendars_routing_spec.rb +4 -2
  110. data/spec/routing/date_book/events_routing_spec.rb +48 -11
  111. data/spec/support/controller_behaviors.rb +2 -0
  112. data/spec/support/controller_macros.rb +3 -1
  113. data/spec/support/factory_girl.rb +2 -0
  114. data/spec/support/feature_behaviors.rb +9 -9
  115. data/spec/support/loaded_site.rb +2 -0
  116. data/spec/support/loaded_site/calendars.rb +2 -0
  117. data/spec/support/loaded_site/events.rb +3 -1
  118. data/spec/support/loaded_site/users.rb +2 -0
  119. data/spec/support/request_behaviors.rb +12 -63
  120. data/spec/support/shared_connection.rb +2 -0
  121. data/spec/support/utilities.rb +6 -5
  122. metadata +79 -42
  123. data/app/graphql/types/profile_type.rb +0 -7
  124. data/app/helpers/date_book/calendar_helper.rb +0 -4
  125. data/app/views/date_book/application/_all_day_checkbox.html.haml +0 -1
  126. data/bin/rails +0 -15
  127. data/spec/helpers/date_book/calendar_helper_spec.rb +0 -17
  128. data/spec/requests/date_book/events_spec.rb +0 -56
@@ -1,4 +1,7 @@
1
1
  # This migration comes from date_book (originally 20170807133850)
2
+ # frozen_string_literal: true
3
+
4
+ # Migration to add our fields to event_occurrences
2
5
  class AddFieldsToEventOccurrences < ActiveRecord::Migration[5.1]
3
6
  def change
4
7
  add_column :event_occurrences, :end_date, :datetime
@@ -10,7 +10,7 @@
10
10
  #
11
11
  # It's strongly recommended that you check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema.define(version: 20170808150920) do
13
+ ActiveRecord::Schema.define(version: 20170808200813) do
14
14
 
15
15
  create_table "calendars", force: :cascade do |t|
16
16
  t.string "name"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  after :users do
2
4
  BasicBenchmark.new "Seeding #{Rails.env} Calendars" do
3
5
  FactoryGirl.create(
@@ -19,4 +21,3 @@ after :users do
19
21
  )
20
22
  end
21
23
  end
22
-
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  after :users, :calendars do
2
4
  BasicBenchmark.new "Seeding #{Rails.env} Events" do
3
5
  FactoryGirl.create(
@@ -8,7 +10,7 @@ after :users, :calendars do
8
10
  calendar: Calendar.friendly.find('other-calendar'),
9
11
  schedule_attributes: {
10
12
  rule: 'weekly',
11
- day: %w(monday),
13
+ day: %w[monday],
12
14
  time: '00:00',
13
15
  duration: 1.day,
14
16
  all_day: true
@@ -21,7 +23,7 @@ after :users, :calendars do
21
23
  css_class: 'week',
22
24
  schedule_attributes: {
23
25
  rule: 'weekly',
24
- day: %w(monday),
26
+ day: %w[monday],
25
27
  time: '00:00',
26
28
  duration: 5.days,
27
29
  all_day: true
@@ -77,13 +79,11 @@ after :users, :calendars do
77
79
  calendar: Calendar.friendly.find('regular-calendar'),
78
80
  schedule_attributes: {
79
81
  rule: 'monthly',
80
- day_of_week: { tuesday: [ '1' ] },
82
+ day_of_week: { tuesday: ['1'] },
81
83
  time: '5:00 PM',
82
84
  interval: 1,
83
85
  duration: 1.hour
84
86
  }
85
87
  )
86
-
87
88
  end
88
89
  end
89
-
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  BasicBenchmark.new "Seeding #{Rails.env} Users" do
2
4
  FactoryGirl.create(
3
5
  :user,
@@ -13,4 +15,4 @@ BasicBenchmark.new "Seeding #{Rails.env} Users" do
13
15
  :user,
14
16
  name: 'Other User'
15
17
  )
16
- end
18
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ### My little tool for benchmarking code blocks
2
4
  class BasicBenchmark
3
5
  def initialize(label)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  FactoryGirl.define do
2
4
  factory :calendar do
3
5
  description { "<p>#{Faker::Lorem.paragraphs(2).join('</p><p>')}</p>" }
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  FactoryGirl.define do
2
4
  factory :event do
3
5
  description { "<p>#{Faker::Lorem.paragraphs(2).join('</p><p>')}</p>" }
@@ -1,5 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  FactoryGirl.define do
2
4
  factory :role do
3
-
4
5
  end
5
6
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  FactoryGirl.define do
2
4
  factory :user do
3
5
  sequence :email do |n|
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails_helper'
2
4
 
3
5
  RSpec.feature 'Calendars', folder: :features do
4
6
  include_context 'loaded site'
5
7
 
6
8
  include ActionView::Helpers::TextHelper
7
- let(:paragraphs) { %w(first second) }
9
+ let(:paragraphs) { %w[first second] }
8
10
  let!(:id) { regular_calendar.id }
9
11
 
10
12
  describe 'Browsing Calendars' do
@@ -22,7 +24,11 @@ RSpec.feature 'Calendars', folder: :features do
22
24
  before do
23
25
  visit '/date_book/calendars/regular-calendar'
24
26
  end
25
- it_behaves_like 'a bootstrap page showing an item', Calendar, 'Regular Calendar'
27
+ it_behaves_like(
28
+ 'a bootstrap page showing an item',
29
+ Calendar,
30
+ 'Regular Calendar'
31
+ )
26
32
  end
27
33
  end
28
34
 
@@ -64,12 +70,20 @@ RSpec.feature 'Calendars', folder: :features do
64
70
  end
65
71
  describe 'permits adding a valid Calendar', js: true do
66
72
  before do
73
+ # Make travis wait
74
+ wait_until do
75
+ page.has_field? 'Name'
76
+ end
67
77
  fill_in 'Name', with: 'Calendar Name Here'
68
78
  fill_in_wysiwyg(
69
79
  'Description',
70
80
  simple_format(paragraphs.join("\n\n"))
71
81
  )
72
82
  click_button 'Save Calendar'
83
+ # Make travis wait
84
+ wait_until do
85
+ page.has_css? 'h1', text: 'Calendar Name Here'
86
+ end
73
87
  end
74
88
  it_behaves_like(
75
89
  'a bootstrap page with an alert',
@@ -110,8 +124,16 @@ RSpec.feature 'Calendars', folder: :features do
110
124
  end
111
125
  describe 'validates editing a Calendar' do
112
126
  before do
127
+ # Make travis wait
128
+ wait_until do
129
+ page.has_field? 'Name'
130
+ end
113
131
  fill_in 'Name', with: ''
114
132
  click_button 'Save Calendar'
133
+ # Make travis wait
134
+ wait_until do
135
+ page.has_css? 'h1', text: 'Editing Regular Calendar'
136
+ end
115
137
  end
116
138
  it_behaves_like(
117
139
  'a bootstrap page with an alert',
@@ -124,12 +146,20 @@ RSpec.feature 'Calendars', folder: :features do
124
146
  end
125
147
  describe 'permits editing a valid Calendar' do
126
148
  before do
149
+ # Make travis wait
150
+ wait_until do
151
+ page.has_field? 'Name'
152
+ end
127
153
  fill_in 'Name', with: 'Calendar Name Here'
128
154
  fill_in_wysiwyg(
129
155
  'Description',
130
156
  simple_format(paragraphs.join("\n\n"))
131
157
  )
132
158
  click_button 'Save Calendar'
159
+ # Make travis wait
160
+ wait_until do
161
+ page.has_css? 'h1', text: 'Calendar Name Here'
162
+ end
133
163
  end
134
164
  it_behaves_like(
135
165
  'a bootstrap page with an alert',
@@ -152,7 +182,11 @@ RSpec.feature 'Calendars', folder: :features do
152
182
  describe 'when not logged in' do
153
183
  before do
154
184
  # While we're not logged in:
155
- page.driver.submit :delete, '/date_book/calendars/regular-calendar', {}
185
+ page.driver.submit(
186
+ :delete,
187
+ '/date_book/calendars/regular-calendar',
188
+ {}
189
+ )
156
190
  end
157
191
  it_behaves_like 'an authentication error'
158
192
  end
@@ -160,14 +194,22 @@ RSpec.feature 'Calendars', folder: :features do
160
194
  describe 'and not authorized' do
161
195
  before do
162
196
  login_as other_user
163
- page.driver.submit :delete, '/date_book/calendars/regular-calendar', {}
197
+ page.driver.submit(
198
+ :delete,
199
+ '/date_book/calendars/regular-calendar',
200
+ {}
201
+ )
164
202
  end
165
203
  it_behaves_like 'an authorization error'
166
204
  end
167
205
  describe 'and authorized' do
168
206
  before do
169
207
  login_as regular_user
170
- page.driver.submit :delete, '/date_book/calendars/regular-calendar', {}
208
+ page.driver.submit(
209
+ :delete,
210
+ '/date_book/calendars/regular-calendar',
211
+ {}
212
+ )
171
213
  end
172
214
  it_behaves_like 'a bootstrap page', title: 'Calendars'
173
215
  it_behaves_like(
@@ -1,11 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails_helper'
2
4
 
3
5
  RSpec.feature 'Events', folder: :features do
4
6
  include_context 'loaded site'
5
7
 
6
8
  include ActionView::Helpers::TextHelper
7
- let(:paragraphs) { %w(first second) }
8
- let!(:club_id) { science_fiction_club_event.id }
9
+ let(:paragraphs) { %w[first second] }
10
+ let!(:club_id) { science_fiction_club.id }
9
11
 
10
12
  describe 'Browsing Events' do
11
13
  describe 'at /date_book/calendars/admin-calendar/events' do
@@ -100,7 +102,10 @@ RSpec.feature 'Events', folder: :features do
100
102
  describe 'when not logged in' do
101
103
  before do
102
104
  # While we're not logged in:
103
- visit '/date_book/calendars/regular-calendar/events/science-fiction-club/edit'
105
+ visit(
106
+ '/date_book/calendars/regular-calendar/events/'\
107
+ 'science-fiction-club/edit'
108
+ )
104
109
  end
105
110
  it_behaves_like 'an authentication error'
106
111
  end
@@ -108,16 +113,25 @@ RSpec.feature 'Events', folder: :features do
108
113
  describe 'and not authorized' do
109
114
  before do
110
115
  login_as other_user
111
- visit '/date_book/calendars/regular-calendar/events/science-fiction-club/edit'
116
+ visit(
117
+ '/date_book/calendars/regular-calendar/events/'\
118
+ 'science-fiction-club/edit'
119
+ )
112
120
  end
113
121
  it_behaves_like 'an authorization error'
114
122
  end
115
123
  describe 'and authorized' do
116
124
  before do
117
125
  login_as regular_user
118
- visit '/date_book/calendars/regular-calendar/events/science-fiction-club/edit'
126
+ visit(
127
+ '/date_book/calendars/regular-calendar/events/'\
128
+ 'science-fiction-club/edit'
129
+ )
119
130
  end
120
- it_behaves_like 'a bootstrap page', title: 'Editing Science Fiction Club'
131
+ it_behaves_like(
132
+ 'a bootstrap page',
133
+ title: 'Editing Science Fiction Club'
134
+ )
121
135
  describe 'displays a form to edit the Event' do
122
136
  subject { page }
123
137
  it { should have_css("form#edit_event_#{club_id}") }
@@ -168,7 +182,11 @@ RSpec.feature 'Events', folder: :features do
168
182
  describe 'when not logged in' do
169
183
  before do
170
184
  # While we're not logged in:
171
- page.driver.submit :delete, '/date_book/calendars/regular-calendar/events/science-fiction-club', {}
185
+ page.driver.submit(
186
+ :delete,
187
+ '/date_book/calendars/regular-calendar/events/science-fiction-club',
188
+ {}
189
+ )
172
190
  end
173
191
  it_behaves_like 'an authentication error'
174
192
  end
@@ -176,14 +194,22 @@ RSpec.feature 'Events', folder: :features do
176
194
  describe 'and not authorized' do
177
195
  before do
178
196
  login_as other_user
179
- page.driver.submit :delete, '/date_book/calendars/regular-calendar/events/science-fiction-club', {}
197
+ page.driver.submit(
198
+ :delete,
199
+ '/date_book/calendars/regular-calendar/events/science-fiction-club',
200
+ {}
201
+ )
180
202
  end
181
203
  it_behaves_like 'an authorization error'
182
204
  end
183
205
  describe 'and authorized' do
184
206
  before do
185
207
  login_as regular_user
186
- page.driver.submit :delete, '/date_book/calendars/regular-calendar/events/science-fiction-club', {}
208
+ page.driver.submit(
209
+ :delete,
210
+ '/date_book/calendars/regular-calendar/events/science-fiction-club',
211
+ {}
212
+ )
187
213
  end
188
214
  it_behaves_like 'a bootstrap page', title: 'Events'
189
215
  it_behaves_like(
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_helper'
4
+
5
+ describe DateBook::ApplicationHelper, folder: :helpers do
6
+ include_context 'loaded site'
7
+
8
+ describe '#date_book_scripts' do
9
+ subject { helper.date_book_scripts }
10
+ it { should have_tag('script') }
11
+ it { should have_tag('link') }
12
+ end
13
+
14
+ describe '#date_book_date_range' do
15
+ let(:start_date) { Time.parse('2017-07-04 10:00 AM') }
16
+ let(:end_date) { Time.parse('2017-07-05 10:00 AM') }
17
+ subject { helper.date_book_date_range(start_date, end_date, false, 1.day) }
18
+ it { should eq "2017-07-04 10:00 am\n&mdash;\n2017-07-05 10:00 am\n" }
19
+ end
20
+
21
+ describe '#date_book_date' do
22
+ let(:date) { Time.parse('2017-07-04 10:00 AM') }
23
+ subject { helper.date_book_date(date, false) }
24
+ it { should eq '2017-07-04 10:00 am' }
25
+ end
26
+
27
+ describe '#date_book_time' do
28
+ let(:time) { Time.parse('10:00 AM') }
29
+ subject { helper.date_book_time(time) }
30
+ it { should eq '10:00 am' }
31
+ end
32
+ end
@@ -1,17 +1,185 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails_helper'
2
4
 
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__}"
5
+ describe DateBook::EventsHelper, folder: :helpers do
6
+ helper BootstrapForm::Helpers::Bootstrap
7
+ helper BootstrapLeather::ApplicationHelper
8
+ helper DateBook::ApplicationHelper
9
+
10
+ include_context 'loaded site'
11
+
12
+ let(:form_section) do
13
+ form_section = nil
14
+ object = [monday_event.calendar, monday_event]
15
+
16
+ helper.bootstrap_form_for object do |f|
17
+ f.fields_for :schedule do |g|
18
+ form_section = g
19
+ end
20
+ end
21
+
22
+ form_section
23
+ end
24
+
25
+ describe '#date_book_event_occurrence_dates' do
26
+ let(:rendered) { helper.date_book_event_occurrence_dates(monday_event) }
27
+ it 'displays dates in a dl' do
28
+ expect(rendered).to have_tag('dl') do
29
+ with_tag 'dt' do
30
+ with_text 'Next Occurrence'
31
+ end
32
+ with_tag 'dd' do
33
+ with_tag 'a', with: { href: monday_event.event_occurrences.first.url }
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ describe '#date_book_rule_form_section' do
40
+ let(:rendered) do
41
+ helper.date_book_rule_form_section('singular', form_section)
42
+ end
43
+ it 'contains a date field' do
44
+ expect(rendered).to have_tag(
45
+ 'div',
46
+ with: { class: 'form-group date-book--date' }
47
+ ) do
48
+ with_tag 'label', with: { for: 'event_schedule_attributes_date' }
49
+ with_tag 'div', with: { class: 'input-group' } do
50
+ with_tag 'span', with: { class: 'glyphicon-calendar' }
51
+ with_tag 'input', with: { id: 'event_schedule_attributes_date' }
52
+ end
53
+ end
54
+ end
55
+ it 'contains a time field' do
56
+ expect(rendered).to have_tag(
57
+ 'div',
58
+ with: { class: 'form-group date-book--time' }
59
+ ) do
60
+ with_tag 'label', with: { for: 'event_schedule_attributes_time' }
61
+ with_tag 'div', with: { class: 'input-group' } do
62
+ with_tag 'span', with: { class: 'glyphicon-time' }
63
+ with_tag 'input', with: { id: 'event_schedule_attributes_time' }
64
+ with_tag 'input', with: { id: 'event_schedule_attributes_all_day' }
65
+ end
66
+ end
67
+ end
68
+ it 'contains a duration field' do
69
+ expect(rendered).to have_tag(
70
+ 'div',
71
+ with: { class: 'form-group date-book--duration' }
72
+ ) do
73
+ with_tag 'label', with: { for: 'event_schedule_attributes_duration' }
74
+ with_tag 'div', with: { class: 'input-group' } do
75
+ with_tag 'input', with: {
76
+ id: 'event_schedule_attributes_duration_attributes_count'
77
+ }
78
+ with_tag 'select', with: {
79
+ id: 'event_schedule_attributes_duration_attributes_unit'
80
+ }
81
+ end
82
+ end
83
+ end
84
+ end
85
+
86
+ describe '#date_book_date_field' do
87
+ let(:rendered) { helper.date_book_date_field(form_section) }
88
+ it 'shows the date field' do
89
+ expect(rendered).to have_tag(
90
+ 'div',
91
+ with: { class: 'form-group date-book--date' }
92
+ ) do
93
+ with_tag 'label', with: { for: 'event_schedule_attributes_date' }
94
+ with_tag 'div', with: { class: 'input-group' } do
95
+ with_tag 'span', with: { class: 'glyphicon-calendar' }
96
+ with_tag 'input', with: { id: 'event_schedule_attributes_date' }
97
+ end
98
+ end
99
+ end
100
+ end
101
+
102
+ describe '#date_book_time_field' do
103
+ let(:rendered) { helper.date_book_time_field(form_section) }
104
+ it 'shows the time field' do
105
+ expect(rendered).to have_tag(
106
+ 'div',
107
+ with: { class: 'form-group date-book--time' }
108
+ ) do
109
+ with_tag 'label', with: { for: 'event_schedule_attributes_time' }
110
+ with_tag 'div', with: { class: 'input-group' } do
111
+ with_tag 'span', with: { class: 'glyphicon-time' }
112
+ with_tag 'input', with: { id: 'event_schedule_attributes_time' }
113
+ with_tag 'input', with: { id: 'event_schedule_attributes_all_day' }
114
+ end
115
+ end
116
+ end
117
+ end
118
+
119
+ describe '#date_book_duration_field' do
120
+ let(:rendered) { helper.date_book_duration_field(form_section) }
121
+ it 'shows the duration field' do
122
+ expect(rendered).to have_tag(
123
+ 'div',
124
+ with: { class: 'form-group date-book--duration' }
125
+ ) do
126
+ with_tag 'label', with: { for: 'event_schedule_attributes_duration' }
127
+ with_tag 'div', with: { class: 'input-group' } do
128
+ with_tag 'input', with: {
129
+ id: 'event_schedule_attributes_duration_attributes_count'
130
+ }
131
+ with_tag 'select', with: {
132
+ id: 'event_schedule_attributes_duration_attributes_unit'
133
+ }
134
+ end
135
+ end
136
+ end
137
+ end
138
+
139
+ describe '#date_book_interval_field' do
140
+ let(:rendered) { helper.date_book_interval_field('hours', form_section) }
141
+ it 'shows the interval field' do
142
+ expect(rendered).to have_tag('div', with: { class: 'form-group' }) do
143
+ with_tag 'label', with: { for: 'event_schedule_attributes_interval' }
144
+ with_tag 'input', with: { id: 'event_schedule_attributes_interval' }
145
+ end
146
+ end
147
+ end
148
+
149
+ describe '#date_book_day_field' do
150
+ let(:rendered) { helper.date_book_day_field(form_section) }
151
+ it 'shows a hidden field to catch destruction of all checks' do
152
+ expect(rendered).to have_tag(
153
+ 'input',
154
+ with: {
155
+ type: 'hidden',
156
+ id: 'event_schedule_attributes_day'
157
+ }
158
+ )
159
+ end
160
+ it 'shows the actual checkboxes' do
161
+ expect(rendered).to have_tag(
162
+ 'div',
163
+ with: { class: 'form-group date-book--day' }
164
+ ) do
165
+ with_tag 'label', minimum: 7 do
166
+ with_tag 'input', with: { type: 'checkbox' }
167
+ end
168
+ end
169
+ end
170
+ end
171
+
172
+ describe '#date_book_day_of_week_field' do
173
+ let(:rendered) { helper.date_book_day_of_week_field(form_section) }
174
+ it 'shows the day of week field' do
175
+ expect(rendered).to have_tag(
176
+ 'div',
177
+ with: { class: 'form-group date-book--day-of-week' }
178
+ ) do
179
+ with_tag 'td', count: 35 do
180
+ with_tag 'input', with: { type: 'checkbox' }
181
+ end
182
+ end
183
+ end
16
184
  end
17
185
  end