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,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails_helper'
2
4
 
3
5
  RSpec.describe Calendar, folder: :models do
@@ -23,4 +25,4 @@ RSpec.describe Calendar, folder: :models do
23
25
 
24
26
  describe 'Scopes and Methods' do
25
27
  end
26
- end
28
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails_helper'
2
4
 
3
5
  RSpec.describe Event, folder: :models do
@@ -59,4 +61,4 @@ RSpec.describe Event, folder: :models do
59
61
  its(:end_date) { should be < Time.now }
60
62
  end
61
63
  end
62
- end
64
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # require 'rails_helper'
2
3
  #
3
4
  # RSpec.describe Role, type: :model do
@@ -66,7 +66,12 @@ RSpec.configure do |config|
66
66
 
67
67
  config.include Rails.application.routes.url_helpers
68
68
 
69
- config.include RSpecHtmlMatchers, folder: :helper
69
+ # Capybara doesn't work on helpers
70
+ config.include RSpecHtmlMatchers, type: :helper
71
+
72
+ config.before :each, type: :helper do
73
+ helper.class.include DateBook::Engine.routes.url_helpers
74
+ end
70
75
 
71
76
  # In order to tell Rspec how to use Devise, as per
72
77
  # https://github.com/plataformatec/devise/wiki/How-To:-Test-controllers-with-Rails-3-and-4-%28and-RSpec%29
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_helper'
4
+
5
+ RSpec.describe 'DateBook API', folder: :requests do
6
+ include_context 'loaded site'
7
+
8
+ let(:calendar_query) do
9
+ { query: '
10
+ {
11
+ calendar(slug: "regular-calendar") {
12
+ event_occurrences {
13
+ url,
14
+ popover_url,
15
+ start,
16
+ end,
17
+ event {
18
+ id,
19
+ name,
20
+ css_class,
21
+ text_color,
22
+ background_color,
23
+ border_color,
24
+ all_day
25
+ }
26
+ }
27
+ }
28
+ }
29
+ ' }
30
+ end
31
+
32
+ let(:event_occurrences_query) do
33
+ { query: '
34
+ {
35
+ event_occurrences {
36
+ url,
37
+ popover_url,
38
+ start,
39
+ end,
40
+ event {
41
+ id,
42
+ name,
43
+ css_class,
44
+ text_color,
45
+ background_color,
46
+ border_color,
47
+ all_day
48
+ }
49
+ }
50
+ }
51
+ ' }
52
+ end
53
+
54
+ describe 'Browsing Events' do
55
+ describe 'at /date_book/api' do
56
+ describe 'with a global query' do
57
+ before do
58
+ post '/date_book/api.json', params: event_occurrences_query
59
+ end
60
+ it_behaves_like(
61
+ 'a graphql object listing a collection of items',
62
+ EventOccurrence
63
+ )
64
+ end
65
+ describe 'with a calendar query' do
66
+ before do
67
+ post '/date_book/api.json', params: calendar_query
68
+ end
69
+ it_behaves_like(
70
+ 'a graphql object showing an item',
71
+ Calendar
72
+ )
73
+ end
74
+ end
75
+ end
76
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails_helper'
2
4
 
3
5
  module DateBook
@@ -6,8 +8,8 @@ module DateBook
6
8
 
7
9
  describe 'Routing' do
8
10
  it 'routes to #index' do
9
- expect(get: '/calendars').
10
- to route_to(controller: 'date_book/calendars', action: 'index')
11
+ expect(get: '/calendars')
12
+ .to route_to(controller: 'date_book/calendars', action: 'index')
11
13
  end
12
14
 
13
15
  it 'routes to #new' do
@@ -1,53 +1,90 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails_helper'
2
4
 
3
5
  module DateBook
4
- RSpec.describe EventsController, folder: :routing do
6
+ RSpec.describe EventsController,
7
+ folder: :routing do
5
8
  routes { DateBook::Engine.routes }
6
9
 
7
10
  describe 'Routing' do
8
11
  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')
12
+ expect(get: '/calendars/calendar-slug/events')
13
+ .to route_to(
14
+ controller: 'date_book/events',
15
+ action: 'index',
16
+ calendar_id: 'calendar-slug'
17
+ )
11
18
  end
12
19
 
13
20
  it 'routes to #new' do
14
21
  expect(get: '/calendars/calendar-slug/events/new')
15
- .to route_to('date_book/events#new', calendar_id: 'calendar-slug')
22
+ .to route_to(
23
+ 'date_book/events#new',
24
+ calendar_id: 'calendar-slug'
25
+ )
16
26
  end
17
27
 
18
28
  it 'routes to #show' do
19
29
  expect(get: '/calendars/calendar-slug/events/slug')
20
- .to route_to('date_book/events#show', id: 'slug', calendar_id: 'calendar-slug')
30
+ .to route_to(
31
+ 'date_book/events#show',
32
+ id: 'slug',
33
+ calendar_id: 'calendar-slug'
34
+ )
21
35
  end
22
36
 
23
37
  it 'routes to #popover' do
24
38
  expect(get: '/calendars/calendar-slug/events/slug/popover')
25
- .to route_to('date_book/events#popover', id: 'slug', calendar_id: 'calendar-slug')
39
+ .to route_to(
40
+ 'date_book/events#popover',
41
+ id: 'slug',
42
+ calendar_id: 'calendar-slug'
43
+ )
26
44
  end
27
45
 
28
46
  it 'routes to #edit' do
29
47
  expect(get: '/calendars/calendar-slug/events/slug/edit')
30
- .to route_to('date_book/events#edit', id: 'slug', calendar_id: 'calendar-slug')
48
+ .to route_to(
49
+ 'date_book/events#edit',
50
+ id: 'slug',
51
+ calendar_id: 'calendar-slug'
52
+ )
31
53
  end
32
54
 
33
55
  it 'routes to #create' do
34
56
  expect(post: '/calendars/calendar-slug/events')
35
- .to route_to('date_book/events#create', calendar_id: 'calendar-slug')
57
+ .to route_to(
58
+ 'date_book/events#create',
59
+ calendar_id: 'calendar-slug'
60
+ )
36
61
  end
37
62
 
38
63
  it 'routes to #update via PUT' do
39
64
  expect(put: '/calendars/calendar-slug/events/slug')
40
- .to route_to('date_book/events#update', id: 'slug', calendar_id: 'calendar-slug')
65
+ .to route_to(
66
+ 'date_book/events#update',
67
+ id: 'slug',
68
+ calendar_id: 'calendar-slug'
69
+ )
41
70
  end
42
71
 
43
72
  it 'routes to #update via PATCH' do
44
73
  expect(patch: '/calendars/calendar-slug/events/slug')
45
- .to route_to('date_book/events#update', id: 'slug', calendar_id: 'calendar-slug')
74
+ .to route_to(
75
+ 'date_book/events#update',
76
+ id: 'slug',
77
+ calendar_id: 'calendar-slug'
78
+ )
46
79
  end
47
80
 
48
81
  it 'routes to #destroy' do
49
82
  expect(delete: '/calendars/calendar-slug/events/slug')
50
- .to route_to('date_book/events#destroy', id: 'slug', calendar_id: 'calendar-slug')
83
+ .to route_to(
84
+ 'date_book/events#destroy',
85
+ id: 'slug',
86
+ calendar_id: 'calendar-slug'
87
+ )
51
88
  end
52
89
  end
53
90
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  shared_examples_for 'a successful page' do |options = {}|
2
4
  describe 'responds successfully' do
3
5
  subject { response }
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ControllerMacros
2
4
  def login_user(user)
3
5
  @request.env['devise.mapping'] = Devise.mappings[:user]
@@ -9,7 +11,7 @@ shared_context 'authentication for routes' do
9
11
  let(:warden) do
10
12
  instance_double('Warden::Proxy').tap do |warden|
11
13
  allow(warden).to receive(:authenticate?).with(scope: :user)
12
- .and_return(authenticated?)
14
+ .and_return(authenticated?)
13
15
  allow(warden).to receive(:user).with(:user).and_return(user)
14
16
  end
15
17
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.configure do |config|
2
4
  config.include FactoryGirl::Syntax::Methods
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  shared_examples_for 'a restricted page' do
2
4
  describe 'redirects to the home page' do
3
5
  subject { current_path }
@@ -65,15 +67,13 @@ shared_examples_for 'a bootstrap page '\
65
67
  )
66
68
  end
67
69
  end
68
- if options[:links]
69
- options[:links].each do |link_text|
70
- it "has a #{link_text} link" do
71
- click_link_or_button 'Menu'
72
- within find('.navbar', text: options[:text]) do
73
- click_link_or_button options[:text]
74
- within first('li.dropdown', text: options[:text]) do
75
- expect(page).to have_link(link_text)
76
- end
70
+ options[:links]&.each do |link_text|
71
+ it "has a #{link_text} link" do
72
+ click_link_or_button 'Menu'
73
+ within find('.navbar', text: options[:text]) do
74
+ click_link_or_button options[:text]
75
+ within first('li.dropdown', text: options[:text]) do
76
+ expect(page).to have_link(link_text)
77
77
  end
78
78
  end
79
79
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  shared_context 'loaded site' do
2
4
  include_context 'calendars'
3
5
  include_context 'events'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  shared_context 'calendars' do
2
4
  let(:regular_calendar) { Calendar.friendly.find('regular-calendar') }
3
5
  let(:other_calendar) { Calendar.friendly.find('other-calendar') }
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  shared_context 'events' do
2
4
  let(:monday_event) { Event.friendly.find('monday') }
3
- let(:science_fiction_club_event) { Event.friendly.find('science-fiction-club') }
5
+ let(:science_fiction_club) { Event.friendly.find('science-fiction-club') }
4
6
  let(:yesterdays_event) { Event.friendly.find('yesterday-s-event') }
5
7
  let(:tomorrows_event) { Event.friendly.find('tomorrow-s-event') }
6
8
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  shared_context 'users' do
2
4
  let(:admin_user) { User.find_by_name('Admin User') }
3
5
  let(:regular_user) { User.find_by_name('Regular User') }
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  shared_examples_for 'a Json authentication error' do
2
4
  it_behaves_like(
3
5
  'a json object with an error',
@@ -19,71 +21,18 @@ shared_examples_for 'a blank response' do
19
21
  end
20
22
  end
21
23
 
22
- shared_examples_for 'a json array' do |options = {}|
23
- describe 'displays an array in Json' do
24
- subject { JSON.parse(response.body) }
25
- it { should be_an Array }
26
- end
27
- end
28
-
29
- shared_examples_for 'a json object' do |options = {}|
30
- describe 'displays an object with information about itself' do
31
- subject { JSON.parse(response.body) }
32
- its(['title']) { should eq options[:title] }
33
- end
34
- end
35
-
36
- shared_examples_for 'a json object with a message' do |key, text|
37
- subject { JSON.parse(response.body) }
38
- its([key.to_s]) { should match(/#{text}/) }
39
- end
40
-
41
- shared_examples_for 'a json object without a message' do |key|
42
- subject { JSON.parse(response.body) }
43
- its([key.to_s]) { should be nil }
44
- end
45
-
46
- shared_examples_for 'a json object with an error' do |text|
47
- it_behaves_like 'a json object with a message', :error, text
48
- it_behaves_like 'a json object without a message', :info
49
- it_behaves_like 'a json object without a message', :notice
50
- end
51
-
52
- shared_examples_for 'a json object with a notice' do |text|
53
- it_behaves_like 'a json object with a message', :notice, text
54
- it_behaves_like 'a json object without a message', :error
55
- it_behaves_like 'a json object without a message', :info
56
- end
57
-
58
- shared_examples_for 'a json object with info' do |text|
59
- it_behaves_like 'a json object with a message', :info, text
60
- it_behaves_like 'a json object without a message', :error
61
- it_behaves_like 'a json object without a message', :notice
62
- end
63
-
64
- shared_examples_for 'a json object '\
65
- 'listing a collection of items' do |object, options = {}|
66
- options[:minimum] ||= 1
67
- options[:plural_name] ||= object.table_name.to_s
68
- objects_key = options[:plural_name].to_sym
69
- it_behaves_like 'a json array'
70
- describe "displays a list of #{objects_key}" do
71
- subject { JSON.parse(response.body) }
72
- its(:count) { should >= options[:minimum] }
73
- end
74
- end
75
-
76
- shared_examples_for 'a json object '\
77
- 'showing an item' do |object, title, options = {}|
78
- describe "displays an item" do
79
- subject { JSON.parse(response.body) }
80
- its(['title']) { should eq title }
24
+ shared_examples_for 'a graphql object '\
25
+ 'showing an item' do |object|
26
+ describe 'displays an item' do
27
+ subject { JSON.parse(response.body)['data'][object.table_name.singularize] }
28
+ it { should be_a Hash }
81
29
  end
82
30
  end
83
31
 
84
- shared_examples_for 'a json object with errors' do |error_fields|
85
- subject { JSON.parse(response.body)[:errors] }
86
- error_fields.each do |field|
87
- its([field.to_s]) { should eq "#{field.to_s.humanize} can't be blank" }
32
+ shared_examples_for 'a graphql object '\
33
+ 'listing a collection of items' do |object|
34
+ describe 'displays a collection of items' do
35
+ subject { JSON.parse(response.body)['data'][object.table_name] }
36
+ it { should be_an Array }
88
37
  end
89
38
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActiveRecord
2
4
  class Base
3
5
  mattr_accessor :shared_connection
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  def path_to_url(path)
2
4
  protocol = request.protocol
3
5
  host = request.host_with_port.sub(/:80$/, '')
@@ -17,10 +19,9 @@ def wait_until(delay = 1)
17
19
  sleep delay
18
20
  seconds_waited += 1
19
21
  end
20
- unless yield
21
- puts "Waited for #{Capybara.default_max_wait_time} seconds."
22
- puts "{#{yield}} did not become true, continuing."
23
- end
22
+ return if yield
23
+ puts "Waited for #{Capybara.default_max_wait_time} seconds."
24
+ puts "{#{yield}} did not become true, continuing."
24
25
  end
25
26
 
26
27
  def submit_via_execute(form_selector)
@@ -36,7 +37,7 @@ end
36
37
  def fill_in_wysiwyg(locator, text)
37
38
  include ActionView::Helpers::JavaScriptHelper
38
39
  locator = find_field_by_label(locator)
39
- text = text.gsub("'", "\'").gsub("\n", '\\\n')
40
+ text = text.tr("'", "\'").gsub("\n", '\\\n')
40
41
 
41
42
  # Fill the editor content
42
43
  page.execute_script <<-SCRIPT