kiteditor 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +25 -0
- data/app/controllers/mercury/images_controller.rb +5 -0
- data/app/controllers/mercury_controller.rb +34 -0
- data/app/models/mercury/image.rb +17 -0
- data/app/views/layouts/mercury.html.erb +33 -0
- data/app/views/layouts/popup.html.haml +9 -0
- data/app/views/mercury/images/_list.html.haml +22 -0
- data/app/views/mercury/images/index.html.haml +4 -0
- data/app/views/mercury/images/index.js.erb +2 -0
- data/app/views/mercury/lightviews/about.html +11 -0
- data/app/views/mercury/modals/character.html +255 -0
- data/app/views/mercury/modals/htmleditor.html +13 -0
- data/app/views/mercury/modals/link.html +94 -0
- data/app/views/mercury/modals/media.html +1 -0
- data/app/views/mercury/modals/table.html +84 -0
- data/app/views/mercury/palettes/backcolor.html +73 -0
- data/app/views/mercury/palettes/forecolor.html +73 -0
- data/app/views/mercury/panels/history.html +3 -0
- data/app/views/mercury/panels/notes.html +3 -0
- data/app/views/mercury/panels/snippets.html +12 -0
- data/app/views/mercury/selects/formatblock.html +11 -0
- data/app/views/mercury/selects/style.html +5 -0
- data/app/views/mercury/snippets/example/options.html.erb +34 -0
- data/app/views/mercury/snippets/example/preview.html.erb +1 -0
- data/config/engine.rb +44 -0
- data/db/migrate/20110526035601_create_mercury_images.rb +11 -0
- data/features/loading/loading.feature +22 -0
- data/features/loading/navigating.feature +77 -0
- data/features/loading/user_interface.feature +67 -0
- data/features/regions/editable/advanced_editing.feature +0 -0
- data/features/regions/editable/basic_editing.feature +195 -0
- data/features/regions/editable/inserting_links.feature +98 -0
- data/features/regions/editable/inserting_media.feature +110 -0
- data/features/regions/editable/inserting_snippets.feature +102 -0
- data/features/regions/editable/inserting_special_characters.feature +24 -0
- data/features/regions/editable/inserting_tables.feature +109 -0
- data/features/regions/editable/pasting.feature +0 -0
- data/features/regions/editable/uploading_images.feature +0 -0
- data/features/regions/markupable/advanced_editing.feature +0 -0
- data/features/regions/markupable/basic_editing.feature +0 -0
- data/features/regions/markupable/inserting_links.feature +0 -0
- data/features/regions/markupable/inserting_media.feature +0 -0
- data/features/regions/markupable/inserting_snippets.feature +0 -0
- data/features/regions/markupable/inserting_special_characters.feature +0 -0
- data/features/regions/markupable/inserting_tables.feature +0 -0
- data/features/regions/markupable/uploading_images.feature +0 -0
- data/features/regions/snippetable/advanced_editing.feature +0 -0
- data/features/regions/snippetable/basic_editing.feature +0 -0
- data/features/regions/snippetable/inserting_snippets.feature +0 -0
- data/features/saving/saving.feature +33 -0
- data/features/step_definitions/debug_steps.rb +14 -0
- data/features/step_definitions/mercury_steps.rb +438 -0
- data/features/step_definitions/web_steps.rb +211 -0
- data/features/support/env.rb +46 -0
- data/features/support/mercury_contents.rb +25 -0
- data/features/support/mercury_selectors.rb +148 -0
- data/features/support/paths.rb +38 -0
- data/features/support/selectors.rb +44 -0
- data/lib/generators/mercury/install/install_generator.rb +49 -0
- data/lib/generators/mercury/install/templates/mongoid_paperclip_image.rb +17 -0
- data/lib/mercury/authentication.rb +8 -0
- data/lib/mercury-rails.rb +3 -0
- data/spec/javascripts/mercury/dialog_spec.js.coffee +281 -0
- data/spec/javascripts/mercury/dialogs/backcolor_spec.js.coffee +37 -0
- data/spec/javascripts/mercury/dialogs/forecolor_spec.js.coffee +37 -0
- data/spec/javascripts/mercury/dialogs/formatblock_spec.js.coffee +25 -0
- data/spec/javascripts/mercury/dialogs/snippetpanel_spec.js.coffee +30 -0
- data/spec/javascripts/mercury/dialogs/style_spec.js.coffee +25 -0
- data/spec/javascripts/mercury/history_buffer_spec.js.coffee +76 -0
- data/spec/javascripts/mercury/lightview_spec.js.coffee +497 -0
- data/spec/javascripts/mercury/mercury_spec.js.coffee +132 -0
- data/spec/javascripts/mercury/modal_spec.js.coffee +504 -0
- data/spec/javascripts/mercury/modals/htmleditor_spec.js.coffee +30 -0
- data/spec/javascripts/mercury/modals/insertcharacter_spec.js.coffee +29 -0
- data/spec/javascripts/mercury/modals/insertlink_spec.js.coffee +220 -0
- data/spec/javascripts/mercury/modals/insertmedia_spec.js.coffee +167 -0
- data/spec/javascripts/mercury/modals/insertsnippet_spec.js.coffee +52 -0
- data/spec/javascripts/mercury/modals/inserttable_spec.js.coffee +160 -0
- data/spec/javascripts/mercury/native_extensions_spec.js.coffee +60 -0
- data/spec/javascripts/mercury/page_editor_spec.js.coffee +750 -0
- data/spec/javascripts/mercury/palette_spec.js.coffee +49 -0
- data/spec/javascripts/mercury/panel_spec.js.coffee +185 -0
- data/spec/javascripts/mercury/region_spec.js.coffee +298 -0
- data/spec/javascripts/mercury/regions/editable_spec.js.coffee +561 -0
- data/spec/javascripts/mercury/regions/markupable_spec.js.coffee +367 -0
- data/spec/javascripts/mercury/regions/snippetable_spec.js.coffee +370 -0
- data/spec/javascripts/mercury/select_spec.js.coffee +49 -0
- data/spec/javascripts/mercury/snippet_spec.js.coffee +245 -0
- data/spec/javascripts/mercury/snippet_toolbar_spec.js.coffee +184 -0
- data/spec/javascripts/mercury/statusbar_spec.js.coffee +150 -0
- data/spec/javascripts/mercury/table_editor_spec.js.coffee +194 -0
- data/spec/javascripts/mercury/toolbar.button_group_spec.js.coffee +90 -0
- data/spec/javascripts/mercury/toolbar.button_spec.js.coffee +360 -0
- data/spec/javascripts/mercury/toolbar.expander_spec.js.coffee +118 -0
- data/spec/javascripts/mercury/toolbar_spec.js.coffee +222 -0
- data/spec/javascripts/mercury/tooltip_spec.js.coffee +186 -0
- data/spec/javascripts/mercury/uploader_spec.js.coffee +514 -0
- data/spec/javascripts/spec_helper.js +513 -0
- data/spec/javascripts/templates/mercury/dialog.html +2 -0
- data/spec/javascripts/templates/mercury/dialogs/backcolor.html +5 -0
- data/spec/javascripts/templates/mercury/dialogs/forecolor.html +5 -0
- data/spec/javascripts/templates/mercury/dialogs/formatblock.html +3 -0
- data/spec/javascripts/templates/mercury/dialogs/snippetpanel.html +16 -0
- data/spec/javascripts/templates/mercury/dialogs/style.html +3 -0
- data/spec/javascripts/templates/mercury/lightview.html +13 -0
- data/spec/javascripts/templates/mercury/modal.html +13 -0
- data/spec/javascripts/templates/mercury/modals/htmleditor.html +5 -0
- data/spec/javascripts/templates/mercury/modals/insertcharacter.html +5 -0
- data/spec/javascripts/templates/mercury/modals/insertlink.html +30 -0
- data/spec/javascripts/templates/mercury/modals/insertmedia.html +35 -0
- data/spec/javascripts/templates/mercury/modals/insertsnippet.html +6 -0
- data/spec/javascripts/templates/mercury/modals/inserttable.html +27 -0
- data/spec/javascripts/templates/mercury/page_editor.html +35 -0
- data/spec/javascripts/templates/mercury/palette.html +16 -0
- data/spec/javascripts/templates/mercury/panel.html +16 -0
- data/spec/javascripts/templates/mercury/region.html +2 -0
- data/spec/javascripts/templates/mercury/regions/editable.html +3 -0
- data/spec/javascripts/templates/mercury/regions/snippetable.html +4 -0
- data/spec/javascripts/templates/mercury/select.html +16 -0
- data/spec/javascripts/templates/mercury/snippet.html +1 -0
- data/spec/javascripts/templates/mercury/snippet_toolbar.html +16 -0
- data/spec/javascripts/templates/mercury/statusbar.html +8 -0
- data/spec/javascripts/templates/mercury/table_editor.html +65 -0
- data/spec/javascripts/templates/mercury/toolbar.button.html +64 -0
- data/spec/javascripts/templates/mercury/toolbar.button_group.html +9 -0
- data/spec/javascripts/templates/mercury/toolbar.expander.html +18 -0
- data/spec/javascripts/templates/mercury/toolbar.html +11 -0
- data/spec/javascripts/templates/mercury/tooltip.html +12 -0
- data/spec/javascripts/templates/mercury/uploader.html +11 -0
- data/vendor/assets/images/mercury/button.png +0 -0
- data/vendor/assets/images/mercury/close.png +0 -0
- data/vendor/assets/images/mercury/default-snippet.png +0 -0
- data/vendor/assets/images/mercury/loading-dark.gif +0 -0
- data/vendor/assets/images/mercury/loading-light.gif +0 -0
- data/vendor/assets/images/mercury/missing-image.png +0 -0
- data/vendor/assets/images/mercury/search-icon.png +0 -0
- data/vendor/assets/images/mercury/temp-logo.png +0 -0
- data/vendor/assets/images/mercury/toolbar/editable/buttons.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/_expander.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/_pressed.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/historypanel.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/insertcharacter.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/insertlink.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/insertmedia.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/inserttable.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/inspectorpanel.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/notespanel.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/preview.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/redo.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/save.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/snippetpanel.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/undo.png +0 -0
- data/vendor/assets/images/mercury/toolbar/snippetable/buttons.png +0 -0
- data/vendor/assets/javascripts/mercury/dependencies/jquery-1.7.js +9300 -0
- data/vendor/assets/javascripts/mercury/dependencies/jquery-ui-1.8.13.custom.js +1328 -0
- data/vendor/assets/javascripts/mercury/dependencies/jquery-ui-1.8.18.custom.min.js +356 -0
- data/vendor/assets/javascripts/mercury/dependencies/jquery-ui.1.8.13.custom.min.js +356 -0
- data/vendor/assets/javascripts/mercury/dependencies/jquery.additions.js +206 -0
- data/vendor/assets/javascripts/mercury/dependencies/jquery.htmlClean.js +527 -0
- data/vendor/assets/javascripts/mercury/dependencies/liquidmetal.js +88 -0
- data/vendor/assets/javascripts/mercury/dependencies/showdown.js +1340 -0
- data/vendor/assets/javascripts/mercury/dialog.js.coffee +159 -0
- data/vendor/assets/javascripts/mercury/dialogs/backcolor.js.coffee +6 -0
- data/vendor/assets/javascripts/mercury/dialogs/forecolor.js.coffee +6 -0
- data/vendor/assets/javascripts/mercury/dialogs/formatblock.js.coffee +4 -0
- data/vendor/assets/javascripts/mercury/dialogs/snippetpanel.js.coffee +10 -0
- data/vendor/assets/javascripts/mercury/dialogs/style.js.coffee +4 -0
- data/vendor/assets/javascripts/mercury/finalize.js.coffee +3 -0
- data/vendor/assets/javascripts/mercury/history_buffer.js.coffee +30 -0
- data/vendor/assets/javascripts/mercury/lightview.js.coffee +205 -0
- data/vendor/assets/javascripts/mercury/locales/da.locale.js.coffee +0 -0
- data/vendor/assets/javascripts/mercury/locales/de.locale.js.coffee +206 -0
- data/vendor/assets/javascripts/mercury/locales/es.locale.js.coffee +211 -0
- data/vendor/assets/javascripts/mercury/locales/example.local.js.coffee +211 -0
- data/vendor/assets/javascripts/mercury/locales/fr.locale.js.coffee +211 -0
- data/vendor/assets/javascripts/mercury/locales/it.locale.js.coffee +208 -0
- data/vendor/assets/javascripts/mercury/locales/ko.local.js.coffee +206 -0
- data/vendor/assets/javascripts/mercury/locales/nl.locale.js.coffee +206 -0
- data/vendor/assets/javascripts/mercury/locales/pt.locale.js.coffee +211 -0
- data/vendor/assets/javascripts/mercury/locales/sv.local.js.coffee +209 -0
- data/vendor/assets/javascripts/mercury/locales/swedish_chef.locale.js.coffee +213 -0
- data/vendor/assets/javascripts/mercury/mercury.js.coffee +109 -0
- data/vendor/assets/javascripts/mercury/modal.js.coffee +204 -0
- data/vendor/assets/javascripts/mercury/modals/htmleditor.js.coffee +11 -0
- data/vendor/assets/javascripts/mercury/modals/insertcharacter.js.coffee +4 -0
- data/vendor/assets/javascripts/mercury/modals/insertlink.js.coffee +95 -0
- data/vendor/assets/javascripts/mercury/modals/insertmedia.js.coffee +107 -0
- data/vendor/assets/javascripts/mercury/modals/insertsnippet.js.coffee +12 -0
- data/vendor/assets/javascripts/mercury/modals/inserttable.js.coffee +54 -0
- data/vendor/assets/javascripts/mercury/native_extensions.js.coffee +55 -0
- data/vendor/assets/javascripts/mercury/page_editor.js.coffee +241 -0
- data/vendor/assets/javascripts/mercury/palette.js.coffee +29 -0
- data/vendor/assets/javascripts/mercury/panel.js.coffee +115 -0
- data/vendor/assets/javascripts/mercury/plugins/save_as_xml/mercury/page_editor.js.coffee +28 -0
- data/vendor/assets/javascripts/mercury/plugins/save_as_xml/plugin.js +9 -0
- data/vendor/assets/javascripts/mercury/region.js.coffee +107 -0
- data/vendor/assets/javascripts/mercury/regions/editable.js.coffee +600 -0
- data/vendor/assets/javascripts/mercury/regions/markupable.js.coffee +398 -0
- data/vendor/assets/javascripts/mercury/regions/simple.js.coffee +339 -0
- data/vendor/assets/javascripts/mercury/regions/snippetable.js.coffee +124 -0
- data/vendor/assets/javascripts/mercury/select.js.coffee +44 -0
- data/vendor/assets/javascripts/mercury/snippet.js.coffee +104 -0
- data/vendor/assets/javascripts/mercury/snippet_toolbar.js.coffee +72 -0
- data/vendor/assets/javascripts/mercury/statusbar.js.coffee +51 -0
- data/vendor/assets/javascripts/mercury/support/history.js +1 -0
- data/vendor/assets/javascripts/mercury/table_editor.js.coffee +265 -0
- data/vendor/assets/javascripts/mercury/toolbar.button.js.coffee +173 -0
- data/vendor/assets/javascripts/mercury/toolbar.button_group.js.coffee +42 -0
- data/vendor/assets/javascripts/mercury/toolbar.expander.js.coffee +56 -0
- data/vendor/assets/javascripts/mercury/toolbar.js.coffee +86 -0
- data/vendor/assets/javascripts/mercury/tooltip.js.coffee +74 -0
- data/vendor/assets/javascripts/mercury/uploader.js.coffee +227 -0
- data/vendor/assets/javascripts/mercury.js +479 -0
- data/vendor/assets/javascripts/mercury_loader.js +193 -0
- data/vendor/assets/javascripts/mercury_overrides.js +6 -0
- data/vendor/assets/javascripts/popup.js +8 -0
- data/vendor/assets/stylesheets/mercury/all_images.css.erb +89 -0
- data/vendor/assets/stylesheets/mercury/dialog.css +208 -0
- data/vendor/assets/stylesheets/mercury/lightview.css +151 -0
- data/vendor/assets/stylesheets/mercury/mercury.css +151 -0
- data/vendor/assets/stylesheets/mercury/modal.css +183 -0
- data/vendor/assets/stylesheets/mercury/statusbar.css +32 -0
- data/vendor/assets/stylesheets/mercury/toolbar.css +304 -0
- data/vendor/assets/stylesheets/mercury/tooltip.css +26 -0
- data/vendor/assets/stylesheets/mercury/uploader.css +111 -0
- data/vendor/assets/stylesheets/mercury.css +28 -0
- data/vendor/assets/stylesheets/mercury_overrides.css +17 -0
- data/vendor/assets/stylesheets/popup.css.erb +37 -0
- metadata +634 -0
@@ -0,0 +1,211 @@
|
|
1
|
+
# TL;DR: YOU SHOULD DELETE THIS FILE
|
2
|
+
#
|
3
|
+
# This file was generated by Cucumber-Rails and is only here to get you a head start
|
4
|
+
# These step definitions are thin wrappers around the Capybara/Webrat API that lets you
|
5
|
+
# visit pages, interact with widgets and make assertions about page content.
|
6
|
+
#
|
7
|
+
# If you use these step definitions as basis for your features you will quickly end up
|
8
|
+
# with features that are:
|
9
|
+
#
|
10
|
+
# * Hard to maintain
|
11
|
+
# * Verbose to read
|
12
|
+
#
|
13
|
+
# A much better approach is to write your own higher level step definitions, following
|
14
|
+
# the advice in the following blog posts:
|
15
|
+
#
|
16
|
+
# * http://benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories.html
|
17
|
+
# * http://dannorth.net/2011/01/31/whose-domain-is-it-anyway/
|
18
|
+
# * http://elabs.se/blog/15-you-re-cuking-it-wrong
|
19
|
+
#
|
20
|
+
|
21
|
+
|
22
|
+
require 'uri'
|
23
|
+
require 'cgi'
|
24
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
25
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
|
26
|
+
|
27
|
+
module WithinHelpers
|
28
|
+
def with_scope(locator)
|
29
|
+
locator ? within(*selector_for(locator)) { yield } : yield
|
30
|
+
end
|
31
|
+
end
|
32
|
+
World(WithinHelpers)
|
33
|
+
|
34
|
+
# Single-line step scoper
|
35
|
+
When /^(.*) within ([^:]+)$/ do |s, parent|
|
36
|
+
with_scope(parent) { step(s) }
|
37
|
+
end
|
38
|
+
|
39
|
+
# Multi-line step scoper
|
40
|
+
When /^(.*) within ([^:]+):$/ do |s, parent, table_or_string|
|
41
|
+
with_scope(parent) { step "#{s}:", table_or_string }
|
42
|
+
end
|
43
|
+
|
44
|
+
Given /^(?:|I )am on (.+)$/ do |page_name|
|
45
|
+
visit path_to(page_name)
|
46
|
+
end
|
47
|
+
|
48
|
+
When /^(?:|I )go to (.+)$/ do |page_name|
|
49
|
+
visit path_to(page_name)
|
50
|
+
end
|
51
|
+
|
52
|
+
When /^(?:|I )press "([^"]*)"$/ do |button|
|
53
|
+
click_button(button)
|
54
|
+
end
|
55
|
+
|
56
|
+
When /^(?:|I )follow "([^"]*)"$/ do |link|
|
57
|
+
click_link(link)
|
58
|
+
end
|
59
|
+
|
60
|
+
When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
|
61
|
+
fill_in(field, :with => value)
|
62
|
+
end
|
63
|
+
|
64
|
+
When /^(?:|I )fill in "([^"]*)" for "([^"]*)"$/ do |value, field|
|
65
|
+
fill_in(field, :with => value)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Use this to fill in an entire form with data from a table. Example:
|
69
|
+
#
|
70
|
+
# When I fill in the following:
|
71
|
+
# | Account Number | 5002 |
|
72
|
+
# | Expiry date | 2009-11-01 |
|
73
|
+
# | Note | Nice guy |
|
74
|
+
# | Wants Email? | |
|
75
|
+
#
|
76
|
+
# TODO: Add support for checkbox, select og option
|
77
|
+
# based on naming conventions.
|
78
|
+
#
|
79
|
+
When /^(?:|I )fill in the following:$/ do |fields|
|
80
|
+
fields.rows_hash.each do |name, value|
|
81
|
+
step %{I fill in "#{name}" with "#{value}"}
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
|
86
|
+
select(value, :from => field)
|
87
|
+
end
|
88
|
+
|
89
|
+
When /^(?:|I )check "([^"]*)"$/ do |field|
|
90
|
+
check(field)
|
91
|
+
end
|
92
|
+
|
93
|
+
When /^(?:|I )uncheck "([^"]*)"$/ do |field|
|
94
|
+
uncheck(field)
|
95
|
+
end
|
96
|
+
|
97
|
+
When /^(?:|I )choose "([^"]*)"$/ do |field|
|
98
|
+
choose(field)
|
99
|
+
end
|
100
|
+
|
101
|
+
When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
|
102
|
+
attach_file(field, File.expand_path(path))
|
103
|
+
end
|
104
|
+
|
105
|
+
Then /^(?:|I )should see "([^"]*)"$/ do |text|
|
106
|
+
if page.respond_to? :should
|
107
|
+
page.should have_content(text)
|
108
|
+
else
|
109
|
+
assert page.has_content?(text)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
|
114
|
+
regexp = Regexp.new(regexp)
|
115
|
+
|
116
|
+
if page.respond_to? :should
|
117
|
+
page.should have_xpath('//*', :text => regexp)
|
118
|
+
else
|
119
|
+
assert page.has_xpath?('//*', :text => regexp)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
Then /^(?:|I )should not see "([^"]*)"$/ do |text|
|
124
|
+
if page.respond_to? :should
|
125
|
+
page.should have_no_content(text)
|
126
|
+
else
|
127
|
+
assert page.has_no_content?(text)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
|
132
|
+
regexp = Regexp.new(regexp)
|
133
|
+
|
134
|
+
if page.respond_to? :should
|
135
|
+
page.should have_no_xpath('//*', :text => regexp)
|
136
|
+
else
|
137
|
+
assert page.has_no_xpath?('//*', :text => regexp)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
Then /^the "([^"]*)" field(?: within (.*))? should contain "([^"]*)"$/ do |field, parent, value|
|
142
|
+
with_scope(parent) do
|
143
|
+
field = find_field(field)
|
144
|
+
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
145
|
+
if field_value.respond_to? :should
|
146
|
+
field_value.should =~ /#{value}/
|
147
|
+
else
|
148
|
+
assert_match(/#{value}/, field_value)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
Then /^the "([^"]*)" field(?: within (.*))? should not contain "([^"]*)"$/ do |field, parent, value|
|
154
|
+
with_scope(parent) do
|
155
|
+
field = find_field(field)
|
156
|
+
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
157
|
+
if field_value.respond_to? :should_not
|
158
|
+
field_value.should_not =~ /#{value}/
|
159
|
+
else
|
160
|
+
assert_no_match(/#{value}/, field_value)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
Then /^the "([^"]*)" checkbox(?: within (.*))? should be checked$/ do |label, parent|
|
166
|
+
with_scope(parent) do
|
167
|
+
field_checked = find_field(label)['checked']
|
168
|
+
if field_checked.respond_to? :should
|
169
|
+
field_checked.should be_true
|
170
|
+
else
|
171
|
+
assert field_checked
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label, parent|
|
177
|
+
with_scope(parent) do
|
178
|
+
field_checked = find_field(label)['checked']
|
179
|
+
if field_checked.respond_to? :should
|
180
|
+
field_checked.should be_false
|
181
|
+
else
|
182
|
+
assert !field_checked
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
Then /^(?:|I )should be on (.+)$/ do |page_name|
|
188
|
+
current_path = URI.parse(current_url).path
|
189
|
+
if current_path.respond_to? :should
|
190
|
+
current_path.should == path_to(page_name)
|
191
|
+
else
|
192
|
+
assert_equal path_to(page_name), current_path
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
|
197
|
+
query = URI.parse(current_url).query
|
198
|
+
actual_params = query ? CGI.parse(query) : {}
|
199
|
+
expected_params = {}
|
200
|
+
expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
|
201
|
+
|
202
|
+
if actual_params.respond_to? :should
|
203
|
+
actual_params.should == expected_params
|
204
|
+
else
|
205
|
+
assert_equal expected_params, actual_params
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
Then /^show me the page$/ do
|
210
|
+
save_and_open_page
|
211
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
|
2
|
+
# It is recommended to regenerate this file in the future when you upgrade to a
|
3
|
+
# newer version of cucumber-rails. Consider adding your own code to a new file
|
4
|
+
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
5
|
+
# files.
|
6
|
+
|
7
|
+
require 'cucumber/rails'
|
8
|
+
require 'capybara/firebug'
|
9
|
+
|
10
|
+
# You can enable firebug in your tests by tagging them @firebug.
|
11
|
+
# To change the version of firebug use the FIREBUG_VERSION environment variable.
|
12
|
+
# For firefox 4+ use 1.7.0
|
13
|
+
# For firefox 3 use 1.6.2
|
14
|
+
Selenium::WebDriver::Firefox::Profile.firebug_version = ENV['FIREBUG_VERSION'] || '1.8.3'
|
15
|
+
|
16
|
+
# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
|
17
|
+
# order to ease the transition to Capybara we set the default here. If you'd
|
18
|
+
# prefer to use XPath just remove this line and adjust any selectors in your
|
19
|
+
# steps to use the XPath syntax.
|
20
|
+
Capybara.default_selector = :css
|
21
|
+
Capybara.ignore_hidden_elements = true
|
22
|
+
|
23
|
+
# By default, any exception happening in your Rails application will bubble up
|
24
|
+
# to Cucumber so that your scenario will fail. This is a different from how
|
25
|
+
# your application behaves in the production environment, where an error page will
|
26
|
+
# be rendered instead.
|
27
|
+
#
|
28
|
+
# Sometimes we want to override this default behaviour and allow Rails to rescue
|
29
|
+
# exceptions and display an error page (just like when the app is running in production).
|
30
|
+
# Typical scenarios where you want to do this is when you test your error pages.
|
31
|
+
# There are two ways to allow Rails to rescue exceptions:
|
32
|
+
#
|
33
|
+
# 1) Tag your scenario (or feature) with @allow-rescue
|
34
|
+
#
|
35
|
+
# 2) Set the value below to true. Beware that doing this globally is not
|
36
|
+
# recommended as it will mask a lot of errors for you!
|
37
|
+
#
|
38
|
+
ActionController::Base.allow_rescue = false
|
39
|
+
|
40
|
+
# Remove/comment out the lines below if your app doesn't have a database.
|
41
|
+
# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
|
42
|
+
begin
|
43
|
+
DatabaseCleaner.strategy = :transaction
|
44
|
+
rescue NameError
|
45
|
+
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
|
46
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module MercuryContentsHelpers
|
2
|
+
def contents_for(name)
|
3
|
+
case name
|
4
|
+
when 'simple content' then "this is <span>simple</span> <b>content</b>"
|
5
|
+
when 'justifiable content' then "<div>first line</div><br/>this is <span>justifiable</span> <b>content</b>"
|
6
|
+
when 'wrapped content' then "<span>this <a href='http://google.com'>is</a> <i>wrapped</i> <b>content</b></span>"
|
7
|
+
when 'an image' then "this is <img src='/assets/mercury/temp-logo.png'> <b>content</b>"
|
8
|
+
when 'a table' then "this is a <table><tr><td><span>1</span></td><td><span>2</span></td></tr><tr><td><span>3</span></td><td><span>4</span></td></tr></table> <b>content</b>"
|
9
|
+
when 'the snippet', 'that snippet' then "<div class='mercury-snippet' data-snippet='#{@snippet_id || 'snippet_42'}'>#{@snippet_id || 'snippet_42'}</div> <b>content</b>"
|
10
|
+
|
11
|
+
else name
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def parse_snippet_options_from(options_string)
|
16
|
+
json = []
|
17
|
+
options_string.scan(/(?:,\s)?([^:]*): ("[^"]*")/).each do |pair|
|
18
|
+
json << %Q{'options[#{pair[0]}]': #{pair[1]}}
|
19
|
+
end
|
20
|
+
|
21
|
+
"{#{json.join(', ')}}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
World(MercuryContentsHelpers)
|
@@ -0,0 +1,148 @@
|
|
1
|
+
module MercurySelectorsHelpers
|
2
|
+
|
3
|
+
def mercury_selector_for(locator)
|
4
|
+
case locator
|
5
|
+
|
6
|
+
# toolbar selectors
|
7
|
+
when 'the toolbar' then '.mercury-toolbar-container'
|
8
|
+
|
9
|
+
when /^the "(.*?)" button$/
|
10
|
+
".mercury-primary-toolbar .mercury-#{mercury_button_mapping_for($1)}-button"
|
11
|
+
|
12
|
+
when /^the (.*?) editor (button|dropdown|palette)$/
|
13
|
+
".mercury-editable-toolbar .mercury-#{mercury_button_mapping_for($1)}-button"
|
14
|
+
|
15
|
+
when /^the (.*?) toolbar button$/
|
16
|
+
".mercury-snippet-toolbar .mercury-#{mercury_button_mapping_for($1)}-button"
|
17
|
+
|
18
|
+
when /^the (.*?) select$/
|
19
|
+
".mercury-#{mercury_button_mapping_for($1)}-select"
|
20
|
+
|
21
|
+
when /^the (.*?) palette$/
|
22
|
+
".mercury-#{mercury_button_mapping_for($1)}-palette"
|
23
|
+
|
24
|
+
# palette / select dropdown
|
25
|
+
when 'the color red' then '.mercury-palette .picker:nth-child(22n)'
|
26
|
+
|
27
|
+
when 'the red style' then '.mercury-select-options .red'
|
28
|
+
when 'the heading 2 block' then '.mercury-select-options h2'
|
29
|
+
|
30
|
+
# statusbar selectors
|
31
|
+
when 'the statusbar' then '.mercury-statusbar'
|
32
|
+
when 'the about the editor link' then 'a.mercury-statusbar-about'
|
33
|
+
|
34
|
+
# panel selectors
|
35
|
+
when 'the panel', /^the (.*?) panel$/ then '.mercury-panel'
|
36
|
+
|
37
|
+
# modal window selectors
|
38
|
+
when 'the modal', 'the modal window', /^the (.*?) modal$/ then '.mercury-modal'
|
39
|
+
when 'the modal overlay' then '.mercury-modal-overlay'
|
40
|
+
when 'the modal title' then '.mercury-modal h1.mercury-modal-title'
|
41
|
+
when 'the modal close button' then '.mercury-modal h1.mercury-modal-title a'
|
42
|
+
|
43
|
+
when 'the sweet snowman' then '.mercury-modal .character:nth-child(247n)'
|
44
|
+
|
45
|
+
when 'the first cell in the first row' then '.mercury-modal tr:nth-child(1n) td:nth-child(1n)'
|
46
|
+
when 'the third cell in the first row' then '.mercury-modal tr:nth-child(1n) td:nth-child(3n)'
|
47
|
+
when 'the forth cell in the first row' then '.mercury-modal tr:nth-child(1n) td:nth-child(4n)'
|
48
|
+
when 'the second cell in the second row' then '.mercury-modal tr:nth-child(2n) td:nth-child(2n)'
|
49
|
+
when 'the forth cell in the second row' then '.mercury-modal tr:nth-child(2n) td:nth-child(4n)'
|
50
|
+
|
51
|
+
when 'a selected cell' then '.mercury-modal td.selected'
|
52
|
+
|
53
|
+
# lightview selectors
|
54
|
+
when 'the lightview', 'the lightview window', /^the (.*?) lightview$/ then '.mercury-lightview'
|
55
|
+
when 'the lightview overlay' then '.mercury-lightview-overlay'
|
56
|
+
when 'the lightview title' then '.mercury-lightview h1.mercury-lightview-title'
|
57
|
+
when 'the lightview close button' then '.mercury-lightview h1.mercury-lightview-title a'
|
58
|
+
|
59
|
+
# snippet selectors
|
60
|
+
when 'the snippet toolbar' then '.mercury-snippet-toolbar'
|
61
|
+
when 'the snippet', 'that snippet' then "div[data-snippet=#{@snippet_id || 'snippet_42'}]"
|
62
|
+
|
63
|
+
# other selectors
|
64
|
+
when 'the first image' then 'img:nth-child(1n)'
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def mercury_button_mapping_for(locator)
|
70
|
+
case locator.downcase
|
71
|
+
|
72
|
+
# primary toolbar
|
73
|
+
when 'save' then 'save'
|
74
|
+
when 'preview' then 'preview'
|
75
|
+
when 'undo' then 'undo'
|
76
|
+
when 'redo' then 'redo'
|
77
|
+
when 'link', 'insert link' then 'insertLink'
|
78
|
+
when 'media', 'insert media' then 'insertMedia'
|
79
|
+
when 'table', 'insert table' then 'insertTable'
|
80
|
+
when 'character', 'insert character' then 'insertCharacter'
|
81
|
+
when 'snippet', 'insert snippet' then 'snippetPanel'
|
82
|
+
when 'history', 'view history' then 'historyPanel'
|
83
|
+
when 'notes', 'view notes' then 'notesPanel'
|
84
|
+
|
85
|
+
# editor toolbar
|
86
|
+
when 'predefined styles' then 'style'
|
87
|
+
when 'block format' then 'formatblock'
|
88
|
+
when 'backcolor', 'background color' then 'backColor'
|
89
|
+
when 'forecolor', 'foreground color' then 'foreColor'
|
90
|
+
when 'italicize' then 'italic'
|
91
|
+
when 'overline' then 'overline'
|
92
|
+
when 'strike through' then 'strikethrough'
|
93
|
+
when 'underline' then 'underline'
|
94
|
+
when 'subscript' then 'subscript'
|
95
|
+
when 'superscript' then 'superscript'
|
96
|
+
when 'justify left', 'left justify' then 'justifyLeft'
|
97
|
+
when 'justify center', 'center justify' then 'justifyCenter'
|
98
|
+
when 'justify right', 'right justify' then 'justifyRight'
|
99
|
+
when 'justify full', 'full justification' then 'justifyFull'
|
100
|
+
when 'unordered list', 'insert unordered list' then 'insertUnorderedList'
|
101
|
+
when 'ordered list', 'insert ordered list' then 'insertOrderedList'
|
102
|
+
when 'hr', 'insert hr', 'horizontal rule', 'insert horizontal rule' then 'horizontalRule'
|
103
|
+
when 'clean formatting', 'remove formatting' then 'removeFormatting'
|
104
|
+
when 'html editor' then 'htmlEditor'
|
105
|
+
|
106
|
+
# table context buttons
|
107
|
+
when 'add row before', 'insert row before' then 'insertRowBefore'
|
108
|
+
when 'add row after', 'insert row after' then 'insertRowAfter'
|
109
|
+
when 'delete row' then 'deleteRow'
|
110
|
+
when 'add column before', 'insert column before' then 'insertColumnBefore'
|
111
|
+
when 'add column after', 'insert column after' then 'insertColumnAfter'
|
112
|
+
when 'delete column' then 'deleteColumn'
|
113
|
+
when 'increase colspan' then 'increaseColspan'
|
114
|
+
when 'decrease colspan' then 'decreaseColspan'
|
115
|
+
when 'increase rowspan' then 'increaseRowspan'
|
116
|
+
when 'decrease rowspan' then 'decreaseRowspan'
|
117
|
+
|
118
|
+
# snippet toolbar
|
119
|
+
when 'edit snippet settings', 'edit snippet' then 'editSnippet'
|
120
|
+
when 'remove snippet' then 'removeSnippet'
|
121
|
+
|
122
|
+
else locator
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def region_selector_for(locator)
|
127
|
+
case locator.downcase
|
128
|
+
|
129
|
+
when 'the first editable region', 'the editable region' then '#editable1'
|
130
|
+
when 'the first markupable region', 'the markupable region', 'the markdown region' then '#markupable1'
|
131
|
+
when 'the first snippetable region', 'the first snippet region', 'the snippetable region', 'the snippet region' then '#snippetable1'
|
132
|
+
|
133
|
+
else locator
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def snippet_name_for(locator)
|
138
|
+
case locator.downcase
|
139
|
+
|
140
|
+
when 'the example snippet' then 'example'
|
141
|
+
|
142
|
+
else locator
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
147
|
+
|
148
|
+
World(MercurySelectorsHelpers)
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module NavigationHelpers
|
2
|
+
# Maps a name to a path. Used by the
|
3
|
+
#
|
4
|
+
# When /^I go to (.+)$/ do |page_name|
|
5
|
+
#
|
6
|
+
# step definition in web_steps.rb
|
7
|
+
#
|
8
|
+
def path_to(page_name)
|
9
|
+
case page_name
|
10
|
+
|
11
|
+
when 'an editable page', 'the editable page' then '/editor'
|
12
|
+
when 'the test page' then '/mercury/test_page'
|
13
|
+
|
14
|
+
|
15
|
+
when /the root( page)?/ then '/'
|
16
|
+
when /the home\s?page/ then '/'
|
17
|
+
when /the url: "(.*)"/ then url_for($1)
|
18
|
+
|
19
|
+
# Add more mappings here.
|
20
|
+
# Here is an example that pulls values out of the Regexp:
|
21
|
+
#
|
22
|
+
# when /^(.*)'s profile page$/i
|
23
|
+
# user_profile_path(User.find_by_login($1))
|
24
|
+
|
25
|
+
else
|
26
|
+
begin
|
27
|
+
page_name =~ /the (.*) page/
|
28
|
+
path_components = $1.split(/\s+/)
|
29
|
+
self.send(path_components.push('path').join('_').to_sym)
|
30
|
+
rescue Object => e
|
31
|
+
raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
|
32
|
+
"Now, go and add a mapping in #{__FILE__}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
World(NavigationHelpers)
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module HtmlSelectorsHelpers
|
2
|
+
# Maps a name to a selector. Used primarily by the
|
3
|
+
#
|
4
|
+
# When /^(.+) within (.+)$/ do |step, scope|
|
5
|
+
#
|
6
|
+
# step definitions in web_steps.rb
|
7
|
+
#
|
8
|
+
def selector_for(locator)
|
9
|
+
|
10
|
+
# add in for mercury support
|
11
|
+
result = mercury_selector_for(locator)
|
12
|
+
return result if result.present?
|
13
|
+
|
14
|
+
case locator
|
15
|
+
|
16
|
+
when /the page/
|
17
|
+
"html > body"
|
18
|
+
|
19
|
+
# Add more mappings here.
|
20
|
+
# Here is an example that pulls values out of the Regexp:
|
21
|
+
#
|
22
|
+
# when /the (notice|error|info) flash/
|
23
|
+
# ".flash.#{$1}"
|
24
|
+
|
25
|
+
# You can also return an array to use a different selector
|
26
|
+
# type, like:
|
27
|
+
#
|
28
|
+
# when /the header/
|
29
|
+
# [:xpath, "//header"]
|
30
|
+
|
31
|
+
# This allows you to provide a quoted selector as the scope
|
32
|
+
# for "within" steps as was previously the default for the
|
33
|
+
# web steps:
|
34
|
+
when /"(.+)"/
|
35
|
+
$1
|
36
|
+
|
37
|
+
else
|
38
|
+
raise "Can't find mapping from \"#{locator}\" to a selector.\n" +
|
39
|
+
"Now, go and add a mapping in #{__FILE__}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
World(HtmlSelectorsHelpers)
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Mercury
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
source_root Mercury::Engine.root
|
5
|
+
|
6
|
+
desc "Installs Mercury into your application by copying the configuration file."
|
7
|
+
|
8
|
+
class_option :orm, :default => 'active_record', :banner => 'mongoid',
|
9
|
+
:desc => 'ORM for required models -- active_record, or mongoid'
|
10
|
+
|
11
|
+
class_option :full, :type => :boolean, :aliases => '-g',
|
12
|
+
:desc => 'Full installation will install the layout and css overrides for easier customization.'
|
13
|
+
|
14
|
+
def copy_config
|
15
|
+
copy_file 'vendor/assets/javascripts/mercury.js', 'app/assets/javascripts/mercury.js'
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_routes
|
19
|
+
route %Q{Mercury::Engine.routes}
|
20
|
+
end
|
21
|
+
|
22
|
+
def copy_models
|
23
|
+
if options[:orm] == 'mongoid'
|
24
|
+
copy_file 'lib/generators/mercury/install/templates/mongoid_paperclip_image.rb', 'app/models/mercury/image.rb'
|
25
|
+
else
|
26
|
+
copy_file 'app/models/mercury/image.rb' if options[:full]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def copy_layout_and_css_overrides
|
31
|
+
if options[:full] || yes?("Install the layout and CSS overrides files? [yN]")
|
32
|
+
copy_file 'app/views/layouts/mercury.html.erb', 'app/views/layouts/mercury.html.erb'
|
33
|
+
copy_file 'vendor/assets/stylesheets/mercury_overrides.css', 'app/assets/stylesheets/mercury_overrides.css'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def copy_authentication_overrides
|
38
|
+
if options[:full] || yes?("Install the authentication file so you can restrict access to editing? [yN]")
|
39
|
+
copy_file 'lib/mercury/authentication.rb'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def display_readme
|
44
|
+
readme 'POST_INSTALL' if behavior == :invoke
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Mercury::Image
|
2
|
+
include Mongoid::Document
|
3
|
+
include Mongoid::Paperclip
|
4
|
+
|
5
|
+
has_mongoid_attached_file :image
|
6
|
+
|
7
|
+
validates_presence_of :image
|
8
|
+
|
9
|
+
delegate :url, :to => :image
|
10
|
+
|
11
|
+
def serializable_hash(options = nil)
|
12
|
+
options ||= {}
|
13
|
+
options[:methods] ||= []
|
14
|
+
options[:methods] << :url
|
15
|
+
super(options)
|
16
|
+
end
|
17
|
+
end
|