simple_calendar 2.4.3 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +5 -4
  3. data/.gitignore +4 -0
  4. data/Appraisals +5 -5
  5. data/CHANGELOG.md +7 -0
  6. data/Gemfile +4 -1
  7. data/Gemfile.lock +157 -136
  8. data/README.md +22 -15
  9. data/Rakefile +29 -5
  10. data/app/assets/stylesheets/simple_calendar.scss +4 -0
  11. data/app/views/simple_calendar/_calendar.html.erb +7 -7
  12. data/app/views/simple_calendar/_month_calendar.html.erb +8 -8
  13. data/app/views/simple_calendar/_week_calendar.html.erb +14 -12
  14. data/bin/rails +16 -0
  15. data/gemfiles/rails_6_1.gemfile +3 -1
  16. data/gemfiles/rails_6_1.gemfile.lock +159 -131
  17. data/gemfiles/{rails_6.gemfile → rails_7_0.gemfile} +4 -2
  18. data/gemfiles/rails_7_0.gemfile.lock +222 -0
  19. data/gemfiles/{rails_master.gemfile → rails_main.gemfile} +3 -1
  20. data/gemfiles/rails_main.gemfile.lock +246 -0
  21. data/lib/simple_calendar/calendar.rb +26 -14
  22. data/lib/simple_calendar/month_calendar.rb +4 -0
  23. data/lib/simple_calendar/version.rb +1 -1
  24. data/lib/simple_calendar/view_helpers.rb +3 -3
  25. data/lib/simple_calendar/week_calendar.rb +5 -1
  26. data/lib/simple_calendar.rb +8 -1
  27. data/simple_calendar.gemspec +1 -3
  28. data/test/calendars/calendar_test.rb +154 -0
  29. data/test/calendars/month_calendar_test.rb +16 -0
  30. data/test/dummy/Rakefile +6 -0
  31. data/test/dummy/app/assets/config/manifest.js +1 -0
  32. data/test/dummy/app/assets/images/.keep +0 -0
  33. data/test/dummy/app/assets/stylesheets/application.css +1 -0
  34. data/test/dummy/app/channels/application_cable/channel.rb +4 -0
  35. data/test/dummy/app/channels/application_cable/connection.rb +4 -0
  36. data/test/dummy/app/controllers/application_controller.rb +2 -0
  37. data/test/dummy/app/controllers/concerns/.keep +0 -0
  38. data/test/dummy/app/controllers/meetings_controller.rb +59 -0
  39. data/test/dummy/app/helpers/application_helper.rb +2 -0
  40. data/test/dummy/app/helpers/meetings_helper.rb +2 -0
  41. data/test/dummy/app/jobs/application_job.rb +7 -0
  42. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  43. data/test/dummy/app/models/application_record.rb +7 -0
  44. data/test/dummy/app/models/concerns/.keep +0 -0
  45. data/test/dummy/app/models/meeting.rb +2 -0
  46. data/test/dummy/app/views/layouts/application.html.erb +15 -0
  47. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  48. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  49. data/test/dummy/app/views/meetings/_form.html.erb +32 -0
  50. data/test/dummy/app/views/meetings/_meeting.html.erb +17 -0
  51. data/test/dummy/app/views/meetings/edit.html.erb +10 -0
  52. data/test/dummy/app/views/meetings/index.html.erb +24 -0
  53. data/test/dummy/app/views/meetings/new.html.erb +9 -0
  54. data/test/dummy/app/views/meetings/show.html.erb +10 -0
  55. data/test/dummy/bin/rails +4 -0
  56. data/test/dummy/bin/rake +4 -0
  57. data/test/dummy/bin/setup +33 -0
  58. data/test/dummy/config/application.rb +22 -0
  59. data/test/dummy/config/boot.rb +5 -0
  60. data/test/dummy/config/cable.yml +10 -0
  61. data/test/dummy/config/database.yml +25 -0
  62. data/test/dummy/config/environment.rb +5 -0
  63. data/test/dummy/config/environments/development.rb +67 -0
  64. data/test/dummy/config/environments/production.rb +87 -0
  65. data/test/dummy/config/environments/test.rb +60 -0
  66. data/test/dummy/config/initializers/content_security_policy.rb +25 -0
  67. data/test/dummy/config/initializers/filter_parameter_logging.rb +8 -0
  68. data/test/dummy/config/initializers/inflections.rb +16 -0
  69. data/test/dummy/config/initializers/permissions_policy.rb +11 -0
  70. data/test/dummy/config/locales/en.yml +33 -0
  71. data/test/dummy/config/puma.rb +43 -0
  72. data/test/dummy/config/routes.rb +7 -0
  73. data/test/dummy/config/storage.yml +34 -0
  74. data/test/dummy/config.ru +6 -0
  75. data/test/dummy/db/migrate/20220930184313_create_meetings.rb +11 -0
  76. data/test/dummy/db/schema.rb +21 -0
  77. data/test/dummy/lib/assets/.keep +0 -0
  78. data/test/dummy/log/.keep +0 -0
  79. data/test/dummy/public/404.html +67 -0
  80. data/test/dummy/public/422.html +67 -0
  81. data/test/dummy/public/500.html +66 -0
  82. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  83. data/test/dummy/public/apple-touch-icon.png +0 -0
  84. data/test/dummy/public/favicon.ico +0 -0
  85. data/test/dummy/storage/.keep +0 -0
  86. data/test/dummy/tmp/.keep +0 -0
  87. data/test/dummy/tmp/development_secret.txt +1 -0
  88. data/test/dummy/tmp/pids/.keep +0 -0
  89. data/test/dummy/tmp/pids/server.pid +1 -0
  90. data/test/dummy/tmp/restart.txt +0 -0
  91. data/test/dummy/tmp/storage/.keep +0 -0
  92. data/test/fixtures/meetings.yml +36 -0
  93. data/test/integrations/month_calendar_test.rb +58 -0
  94. data/test/simple_calendar_test.rb +7 -0
  95. data/test/test_helper.rb +14 -0
  96. metadata +80 -39
  97. data/gemfiles/rails_6.gemfile.lock +0 -195
  98. data/gemfiles/rails_master.gemfile.lock +0 -207
  99. data/spec/calendar_spec.rb +0 -176
  100. data/spec/calendars/month_calendar_spec.rb +0 -25
  101. data/spec/simple_calendar_spec.rb +0 -9
  102. data/spec/spec_helper.rb +0 -96
  103. data/spec/support/fake_event.rb +0 -9
  104. data/spec/support/view_context.rb +0 -20
  105. data/spec/views_generators_spec.rb +0 -7
  106. /data/lib/simple_calendar/{railtie.rb → engine.rb} +0 -0
