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.
- checksums.yaml +4 -4
- data/.rubocop.yml +9 -1
- data/.rubocop_todo.yml +2 -1
- data/.travis.yml +3 -0
- data/Gemfile +16 -4
- data/Gemfile.lock +14 -2
- data/VERSION +1 -1
- data/app/assets/javascripts/date_book/calendar_events.js +3 -3
- data/app/assets/stylesheets/date_book.css.scss +31 -2
- data/app/controllers/date_book/calendars_controller.rb +30 -19
- data/app/controllers/date_book/date_book_controller.rb +1 -1
- data/app/controllers/date_book/events_controller.rb +60 -62
- data/app/controllers/date_book/graphql_controller.rb +10 -11
- data/app/graphql/date_book_schema.rb +4 -4
- data/app/graphql/types/calendar_type.rb +4 -2
- data/app/graphql/types/date_time_type.rb +9 -5
- data/app/graphql/types/event_occurrence_type.rb +4 -2
- data/app/graphql/types/event_type.rb +4 -2
- data/app/graphql/types/mutation_type.rb +3 -1
- data/app/graphql/types/query_type.rb +12 -26
- data/app/helpers/date_book/application_helper.rb +4 -7
- data/app/helpers/date_book/events_helper.rb +43 -23
- data/app/views/date_book/application/_date_range.html.haml +3 -3
- data/app/views/date_book/calendars/index.html.haml +19 -3
- data/app/views/date_book/calendars/show.html.haml +29 -4
- data/app/views/date_book/events/_event.json.jbuilder +3 -1
- data/app/views/date_book/events/_form.html.haml +4 -4
- data/app/views/date_book/events/_occurrence_dates.html.haml +3 -3
- data/app/views/date_book/events/fields/_date.html.haml +1 -1
- data/app/views/date_book/events/fields/_day.html.haml +1 -1
- data/app/views/date_book/events/fields/_day_of_week.html.haml +3 -3
- data/app/views/date_book/events/fields/_duration.html.haml +3 -3
- data/app/views/date_book/events/fields/_interval.html.haml +1 -1
- data/app/views/date_book/events/fields/_time.html.haml +1 -1
- data/app/views/date_book/events/index.html.haml +1 -1
- data/app/views/date_book/events/rules/_daily.html.haml +3 -3
- data/app/views/date_book/events/rules/_monthly.html.haml +4 -4
- data/app/views/date_book/events/rules/_singular.html.haml +3 -3
- data/app/views/date_book/events/rules/_weekly.html.haml +4 -4
- data/app/views/date_book/events/show.html.haml +1 -1
- data/app/views/layouts/_date_book_scripts.html.haml +2 -4
- data/config/locales/en.yml +2 -0
- data/config/routes.rb +1 -1
- data/date_book.gemspec +25 -22
- data/db/migrate/20170807133845_create_calendars.rb +3 -0
- data/db/migrate/20170807133846_create_events.rb +3 -0
- data/db/migrate/20170807133847_create_schedules.rb +9 -6
- data/db/migrate/20170807133848_add_fields_to_schedule.rb +3 -0
- data/db/migrate/20170807133849_create_event_occurrences.rb +4 -3
- data/db/migrate/20170807133850_add_fields_to_event_occurrences.rb +3 -0
- data/lib/date_book.rb +11 -2
- data/lib/date_book/concerns/ability.rb +9 -12
- data/lib/date_book/concerns/acts_as_calendar.rb +5 -6
- data/lib/date_book/concerns/acts_as_event.rb +30 -9
- data/lib/date_book/concerns/acts_as_event_occurrence.rb +21 -9
- data/lib/date_book/concerns/acts_as_ownable.rb +9 -3
- data/lib/date_book/concerns/acts_as_owner.rb +5 -6
- data/lib/date_book/concerns/acts_as_schedule.rb +14 -7
- data/lib/date_book/configuration.rb +14 -11
- data/lib/date_book/engine.rb +7 -5
- data/lib/date_book/version.rb +2 -0
- data/lib/generators/date_book/install/install_generator.rb +27 -29
- data/lib/generators/date_book/install/templates/app/models/calendar.rb +4 -1
- data/lib/generators/date_book/install/templates/app/models/event.rb +4 -1
- data/lib/generators/date_book/install/templates/app/models/event_occurrence.rb +4 -1
- data/lib/generators/date_book/install/templates/app/models/schedule.rb +4 -1
- data/spec/abilities/event_spec.rb +1 -1
- data/spec/controllers/date_book/calendars_controller_spec.rb +48 -20
- data/spec/controllers/date_book/events_controller_spec.rb +145 -39
- data/spec/dummy/app/models/calendar.rb +3 -1
- data/spec/dummy/app/models/event.rb +3 -1
- data/spec/dummy/app/models/event_occurrence.rb +3 -1
- data/spec/dummy/app/models/role.rb +7 -5
- data/spec/dummy/app/models/schedule.rb +3 -1
- data/spec/dummy/app/models/user.rb +3 -3
- data/spec/dummy/config/initializers/devise.rb +61 -40
- data/spec/dummy/config/initializers/high_voltage.rb +2 -0
- data/spec/dummy/config/initializers/rolify.rb +5 -2
- data/spec/dummy/config/routes.rb +6 -9
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20170728171103_create_users_table.rb +2 -0
- data/spec/dummy/db/migrate/20170807134122_add_devise_to_users.rb +4 -3
- data/spec/dummy/db/migrate/20170807134128_rolify_create_roles.rb +6 -4
- data/spec/dummy/db/migrate/{20170808150915_create_calendars.date_book.rb → 20170808200808_create_calendars.date_book.rb} +3 -0
- data/spec/dummy/db/migrate/{20170808150916_create_events.date_book.rb → 20170808200809_create_events.date_book.rb} +3 -0
- data/spec/dummy/db/migrate/{20170808150917_create_schedules.date_book.rb → 20170808200810_create_schedules.date_book.rb} +9 -6
- data/spec/dummy/db/migrate/{20170808150918_add_fields_to_schedule.date_book.rb → 20170808200811_add_fields_to_schedule.date_book.rb} +3 -0
- data/spec/dummy/db/migrate/{20170808150919_create_event_occurrences.date_book.rb → 20170808200812_create_event_occurrences.date_book.rb} +4 -3
- 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
- data/spec/dummy/db/schema.rb +1 -1
- data/spec/dummy/db/seeds/calendars.seeds.rb +2 -1
- data/spec/dummy/db/seeds/events.seeds.rb +5 -5
- data/spec/dummy/db/seeds/users.seeds.rb +3 -1
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/lib/basic_benchmark.rb +2 -0
- data/spec/factories/calendars.rb +2 -0
- data/spec/factories/events.rb +2 -0
- data/spec/factories/roles.rb +2 -1
- data/spec/factories/users.rb +2 -0
- data/spec/features/calendars_spec.rb +47 -5
- data/spec/features/events_spec.rb +35 -9
- data/spec/helpers/date_book/application_helper_spec.rb +32 -0
- data/spec/helpers/date_book/events_helper_spec.rb +181 -13
- data/spec/models/calendar_spec.rb +3 -1
- data/spec/models/event_spec.rb +3 -1
- data/spec/models/role_spec.rb +1 -0
- data/spec/rails_helper.rb +6 -1
- data/spec/requests/date_book/api_spec.rb +76 -0
- data/spec/routing/date_book/calendars_routing_spec.rb +4 -2
- data/spec/routing/date_book/events_routing_spec.rb +48 -11
- data/spec/support/controller_behaviors.rb +2 -0
- data/spec/support/controller_macros.rb +3 -1
- data/spec/support/factory_girl.rb +2 -0
- data/spec/support/feature_behaviors.rb +9 -9
- data/spec/support/loaded_site.rb +2 -0
- data/spec/support/loaded_site/calendars.rb +2 -0
- data/spec/support/loaded_site/events.rb +3 -1
- data/spec/support/loaded_site/users.rb +2 -0
- data/spec/support/request_behaviors.rb +12 -63
- data/spec/support/shared_connection.rb +2 -0
- data/spec/support/utilities.rb +6 -5
- metadata +79 -42
- data/app/graphql/types/profile_type.rb +0 -7
- data/app/helpers/date_book/calendar_helper.rb +0 -4
- data/app/views/date_book/application/_all_day_checkbox.html.haml +0 -1
- data/bin/rails +0 -15
- data/spec/helpers/date_book/calendar_helper_spec.rb +0 -17
- data/spec/requests/date_book/events_spec.rb +0 -56
@@ -19,7 +19,7 @@ describe 'Abilities on Events', folder: :abilities do
|
|
19
19
|
it { should_not be_able_to(:create, Event) }
|
20
20
|
end
|
21
21
|
context 'when logged in as regular user' do
|
22
|
-
let(:my_event) {
|
22
|
+
let(:my_event) { science_fiction_club }
|
23
23
|
let(:other_event) { monday_event }
|
24
24
|
let(:user) { regular_user }
|
25
25
|
subject(:ability) { Ability.new(user) }
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rails_helper'
|
2
4
|
|
3
5
|
module DateBook
|
@@ -7,16 +9,22 @@ module DateBook
|
|
7
9
|
include_context 'loaded site'
|
8
10
|
include ControllerMacros
|
9
11
|
|
10
|
-
# This should return the minimal set of attributes required to create a
|
11
|
-
# Calendar. As you add validations to Calendar, be sure to
|
12
|
-
#
|
13
|
-
let(:valid_attributes)
|
14
|
-
{
|
15
|
-
|
12
|
+
# This should return the minimal set of attributes required to create a
|
13
|
+
# valid Calendar. As you add validations to Calendar, be sure to adjust the
|
14
|
+
# attributes here as well.
|
15
|
+
let(:valid_attributes) do
|
16
|
+
{
|
17
|
+
name: 'Test Calendar',
|
18
|
+
schedule_attributes: {
|
19
|
+
date: 1.hour.ago.to_date,
|
20
|
+
time: 1.hour.ago
|
21
|
+
}
|
22
|
+
}
|
23
|
+
end
|
16
24
|
|
17
|
-
let(:invalid_attributes)
|
25
|
+
let(:invalid_attributes) do
|
18
26
|
{ name: nil, schedule_attributes: nil }
|
19
|
-
|
27
|
+
end
|
20
28
|
|
21
29
|
describe 'GET #index' do
|
22
30
|
before do
|
@@ -92,7 +100,6 @@ module DateBook
|
|
92
100
|
end
|
93
101
|
end
|
94
102
|
|
95
|
-
|
96
103
|
describe 'POST #create' do
|
97
104
|
describe 'when not logged in' do
|
98
105
|
before do
|
@@ -121,7 +128,7 @@ module DateBook
|
|
121
128
|
login_user regular_user
|
122
129
|
end
|
123
130
|
it 'results in a new calendar' do
|
124
|
-
expect { post(:create, params: {
|
131
|
+
expect { post(:create, params: { calendar: valid_attributes }) }
|
125
132
|
.to change { Calendar.count(:id) }.by(1)
|
126
133
|
end
|
127
134
|
end
|
@@ -142,8 +149,8 @@ module DateBook
|
|
142
149
|
login_user regular_user
|
143
150
|
end
|
144
151
|
it 'does not result in a new calendar' do
|
145
|
-
expect { post(:create, params: {
|
146
|
-
.to_not
|
152
|
+
expect { post(:create, params: { calendar: invalid_attributes }) }
|
153
|
+
.to_not(change { Calendar.count(:id) })
|
147
154
|
end
|
148
155
|
end
|
149
156
|
end
|
@@ -153,7 +160,13 @@ module DateBook
|
|
153
160
|
describe 'when not logged in' do
|
154
161
|
before do
|
155
162
|
# Here's where we are *not* logging in
|
156
|
-
put
|
163
|
+
put(
|
164
|
+
:update,
|
165
|
+
params: {
|
166
|
+
id: 'regular-calendar',
|
167
|
+
calendar: valid_attributes
|
168
|
+
}
|
169
|
+
)
|
157
170
|
end
|
158
171
|
it_should_behave_like 'a redirect to the home page'
|
159
172
|
end
|
@@ -161,7 +174,13 @@ module DateBook
|
|
161
174
|
describe 'as someone other than the owner' do
|
162
175
|
before do
|
163
176
|
login_user other_user
|
164
|
-
put
|
177
|
+
put(
|
178
|
+
:update,
|
179
|
+
params: {
|
180
|
+
id: 'regular-calendar',
|
181
|
+
calendar: valid_attributes
|
182
|
+
}
|
183
|
+
)
|
165
184
|
end
|
166
185
|
it_should_behave_like 'a 403 Forbidden error'
|
167
186
|
end
|
@@ -169,10 +188,19 @@ module DateBook
|
|
169
188
|
describe 'with valid params' do
|
170
189
|
before do
|
171
190
|
login_user regular_user
|
172
|
-
put
|
191
|
+
put(
|
192
|
+
:update,
|
193
|
+
params: {
|
194
|
+
id: 'regular-calendar',
|
195
|
+
calendar: valid_attributes
|
196
|
+
}
|
197
|
+
)
|
173
198
|
end
|
174
199
|
# Note that slug does not change
|
175
|
-
it_should_behave_like
|
200
|
+
it_should_behave_like(
|
201
|
+
'a redirect to',
|
202
|
+
'/date_book/calendars/regular-calendar'
|
203
|
+
)
|
176
204
|
|
177
205
|
describe 'updates @calendar' do
|
178
206
|
subject { regular_calendar.reload }
|
@@ -189,9 +217,10 @@ module DateBook
|
|
189
217
|
login_user regular_user
|
190
218
|
put(
|
191
219
|
:update, params: {
|
192
|
-
|
193
|
-
|
194
|
-
|
220
|
+
id: 'regular-calendar',
|
221
|
+
calendar: invalid_attributes
|
222
|
+
}
|
223
|
+
)
|
195
224
|
end
|
196
225
|
it_should_behave_like 'a successful page', which_renders: 'edit'
|
197
226
|
|
@@ -254,6 +283,5 @@ module DateBook
|
|
254
283
|
end
|
255
284
|
end
|
256
285
|
end
|
257
|
-
|
258
286
|
end
|
259
287
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rails_helper'
|
2
4
|
|
3
5
|
module DateBook
|
@@ -7,16 +9,19 @@ module DateBook
|
|
7
9
|
include_context 'loaded site'
|
8
10
|
include ControllerMacros
|
9
11
|
|
10
|
-
# This should return the minimal set of attributes required to create a
|
11
|
-
# Event. As you add validations to Event, be sure to
|
12
|
-
#
|
13
|
-
let(:valid_attributes)
|
14
|
-
{
|
15
|
-
|
12
|
+
# This should return the minimal set of attributes required to create a
|
13
|
+
# valid Event. As you add validations to Event, be sure to adjust the
|
14
|
+
# attributes here as well.
|
15
|
+
let(:valid_attributes) do
|
16
|
+
{
|
17
|
+
name: 'Test Event',
|
18
|
+
schedule_attributes: { date: 1.hour.ago.to_date, time: 1.hour.ago }
|
19
|
+
}
|
20
|
+
end
|
16
21
|
|
17
|
-
let(:invalid_attributes)
|
22
|
+
let(:invalid_attributes) do
|
18
23
|
{ name: nil, schedule_attributes: nil }
|
19
|
-
|
24
|
+
end
|
20
25
|
|
21
26
|
describe 'GET #index' do
|
22
27
|
describe 'without a query' do
|
@@ -33,7 +38,10 @@ module DateBook
|
|
33
38
|
end
|
34
39
|
describe 'with a query' do
|
35
40
|
before do
|
36
|
-
get
|
41
|
+
get(
|
42
|
+
:index,
|
43
|
+
params: { start: Time.zone.now, calendar_id: 'admin-calendar' }
|
44
|
+
)
|
37
45
|
end
|
38
46
|
it_should_behave_like 'a successful page', which_renders: 'index'
|
39
47
|
|
@@ -47,14 +55,20 @@ module DateBook
|
|
47
55
|
|
48
56
|
describe 'GET #show' do
|
49
57
|
before do
|
50
|
-
get
|
58
|
+
get(
|
59
|
+
:show,
|
60
|
+
params: { id: 'the-work-week', calendar_id: 'admin-calendar' }
|
61
|
+
)
|
51
62
|
end
|
52
63
|
it_should_behave_like 'a successful page', which_renders: 'show'
|
53
64
|
end
|
54
65
|
|
55
66
|
describe 'GET #popover' do
|
56
67
|
before do
|
57
|
-
get
|
68
|
+
get(
|
69
|
+
:popover,
|
70
|
+
params: { id: 'the-work-week', calendar_id: 'admin-calendar' }
|
71
|
+
)
|
58
72
|
end
|
59
73
|
it_should_behave_like 'a successful page', which_renders: 'popover'
|
60
74
|
end
|
@@ -63,14 +77,14 @@ module DateBook
|
|
63
77
|
describe 'when not logged in' do
|
64
78
|
before do
|
65
79
|
# Here's where we are *not* logging in
|
66
|
-
get :new, params: { calendar_id: 'regular-calendar'}
|
80
|
+
get :new, params: { calendar_id: 'regular-calendar' }
|
67
81
|
end
|
68
82
|
it_should_behave_like 'a redirect to the home page'
|
69
83
|
end
|
70
84
|
describe 'when logged in' do
|
71
85
|
before do
|
72
86
|
login_user regular_user
|
73
|
-
get :new, params: { calendar_id: 'regular-calendar'}
|
87
|
+
get :new, params: { calendar_id: 'regular-calendar' }
|
74
88
|
end
|
75
89
|
it_should_behave_like 'a successful page', which_renders: 'new'
|
76
90
|
|
@@ -86,7 +100,10 @@ module DateBook
|
|
86
100
|
describe 'when not logged in' do
|
87
101
|
before do
|
88
102
|
# Here's where we are *not* logging in
|
89
|
-
get
|
103
|
+
get(
|
104
|
+
:edit,
|
105
|
+
params: { id: 'the-work-week', calendar_id: 'admin-calendar' }
|
106
|
+
)
|
90
107
|
end
|
91
108
|
it_should_behave_like 'a redirect to the home page'
|
92
109
|
end
|
@@ -94,31 +111,42 @@ module DateBook
|
|
94
111
|
describe 'as someone other than the owner' do
|
95
112
|
before do
|
96
113
|
login_user regular_user
|
97
|
-
get
|
114
|
+
get(
|
115
|
+
:edit,
|
116
|
+
params: { id: 'the-work-week', calendar_id: 'admin-calendar' }
|
117
|
+
)
|
98
118
|
end
|
99
119
|
it_should_behave_like 'a 403 Forbidden error'
|
100
120
|
end
|
101
121
|
describe 'as the owner' do
|
102
122
|
before do
|
103
123
|
login_user regular_user
|
104
|
-
get
|
124
|
+
get(
|
125
|
+
:edit,
|
126
|
+
params: {
|
127
|
+
id: 'science-fiction-club',
|
128
|
+
calendar_id: 'regular-calendar'
|
129
|
+
}
|
130
|
+
)
|
105
131
|
end
|
106
132
|
it_should_behave_like 'a successful page', which_renders: 'edit'
|
107
133
|
|
108
134
|
describe 'loads requested event into @event' do
|
109
135
|
subject { assigns(:event) }
|
110
|
-
it { should eq
|
136
|
+
it { should eq science_fiction_club }
|
111
137
|
end
|
112
138
|
end
|
113
139
|
end
|
114
140
|
end
|
115
141
|
|
116
|
-
|
117
142
|
describe 'POST #create' do
|
118
143
|
describe 'when not logged in' do
|
119
144
|
before do
|
120
145
|
# Here's where we are *not* logging in
|
121
|
-
post
|
146
|
+
post(
|
147
|
+
:create,
|
148
|
+
params: { event: valid_attributes, calendar_id: 'regular-calendar' }
|
149
|
+
)
|
122
150
|
end
|
123
151
|
it_should_behave_like 'a redirect to the home page'
|
124
152
|
end
|
@@ -126,7 +154,13 @@ module DateBook
|
|
126
154
|
describe 'with valid params' do
|
127
155
|
before do
|
128
156
|
login_user regular_user
|
129
|
-
post
|
157
|
+
post(
|
158
|
+
:create,
|
159
|
+
params: {
|
160
|
+
event: valid_attributes,
|
161
|
+
calendar_id: 'regular-calendar'
|
162
|
+
}
|
163
|
+
)
|
130
164
|
end
|
131
165
|
it_should_behave_like(
|
132
166
|
'a redirect to',
|
@@ -142,14 +176,27 @@ module DateBook
|
|
142
176
|
login_user regular_user
|
143
177
|
end
|
144
178
|
it 'results in a new event' do
|
145
|
-
expect
|
146
|
-
|
179
|
+
expect do
|
180
|
+
post(
|
181
|
+
:create,
|
182
|
+
params: {
|
183
|
+
event: valid_attributes,
|
184
|
+
calendar_id: 'regular-calendar'
|
185
|
+
}
|
186
|
+
)
|
187
|
+
end.to change { Event.count(:id) }.by(1)
|
147
188
|
end
|
148
189
|
end
|
149
190
|
describe 'with invalid params' do
|
150
191
|
before do
|
151
192
|
login_user regular_user
|
152
|
-
post
|
193
|
+
post(
|
194
|
+
:create,
|
195
|
+
params: {
|
196
|
+
event: invalid_attributes,
|
197
|
+
calendar_id: 'regular-calendar'
|
198
|
+
}
|
199
|
+
)
|
153
200
|
end
|
154
201
|
it_should_behave_like 'a successful page', which_renders: 'new'
|
155
202
|
|
@@ -163,8 +210,15 @@ module DateBook
|
|
163
210
|
login_user regular_user
|
164
211
|
end
|
165
212
|
it 'does not result in a new event' do
|
166
|
-
expect
|
167
|
-
|
213
|
+
expect do
|
214
|
+
post(
|
215
|
+
:create,
|
216
|
+
params: {
|
217
|
+
event: invalid_attributes,
|
218
|
+
calendar_id: 'regular-calendar'
|
219
|
+
}
|
220
|
+
)
|
221
|
+
end.to_not(change { Event.count(:id) })
|
168
222
|
end
|
169
223
|
end
|
170
224
|
end
|
@@ -174,7 +228,14 @@ module DateBook
|
|
174
228
|
describe 'when not logged in' do
|
175
229
|
before do
|
176
230
|
# Here's where we are *not* logging in
|
177
|
-
put
|
231
|
+
put(
|
232
|
+
:update,
|
233
|
+
params: {
|
234
|
+
id: 'science-fiction-club',
|
235
|
+
event: valid_attributes,
|
236
|
+
calendar_id: 'regular-calendar'
|
237
|
+
}
|
238
|
+
)
|
178
239
|
end
|
179
240
|
it_should_behave_like 'a redirect to the home page'
|
180
241
|
end
|
@@ -182,7 +243,14 @@ module DateBook
|
|
182
243
|
describe 'as someone other than the owner' do
|
183
244
|
before do
|
184
245
|
login_user other_user
|
185
|
-
put
|
246
|
+
put(
|
247
|
+
:update,
|
248
|
+
params: {
|
249
|
+
id: 'science-fiction-club',
|
250
|
+
event: valid_attributes,
|
251
|
+
calendar_id: 'regular-calendar'
|
252
|
+
}
|
253
|
+
)
|
186
254
|
end
|
187
255
|
it_should_behave_like 'a 403 Forbidden error'
|
188
256
|
end
|
@@ -190,13 +258,24 @@ module DateBook
|
|
190
258
|
describe 'with valid params' do
|
191
259
|
before do
|
192
260
|
login_user regular_user
|
193
|
-
put
|
261
|
+
put(
|
262
|
+
:update,
|
263
|
+
params: {
|
264
|
+
id: 'science-fiction-club',
|
265
|
+
event: valid_attributes,
|
266
|
+
calendar_id: 'regular-calendar'
|
267
|
+
}
|
268
|
+
)
|
194
269
|
end
|
195
270
|
# Note that slug does not change
|
196
|
-
it_should_behave_like
|
271
|
+
it_should_behave_like(
|
272
|
+
'a redirect to',
|
273
|
+
'/date_book/calendars/regular-calendar/events/'\
|
274
|
+
'science-fiction-club'
|
275
|
+
)
|
197
276
|
|
198
277
|
describe 'updates @event' do
|
199
|
-
subject {
|
278
|
+
subject { science_fiction_club.reload }
|
200
279
|
its(:name) { should eq 'Test Event' }
|
201
280
|
end
|
202
281
|
|
@@ -221,11 +300,11 @@ module DateBook
|
|
221
300
|
|
222
301
|
describe 'loads the given event into @event' do
|
223
302
|
subject { assigns(:event) }
|
224
|
-
it { should eq
|
303
|
+
it { should eq science_fiction_club }
|
225
304
|
end
|
226
305
|
|
227
306
|
describe 'does not update @event' do
|
228
|
-
subject {
|
307
|
+
subject { science_fiction_club.reload }
|
229
308
|
its(:name) { should eq 'Science Fiction Club' }
|
230
309
|
end
|
231
310
|
|
@@ -242,7 +321,13 @@ module DateBook
|
|
242
321
|
describe 'when not logged in' do
|
243
322
|
before do
|
244
323
|
# Here's where we are *not* logging in
|
245
|
-
delete
|
324
|
+
delete(
|
325
|
+
:destroy,
|
326
|
+
params: {
|
327
|
+
id: 'science-fiction-club',
|
328
|
+
calendar_id: 'regular-calendar'
|
329
|
+
}
|
330
|
+
)
|
246
331
|
end
|
247
332
|
it_should_behave_like 'a redirect to the home page'
|
248
333
|
end
|
@@ -250,17 +335,32 @@ module DateBook
|
|
250
335
|
describe 'as someone other than the owner' do
|
251
336
|
before do
|
252
337
|
login_user other_user
|
253
|
-
delete
|
338
|
+
delete(
|
339
|
+
:destroy,
|
340
|
+
params: {
|
341
|
+
id: 'science-fiction-club',
|
342
|
+
calendar_id: 'regular-calendar'
|
343
|
+
}
|
344
|
+
)
|
254
345
|
end
|
255
346
|
it_should_behave_like 'a 403 Forbidden error'
|
256
347
|
end
|
257
348
|
describe 'as the owner' do
|
258
349
|
before do
|
259
350
|
login_user regular_user
|
260
|
-
delete
|
351
|
+
delete(
|
352
|
+
:destroy,
|
353
|
+
params: {
|
354
|
+
id: 'science-fiction-club',
|
355
|
+
calendar_id: 'regular-calendar'
|
356
|
+
}
|
357
|
+
)
|
261
358
|
end
|
262
359
|
# Note that slug does not change
|
263
|
-
it_should_behave_like
|
360
|
+
it_should_behave_like(
|
361
|
+
'a redirect to',
|
362
|
+
'/date_book/calendars/regular-calendar/events'
|
363
|
+
)
|
264
364
|
|
265
365
|
describe "sets the flash with a notice of the event's removal" do
|
266
366
|
subject { flash[:notice] }
|
@@ -272,12 +372,18 @@ module DateBook
|
|
272
372
|
login_user regular_user
|
273
373
|
end
|
274
374
|
it 'results one less event' do
|
275
|
-
expect
|
276
|
-
|
375
|
+
expect do
|
376
|
+
delete(
|
377
|
+
:destroy,
|
378
|
+
params: {
|
379
|
+
id: 'science-fiction-club',
|
380
|
+
calendar_id: 'regular-calendar'
|
381
|
+
}
|
382
|
+
)
|
383
|
+
end.to change { Event.count(:id) }.by(-1)
|
277
384
|
end
|
278
385
|
end
|
279
386
|
end
|
280
387
|
end
|
281
|
-
|
282
388
|
end
|
283
389
|
end
|