@@ -1,195 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- simple_calendar (2.4.3)
5
- rails (>= 3.0)
6
-
7
- GEM
8
- remote: http://rubygems.org/
9
- specs:
10
- actioncable (6.0.3.7)
11
- actionpack (= 6.0.3.7)
12
- nio4r (~> 2.0)
13
- websocket-driver (>= 0.6.1)
14
- actionmailbox (6.0.3.7)
15
- actionpack (= 6.0.3.7)
16
- activejob (= 6.0.3.7)
17
- activerecord (= 6.0.3.7)
18
- activestorage (= 6.0.3.7)
19
- activesupport (= 6.0.3.7)
20
- mail (>= 2.7.1)
21
- actionmailer (6.0.3.7)
22
- actionpack (= 6.0.3.7)
23
- actionview (= 6.0.3.7)
24
- activejob (= 6.0.3.7)
25
- mail (~> 2.5, >= 2.5.4)
26
- rails-dom-testing (~> 2.0)
27
- actionpack (6.0.3.7)
28
- actionview (= 6.0.3.7)
29
- activesupport (= 6.0.3.7)
30
- rack (~> 2.0, >= 2.0.8)
31
- rack-test (>= 0.6.3)
32
- rails-dom-testing (~> 2.0)
33
- rails-html-sanitizer (~> 1.0, >= 1.2.0)
34
- actiontext (6.0.3.7)
35
- actionpack (= 6.0.3.7)
36
- activerecord (= 6.0.3.7)
37
- activestorage (= 6.0.3.7)
38
- activesupport (= 6.0.3.7)
39
- nokogiri (>= 1.8.5)
40
- actionview (6.0.3.7)
41
- activesupport (= 6.0.3.7)
42
- builder (~> 3.1)
43
- erubi (~> 1.4)
44
- rails-dom-testing (~> 2.0)
45
- rails-html-sanitizer (~> 1.1, >= 1.2.0)
46
- activejob (6.0.3.7)
47
- activesupport (= 6.0.3.7)
48
- globalid (>= 0.3.6)
49
- activemodel (6.0.3.7)
50
- activesupport (= 6.0.3.7)
51
- activerecord (6.0.3.7)
52
- activemodel (= 6.0.3.7)
53
- activesupport (= 6.0.3.7)
54
- activestorage (6.0.3.7)
55
- actionpack (= 6.0.3.7)
56
- activejob (= 6.0.3.7)
57
- activerecord (= 6.0.3.7)
58
- marcel (~> 1.0.0)
59
- activesupport (6.0.3.7)
60
- concurrent-ruby (~> 1.0, >= 1.0.2)
61
- i18n (>= 0.7, < 2)
62
- minitest (~> 5.1)
63
- tzinfo (~> 1.1)
64
- zeitwerk (~> 2.2, >= 2.2.2)
65
- appraisal (2.4.0)
66
- bundler
67
- rake
68
- thor (>= 0.14.0)
69
- ast (2.4.2)
70
- builder (3.2.4)
71
- concurrent-ruby (1.1.8)
72
- crass (1.0.6)
73
- diff-lcs (1.4.4)
74
- erubi (1.10.0)
75
- globalid (0.4.2)
76
- activesupport (>= 4.2.0)
77
- i18n (1.8.10)
78
- concurrent-ruby (~> 1.0)
79
- loofah (2.9.1)
80
- crass (~> 1.0.2)
81
- nokogiri (>= 1.5.9)
82
- mail (2.7.1)
83
- mini_mime (>= 0.1.1)
84
- marcel (1.0.1)
85
- method_source (1.0.0)
86
- mini_mime (1.1.0)
87
- mini_portile2 (2.5.1)
88
- minitest (5.14.4)
89
- nio4r (2.5.7)
90
- nokogiri (1.11.3)
91
- mini_portile2 (~> 2.5.0)
92
- racc (~> 1.4)
93
- nokogiri (1.11.3-x86_64-darwin)
94
- racc (~> 1.4)
95
- nokogiri (1.11.3-x86_64-linux)
96
- racc (~> 1.4)
97
- parallel (1.20.1)
98
- parser (3.0.1.1)
99
- ast (~> 2.4.1)
100
- racc (1.5.2)
101
- rack (2.2.3)
102
- rack-test (1.1.0)
103
- rack (>= 1.0, < 3)
104
- rails (6.0.3.7)
105
- actioncable (= 6.0.3.7)
106
- actionmailbox (= 6.0.3.7)
107
- actionmailer (= 6.0.3.7)
108
- actionpack (= 6.0.3.7)
109
- actiontext (= 6.0.3.7)
110
- actionview (= 6.0.3.7)
111
- activejob (= 6.0.3.7)
112
- activemodel (= 6.0.3.7)
113
- activerecord (= 6.0.3.7)
114
- activestorage (= 6.0.3.7)
115
- activesupport (= 6.0.3.7)
116
- bundler (>= 1.3.0)
117
- railties (= 6.0.3.7)
118
- sprockets-rails (>= 2.0.0)
119
- rails-dom-testing (2.0.3)
120
- activesupport (>= 4.2.0)
121
- nokogiri (>= 1.6)
122
- rails-html-sanitizer (1.3.0)
123
- loofah (~> 2.3)
124
- railties (6.0.3.7)
125
- actionpack (= 6.0.3.7)
126
- activesupport (= 6.0.3.7)
127
- method_source
128
- rake (>= 0.8.7)
129
- thor (>= 0.20.3, < 2.0)
130
- rainbow (3.0.0)
131
- rake (13.0.3)
132
- regexp_parser (2.1.1)
133
- rexml (3.2.5)
134
- rspec (3.10.0)
135
- rspec-core (~> 3.10.0)
136
- rspec-expectations (~> 3.10.0)
137
- rspec-mocks (~> 3.10.0)
138
- rspec-core (3.10.1)
139
- rspec-support (~> 3.10.0)
140
- rspec-expectations (3.10.1)
141
- diff-lcs (>= 1.2.0, < 2.0)
142
- rspec-support (~> 3.10.0)
143
- rspec-mocks (3.10.2)
144
- diff-lcs (>= 1.2.0, < 2.0)
145
- rspec-support (~> 3.10.0)
146
- rspec-support (3.10.2)
147
- rubocop (1.14.0)
148
- parallel (~> 1.10)
149
- parser (>= 3.0.0.0)
150
- rainbow (>= 2.2.2, < 4.0)
151
- regexp_parser (>= 1.8, < 3.0)
152
- rexml
153
- rubocop-ast (>= 1.5.0, < 2.0)
154
- ruby-progressbar (~> 1.7)
155
- unicode-display_width (>= 1.4.0, < 3.0)
156
- rubocop-ast (1.5.0)
157
- parser (>= 3.0.1.1)
158
- rubocop-performance (1.11.2)
159
- rubocop (>= 1.7.0, < 2.0)
160
- rubocop-ast (>= 0.4.0)
161
- ruby-progressbar (1.11.0)
162
- sprockets (4.0.2)
163
- concurrent-ruby (~> 1.0)
164
- rack (> 1, < 3)
165
- sprockets-rails (3.2.2)
166
- actionpack (>= 4.0)
167
- activesupport (>= 4.0)
168
- sprockets (>= 3.0.0)
169
- standard (1.1.1)
170
- rubocop (= 1.14.0)
171
- rubocop-performance (= 1.11.2)
172
- thor (1.1.0)
173
- thread_safe (0.3.6)
174
- tzinfo (1.2.9)
175
- thread_safe (~> 0.1)
176
- unicode-display_width (2.0.0)
177
- websocket-driver (0.7.3)
178
- websocket-extensions (>= 0.1.0)
179
- websocket-extensions (0.1.5)
180
- zeitwerk (2.4.2)
181
-
182
- PLATFORMS
183
- ruby
184
- x86_64-darwin-20
185
- x86_64-linux
186
-
187
- DEPENDENCIES
188
- appraisal
189
- rails (~> 6.0.0)
190
- rspec
191
- simple_calendar!
192
- standard
193
-
194
- BUNDLED WITH
195
- 2.2.20
@@ -1,207 +0,0 @@
1
- GIT
2
- remote: https://github.com/rails/rails.git
3
- revision: f250208dd477e879f16a0cea51bc5c399651107d
4
- specs:
5
- actioncable (6.2.0.alpha)
6
- actionpack (= 6.2.0.alpha)
7
- activesupport (= 6.2.0.alpha)
8
- nio4r (~> 2.0)
9
- websocket-driver (>= 0.6.1)
10
- actionmailbox (6.2.0.alpha)
11
- actionpack (= 6.2.0.alpha)
12
- activejob (= 6.2.0.alpha)
13
- activerecord (= 6.2.0.alpha)
14
- activestorage (= 6.2.0.alpha)
15
- activesupport (= 6.2.0.alpha)
16
- mail (>= 2.7.1)
17
- actionmailer (6.2.0.alpha)
18
- actionpack (= 6.2.0.alpha)
19
- actionview (= 6.2.0.alpha)
20
- activejob (= 6.2.0.alpha)
21
- activesupport (= 6.2.0.alpha)
22
- mail (~> 2.5, >= 2.5.4)
23
- rails-dom-testing (~> 2.0)
24
- actionpack (6.2.0.alpha)
25
- actionview (= 6.2.0.alpha)
26
- activesupport (= 6.2.0.alpha)
27
- rack (~> 2.0, >= 2.0.9)
28
- rack-test (>= 0.6.3)
29
- rails-dom-testing (~> 2.0)
30
- rails-html-sanitizer (~> 1.0, >= 1.2.0)
31
- actiontext (6.2.0.alpha)
32
- actionpack (= 6.2.0.alpha)
33
- activerecord (= 6.2.0.alpha)
34
- activestorage (= 6.2.0.alpha)
35
- activesupport (= 6.2.0.alpha)
36
- nokogiri (>= 1.8.5)
37
- actionview (6.2.0.alpha)
38
- activesupport (= 6.2.0.alpha)
39
- builder (~> 3.1)
40
- erubi (~> 1.4)
41
- rails-dom-testing (~> 2.0)
42
- rails-html-sanitizer (~> 1.1, >= 1.2.0)
43
- activejob (6.2.0.alpha)
44
- activesupport (= 6.2.0.alpha)
45
- globalid (>= 0.3.6)
46
- activemodel (6.2.0.alpha)
47
- activesupport (= 6.2.0.alpha)
48
- activerecord (6.2.0.alpha)
49
- activemodel (= 6.2.0.alpha)
50
- activesupport (= 6.2.0.alpha)
51
- activestorage (6.2.0.alpha)
52
- actionpack (= 6.2.0.alpha)
53
- activejob (= 6.2.0.alpha)
54
- activerecord (= 6.2.0.alpha)
55
- activesupport (= 6.2.0.alpha)
56
- marcel (~> 0.3.1)
57
- mimemagic (~> 0.3.2)
58
- activesupport (6.2.0.alpha)
59
- concurrent-ruby (~> 1.0, >= 1.0.2)
60
- i18n (>= 1.6, < 2)
61
- minitest (>= 5.1)
62
- tzinfo (~> 2.0)
63
- zeitwerk (~> 2.3)
64
- rails (6.2.0.alpha)
65
- actioncable (= 6.2.0.alpha)
66
- actionmailbox (= 6.2.0.alpha)
67
- actionmailer (= 6.2.0.alpha)
68
- actionpack (= 6.2.0.alpha)
69
- actiontext (= 6.2.0.alpha)
70
- actionview (= 6.2.0.alpha)
71
- activejob (= 6.2.0.alpha)
72
- activemodel (= 6.2.0.alpha)
73
- activerecord (= 6.2.0.alpha)
74
- activestorage (= 6.2.0.alpha)
75
- activesupport (= 6.2.0.alpha)
76
- bundler (>= 1.15.0)
77
- railties (= 6.2.0.alpha)
78
- sprockets-rails (>= 2.0.0)
79
- railties (6.2.0.alpha)
80
- actionpack (= 6.2.0.alpha)
81
- activesupport (= 6.2.0.alpha)
82
- method_source
83
- rake (>= 0.8.7)
84
- thor (~> 1.0)
85
-
86
- PATH
87
- remote: ..
88
- specs:
89
- simple_calendar (2.4.3)
90
- rails (>= 3.0)
91
-
92
- GEM
93
- remote: http://rubygems.org/
94
- specs:
95
- appraisal (2.4.0)
96
- bundler
97
- rake
98
- thor (>= 0.14.0)
99
- ast (2.4.2)
100
- builder (3.2.4)
101
- concurrent-ruby (1.1.8)
102
- crass (1.0.6)
103
- diff-lcs (1.4.4)
104
- erubi (1.10.0)
105
- globalid (0.4.2)
106
- activesupport (>= 4.2.0)
107
- i18n (1.8.10)
108
- concurrent-ruby (~> 1.0)
109
- loofah (2.9.1)
110
- crass (~> 1.0.2)
111
- nokogiri (>= 1.5.9)
112
- mail (2.7.1)
113
- mini_mime (>= 0.1.1)
114
- marcel (0.3.3)
115
- mimemagic (~> 0.3.2)
116
- method_source (1.0.0)
117
- mimemagic (0.3.10)
118
- nokogiri (~> 1)
119
- rake
120
- mini_mime (1.1.0)
121
- mini_portile2 (2.5.1)
122
- minitest (5.14.4)
123
- nio4r (2.5.7)
124
- nokogiri (1.11.3)
125
- mini_portile2 (~> 2.5.0)
126
- racc (~> 1.4)
127
- nokogiri (1.11.3-x86_64-darwin)
128
- racc (~> 1.4)
129
- nokogiri (1.11.3-x86_64-linux)
130
- racc (~> 1.4)
131
- parallel (1.20.1)
132
- parser (3.0.1.1)
133
- ast (~> 2.4.1)
134
- racc (1.5.2)
135
- rack (2.2.3)
136
- rack-test (1.1.0)
137
- rack (>= 1.0, < 3)
138
- rails-dom-testing (2.0.3)
139
- activesupport (>= 4.2.0)
140
- nokogiri (>= 1.6)
141
- rails-html-sanitizer (1.3.0)
142
- loofah (~> 2.3)
143
- rainbow (3.0.0)
144
- rake (13.0.3)
145
- regexp_parser (2.1.1)
146
- rexml (3.2.5)
147
- rspec (3.10.0)
148
- rspec-core (~> 3.10.0)
149
- rspec-expectations (~> 3.10.0)
150
- rspec-mocks (~> 3.10.0)
151
- rspec-core (3.10.1)
152
- rspec-support (~> 3.10.0)
153
- rspec-expectations (3.10.1)
154
- diff-lcs (>= 1.2.0, < 2.0)
155
- rspec-support (~> 3.10.0)
156
- rspec-mocks (3.10.2)
157
- diff-lcs (>= 1.2.0, < 2.0)
158
- rspec-support (~> 3.10.0)
159
- rspec-support (3.10.2)
160
- rubocop (1.14.0)
161
- parallel (~> 1.10)
162
- parser (>= 3.0.0.0)
163
- rainbow (>= 2.2.2, < 4.0)
164
- regexp_parser (>= 1.8, < 3.0)
165
- rexml
166
- rubocop-ast (>= 1.5.0, < 2.0)
167
- ruby-progressbar (~> 1.7)
168
- unicode-display_width (>= 1.4.0, < 3.0)
169
- rubocop-ast (1.5.0)
170
- parser (>= 3.0.1.1)
171
- rubocop-performance (1.11.2)
172
- rubocop (>= 1.7.0, < 2.0)
173
- rubocop-ast (>= 0.4.0)
174
- ruby-progressbar (1.11.0)
175
- sprockets (4.0.2)
176
- concurrent-ruby (~> 1.0)
177
- rack (> 1, < 3)
178
- sprockets-rails (3.2.2)
179
- actionpack (>= 4.0)
180
- activesupport (>= 4.0)
181
- sprockets (>= 3.0.0)
182
- standard (1.1.1)
183
- rubocop (= 1.14.0)
184
- rubocop-performance (= 1.11.2)
185
- thor (1.1.0)
186
- tzinfo (2.0.4)
187
- concurrent-ruby (~> 1.0)
188
- unicode-display_width (2.0.0)
189
- websocket-driver (0.7.3)
190
- websocket-extensions (>= 0.1.0)
191
- websocket-extensions (0.1.5)
192
- zeitwerk (2.4.2)
193
-
194
- PLATFORMS
195
- ruby
196
- x86_64-darwin-20
197
- x86_64-linux
198
-
199
- DEPENDENCIES
200
- appraisal
201
- rails!
202
- rspec
203
- simple_calendar!
204
- standard
205
-
206
- BUNDLED WITH
207
- 2.2.20
@@ -1,176 +0,0 @@
1
- require "spec_helper"
2
- require "action_controller"
3
- require "simple_calendar/calendar"
4
- require_relative "support/fake_event"
5
- require_relative "support/view_context"
6
-
7
- describe SimpleCalendar::Calendar do
8
- let(:calendar) { SimpleCalendar::Calendar.new(ViewContext.new) }
9
-
10
- it "renders a partial with the same name as the class" do
11
- expect(calendar.send(:partial_name)).to eq("simple_calendar/calendar")
12
- end
13
-
14
- context "event sorting attribute" do
15
- it "has start_time as the default attribute" do
16
- expect(calendar.send(:attribute)).to eq(:start_time)
17
- end
18
-
19
- it "allows you to override the default attribute" do
20
- expect(SimpleCalendar::Calendar.new(ViewContext.new, attribute: :starts_at).send(:attribute)).to eq(:starts_at)
21
- end
22
-
23
- it "set a default when `partial` option isn't present" do
24
- expect(SimpleCalendar::Calendar.new(ViewContext.new).send(:partial_name)).to eq("simple_calendar/calendar")
25
- expect(SimpleCalendar::MonthCalendar.new(ViewContext.new).send(:partial_name)).to eq("simple_calendar/month_calendar")
26
- expect(SimpleCalendar::WeekCalendar.new(ViewContext.new).send(:partial_name)).to eq("simple_calendar/week_calendar")
27
- end
28
-
29
- it "allows to override the default partial" do
30
- expect(SimpleCalendar::Calendar.new(ViewContext.new, partial: "simple_calendar/custom_calendar").send(:partial_name)).to eq("simple_calendar/custom_calendar")
31
- end
32
- end
33
-
34
- describe "#sorted_events" do
35
- it "converts an array of events to a hash sorted by days" do
36
- today, tomorrow = Date.today, Date.tomorrow
37
-
38
- event1 = double(start_time: today.at_midnight)
39
- event2 = double(start_time: today.at_noon)
40
- event3 = double(start_time: tomorrow.at_noon)
41
-
42
- events = [event1, event2, event3].shuffle
43
- calendar = SimpleCalendar::Calendar.new(ViewContext.new, events: events)
44
-
45
- sorted_events = calendar.send(:sorted_events)
46
-
47
- expect(sorted_events[today]).to eq([event1, event2])
48
- expect(sorted_events[tomorrow]).to eq([event3])
49
- end
50
-
51
- it "converts an array of multi-day events to a hash sorted by days" do
52
- today, tomorrow = Date.today, Date.tomorrow
53
-
54
- event1 = double(start_time: today.at_midnight, end_time: tomorrow.at_midnight)
55
- event2 = double(start_time: today.at_noon)
56
- event3 = double(start_time: tomorrow.at_noon)
57
-
58
- events = [event1, event2, event3].shuffle
59
- calendar = SimpleCalendar::Calendar.new(ViewContext.new, events: events)
60
-
61
- sorted_events = calendar.send(:sorted_events)
62
-
63
- expect(sorted_events[today]).to eq([event1, event2])
64
- expect(sorted_events[tomorrow]).to eq([event1, event3])
65
- end
66
-
67
- it "handles events without a start time" do
68
- event = double(start_time: nil)
69
- calendar = SimpleCalendar::Calendar.new(ViewContext.new, events: [event])
70
-
71
- expect { calendar.send(:sorted_events) }.not_to raise_error
72
- end
73
- end
74
-
75
- describe "#start_date" do
76
- it "defaults to today's date" do
77
- view_context = ViewContext.new
78
- calendar = SimpleCalendar::Calendar.new(view_context)
79
- expect(calendar.send(:start_date)).to eq(Date.today)
80
- end
81
-
82
- it "uses the view context's params start_date to override" do
83
- view_context = ViewContext.new(Date.yesterday)
84
- calendar = SimpleCalendar::Calendar.new(view_context)
85
- expect(calendar.send(:start_date)).to eq(Date.yesterday)
86
- end
87
-
88
- it "uses the optional argument's start_date to override view_context's start_date" do
89
- view_context = ViewContext.new(Date.yesterday)
90
- calendar = SimpleCalendar::Calendar.new(view_context, start_date: Date.tomorrow)
91
- expect(calendar.send(:start_date)).to eq(Date.tomorrow)
92
- end
93
-
94
- it "takes an option to override the start_date parameter" do
95
- view_context = ViewContext.new(Date.yesterday, start_date_param: :date)
96
- calendar = SimpleCalendar::Calendar.new(view_context, start_date_param: :date)
97
- expect(calendar.send(:start_date)).to eq(Date.yesterday)
98
- end
99
- end
100
-
101
- describe "current week class" do
102
- it "should have the current week" do
103
- calendar = SimpleCalendar::Calendar.new(ViewContext.new)
104
- week = calendar.date_range.each_slice(7).to_a[0]
105
- expect(calendar.send(:tr_classes_for, week)).to include("current-week")
106
- end
107
-
108
- it "should not have the current week if it does not contain today" do
109
- calendar = SimpleCalendar::MonthCalendar.new(ViewContext.new(6.months.ago))
110
- week = calendar.date_range.each_slice(7).to_a[0]
111
- expect(calendar.send(:tr_classes_for, week)).to_not include("current-week")
112
- end
113
- end
114
-
115
- it "has a param that determines the start date of the calendar" do
116
- calendar = SimpleCalendar::Calendar.new(ViewContext.new)
117
-
118
- rendering_variables = calendar.render[:locals]
119
-
120
- expect(rendering_variables[:start_date]).not_to be_nil
121
- end
122
-
123
- it "generates a default date if no start date is present" do
124
- calendar = SimpleCalendar::Calendar.new(ViewContext.new)
125
-
126
- calendar_start_date = calendar.render[:locals][:start_date]
127
-
128
- expect(calendar_start_date).not_to be_nil
129
- expect(calendar_start_date).to be_a(Date)
130
- end
131
-
132
- it "has a range of dates" do
133
- calendar = SimpleCalendar::Calendar.new(ViewContext.new)
134
-
135
- calendar_date_range = calendar.date_range
136
-
137
- expect(calendar_date_range).to be_an(Array)
138
- expect(calendar_date_range).to all(be_an(Date))
139
- end
140
-
141
- it "can split the range of dates into weeks"
142
- it "has a title"
143
- it "has a next view link"
144
- it "has a previous view link"
145
-
146
- it "accepts an array of events" do
147
- first_event = FakeEvent.new("event1", Date.today)
148
- second_event = FakeEvent.new("event2", Date.today + 1.day)
149
- events = [first_event, second_event]
150
- calendar = SimpleCalendar::Calendar.new(ViewContext.new, events: events)
151
-
152
- calendar_sorted_events = calendar.render[:locals][:sorted_events]
153
-
154
- expect(calendar_sorted_events.length).to eq(2)
155
- end
156
-
157
- it "sorts the events" do
158
- first_event = FakeEvent.new("event1", Date.today + 2.days)
159
- second_event = FakeEvent.new("event2", Date.today + 1.day)
160
- third_event = FakeEvent.new("event3", Date.today)
161
- events = [first_event, third_event, second_event]
162
- calendar = SimpleCalendar::Calendar.new(ViewContext.new, events: events)
163
-
164
- calendar_sorted_events = calendar.render[:locals][:sorted_events]
165
- first_key = calendar_sorted_events.keys[0]
166
- second_key = calendar_sorted_events.keys[1]
167
- third_key = calendar_sorted_events.keys[2]
168
-
169
- expect(calendar_sorted_events[first_key][0]).to eq(third_event)
170
- expect(calendar_sorted_events[second_key][0]).to eq(second_event)
171
- expect(calendar_sorted_events[third_key][0]).to eq(first_event)
172
- end
173
-
174
- it "yields the events for each day"
175
- it "doesn't crash when an event has a nil start_time"
176
- end
@@ -1,25 +0,0 @@
1
- require "spec_helper"
2
- require "action_controller"
3
- require "simple_calendar/calendar"
4
- require "simple_calendar/month_calendar"
5
- require "support/view_context"
6
-
7
- describe SimpleCalendar::MonthCalendar do
8
- describe "#date_range" do
9
- it "renders a full calendar month" do
10
- today = Date.today
11
- calendar = SimpleCalendar::MonthCalendar.new(ViewContext.new, start_date: Date.today)
12
-
13
- expect(calendar.date_range.min).to be <= today.beginning_of_month
14
- expect(calendar.date_range.max).to be >= today.end_of_month
15
- end
16
-
17
- it "render the days of next and previous months on the edges of the calendar" do
18
- month = Date.new(2018, 8, 1)
19
- calendar = SimpleCalendar::MonthCalendar.new(ViewContext.new, start_date: month)
20
-
21
- expect(calendar.date_range.first).to eq Date.new(2018, 7, 30)
22
- expect(calendar.date_range.last).to eq Date.new(2018, 9, 2)
23
- end
24
- end
25
- end
@@ -1,9 +0,0 @@
1
- require "spec_helper"
2
- require "rails"
3
- require "simple_calendar"
4
-
5
- describe SimpleCalendar do
6
- it "has a version number" do
7
- expect(SimpleCalendar::VERSION).not_to be nil
8
- end
9
- end