storytime 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -2
- data/Gemfile.lock +238 -185
- data/README.md +21 -21
- data/app/assets/javascripts/storytime/application.js +5 -3
- data/app/assets/javascripts/storytime/base.js.coffee +5 -4
- data/app/assets/javascripts/storytime/media.js.coffee +7 -2
- data/app/assets/javascripts/storytime/{users.js.coffee → memberships.js.coffee} +3 -4
- data/app/assets/javascripts/storytime/navigations.js.coffee +7 -0
- data/app/assets/javascripts/storytime/wysiwyg.js.coffee +23 -11
- data/app/assets/stylesheets/storytime/application.scss +2 -1
- data/app/assets/stylesheets/storytime/dashboard_overrides.scss +4 -0
- data/app/assets/stylesheets/storytime/media.scss +2 -0
- data/app/assets/stylesheets/storytime/navigation.scss +7 -0
- data/app/assets/stylesheets/storytime/posts.scss +70 -61
- data/app/controllers/storytime/application_controller.rb +8 -7
- data/app/controllers/storytime/blogs_controller.rb +10 -5
- data/app/controllers/storytime/dashboard/blogs_controller.rb +0 -1
- data/app/controllers/storytime/dashboard/custom_posts_controller.rb +1 -1
- data/app/controllers/storytime/dashboard/links_controller.rb +16 -0
- data/app/controllers/storytime/dashboard/memberships_controller.rb +56 -6
- data/app/controllers/storytime/dashboard/navigations_controller.rb +66 -0
- data/app/controllers/storytime/dashboard/pages_controller.rb +7 -3
- data/app/controllers/storytime/dashboard/posts_controller.rb +7 -5
- data/app/controllers/storytime/dashboard/sites_controller.rb +1 -1
- data/app/controllers/storytime/dashboard_controller.rb +3 -3
- data/app/controllers/storytime/pages_controller.rb +3 -3
- data/app/helpers/storytime/application_helper.rb +9 -1
- data/app/models/concerns/storytime/scoped_to_site.rb +5 -3
- data/app/models/storytime/blog.rb +0 -1
- data/app/models/storytime/link.rb +22 -0
- data/app/models/storytime/membership.rb +2 -0
- data/app/models/storytime/navigation.rb +19 -0
- data/app/models/storytime/post.rb +8 -4
- data/app/models/storytime/site.rb +3 -2
- data/app/policies/storytime/membership_policy.rb +13 -1
- data/app/policies/storytime/snippet_policy.rb +5 -1
- data/app/views/layouts/storytime/dashboard.html.erb +2 -1
- data/app/views/storytime/application/storytime/_header.html.erb +1 -0
- data/app/views/storytime/blogs/_tags.html.erb +1 -1
- data/app/views/storytime/blogs/show.html.erb +1 -1
- data/app/views/storytime/dashboard/_navigation.html.erb +12 -8
- data/app/views/storytime/dashboard/_settings_tabs.html.erb +1 -1
- data/app/views/storytime/dashboard/blog_posts/edit.html.erb +1 -1
- data/app/views/storytime/dashboard/blog_posts/new.html.erb +1 -1
- data/app/views/storytime/dashboard/blogs/_blog.html.erb +1 -1
- data/app/views/storytime/dashboard/media/_gallery.html.erb +12 -11
- data/app/views/storytime/dashboard/{users → memberships}/_edit.html.erb +6 -7
- data/app/views/storytime/dashboard/memberships/_index.html.erb +1 -1
- data/app/views/storytime/dashboard/memberships/_membership.html.erb +1 -1
- data/app/views/storytime/dashboard/{users → memberships}/_new.html.erb +3 -3
- data/app/views/storytime/dashboard/memberships/edit.json.jbuilder +2 -0
- data/app/views/storytime/dashboard/memberships/new.json.jbuilder +2 -0
- data/app/views/storytime/dashboard/memberships/save.json.jbuilder +1 -1
- data/app/views/storytime/dashboard/navigations/_blog_link_fields.html.erb +8 -0
- data/app/views/storytime/dashboard/navigations/_external_link_fields.html.erb +7 -0
- data/app/views/storytime/dashboard/navigations/_form.html.erb +58 -0
- data/app/views/storytime/dashboard/navigations/_navigation.html.erb +25 -0
- data/app/views/storytime/dashboard/navigations/_page_link_fields.html.erb +8 -0
- data/app/views/storytime/dashboard/navigations/edit.html.erb +1 -0
- data/app/views/storytime/dashboard/navigations/index.html.erb +15 -0
- data/app/views/storytime/dashboard/navigations/new.html.erb +1 -0
- data/app/views/storytime/dashboard/pages/edit.html.erb +1 -1
- data/app/views/storytime/dashboard/pages/new.html.erb +1 -1
- data/app/views/storytime/dashboard/posts/_image_toolbar.html.erb +4 -1
- data/app/views/storytime/dashboard/posts/_list.html.erb +10 -8
- data/app/views/storytime/dashboard/posts/edit.html.erb +1 -1
- data/app/views/storytime/dashboard/posts/index.html.erb +16 -5
- data/app/views/storytime/dashboard/posts/new.html.erb +1 -1
- data/app/views/storytime/navigations/_navigation.html.erb +3 -0
- data/app/views/storytime/posts/_post.html.erb +1 -1
- data/app/views/storytime/posts/_tags.html.erb +1 -1
- data/app/views/storytime/sites/_google_analytics_code.html.erb +4 -3
- data/app/views/storytime/snippets/_snippet.html.erb +1 -1
- data/config/initializers/assets.rb +1 -1
- data/config/initializers/storytime_admin.rb +2 -0
- data/config/initializers/url_for_patch.rb +6 -6
- data/config/locales/en.yml +18 -0
- data/config/routes.rb +11 -10
- data/db/migrate/20141021073356_create_storytime_snippets.rb +1 -1
- data/db/migrate/20150520181115_create_storytime_navigations.rb +12 -0
- data/db/migrate/20150520185227_create_storytime_links.rb +11 -0
- data/db/migrate/20150520190700_add_position_to_storytime_links.rb +6 -0
- data/db/migrate/20150529192058_add_url_to_storytime_links.rb +5 -0
- data/lib/generators/storytime/views_generator.rb +2 -3
- data/lib/generators/templates/storytime.rb +22 -15
- data/lib/storytime/concerns/current_site.rb +1 -1
- data/lib/storytime/concerns/has_versions.rb +8 -8
- data/lib/storytime/constraints/page_constraint.rb +2 -2
- data/lib/storytime/engine.rb +2 -0
- data/lib/storytime/storytime_helpers.rb +7 -5
- data/lib/storytime/version.rb +1 -1
- data/lib/storytime.rb +29 -11
- data/spec/controllers/dashboard_controller_spec.rb +4 -4
- data/spec/dummy/config/environments/test.rb +1 -1
- data/spec/dummy/db/schema.rb +61 -35
- data/spec/factories/navigation_factories.rb +6 -0
- data/spec/features/blogs_spec.rb +2 -2
- data/spec/features/comments_spec.rb +4 -4
- data/spec/features/dashboard/media_spec.rb +7 -7
- data/spec/features/dashboard/memberships_spec.rb +62 -4
- data/spec/features/dashboard/navigations_spec.rb +33 -0
- data/spec/features/dashboard/pages_spec.rb +26 -16
- data/spec/features/dashboard/posts_spec.rb +65 -15
- data/spec/features/dashboard/sites_spec.rb +5 -5
- data/spec/features/dashboard/snippets_spec.rb +5 -5
- data/spec/features/dashboard/subscription_spec.rb +5 -5
- data/spec/features/pages_spec.rb +3 -3
- data/spec/features/posts_spec.rb +1 -1
- data/spec/features/subscription_spec.rb +2 -2
- data/spec/lib/storytime_helpers_spec.rb +37 -0
- data/spec/models/navigation_spec.rb +21 -0
- data/spec/requests/routings_spec.rb +8 -8
- data/spec/spec_helper.rb +5 -5
- data/spec/support/feature_macros.rb +1 -1
- data/storytime.gemspec +6 -4
- metadata +69 -23
- data/app/views/storytime/dashboard/users/edit.json.jbuilder +0 -2
- data/app/views/storytime/dashboard/users/new.json.jbuilder +0 -2
- data/screenshots/admin.png +0 -0
- data/screenshots/media.png +0 -0
- data/screenshots/page-list.png +0 -0
- data/screenshots/post-editor.png +0 -0
- data/screenshots/site-settings.png +0 -0
- data/screenshots/text-snippets.png +0 -0
- data/screenshots/user-management.png +0 -0
- data/spec/features/dashboard/users_spec.rb +0 -66
@@ -9,6 +9,12 @@ Storytime.configure do |config|
|
|
9
9
|
# Path used to sign users in.
|
10
10
|
# config.login_path = '/users/sign_in'
|
11
11
|
|
12
|
+
# Path used to sign users out.
|
13
|
+
# config.logout_path = '/users/sign_out'
|
14
|
+
|
15
|
+
# Path used to register a new user.
|
16
|
+
# config.registration_path = "/users/sign_up"
|
17
|
+
|
12
18
|
# Method used for Storytime user logout path.
|
13
19
|
# config.logout_method = :delete
|
14
20
|
|
@@ -28,25 +34,22 @@ Storytime.configure do |config|
|
|
28
34
|
# handle how post content is sanitized (i.e. which tags,
|
29
35
|
# HTML attributes to allow/disallow.
|
30
36
|
# config.post_sanitizer = Proc.new do |draft_content|
|
31
|
-
#
|
32
|
-
# HTML::WhiteListSanitizer.new
|
37
|
+
# if Rails::VERSION::MINOR <= 1
|
38
|
+
# white_list_sanitizer = HTML::WhiteListSanitizer.new
|
39
|
+
# tags = white_list_sanitizer.allowed_tags
|
40
|
+
# attributes = white_list_sanitizer.allowed_attributes
|
33
41
|
# else
|
34
|
-
# Rails::Html::WhiteListSanitizer.new
|
42
|
+
# white_list_sanitizer = Rails::Html::WhiteListSanitizer.new
|
43
|
+
# tags = Loofah::HTML5::WhiteList::ALLOWED_ELEMENTS_WITH_LIBXML2
|
44
|
+
# attributes = Loofah::HTML5::WhiteList::ALLOWED_ATTRIBUTES
|
35
45
|
# end
|
36
46
|
#
|
37
|
-
# attributes
|
38
|
-
#
|
39
|
-
#
|
40
|
-
# )
|
47
|
+
# # Add any additional tags or attributes to tags/attributes Sets here.
|
48
|
+
# # tags.add("someCustomTag")
|
49
|
+
# # attributes.add("someCustomAttribute")
|
41
50
|
#
|
42
|
-
#
|
43
|
-
#
|
44
|
-
# else
|
45
|
-
# white_list_sanitizer.sanitize(draft_content,
|
46
|
-
# tags: Storytime.whitelisted_post_html_tags,
|
47
|
-
# attributes: attributes)
|
48
|
-
# end
|
49
|
-
# end
|
51
|
+
# white_list_sanitizer.sanitize(draft_content, tags: tags, attributes: attributes)
|
52
|
+
# # end
|
50
53
|
|
51
54
|
# Enable Disqus comments using your forum's shortname,
|
52
55
|
# the unique identifier for your website as registered on Disqus.
|
@@ -98,6 +101,10 @@ Storytime.configure do |config|
|
|
98
101
|
# AWS Secret Key to use for file uploads.
|
99
102
|
# config.aws_secret_key = <%= @aws_secret_key %>
|
100
103
|
|
104
|
+
# Superclass for Storytime::ApplicationController
|
105
|
+
# Defaults to the host app's ApplicationController
|
106
|
+
# config.application_controller_superclass = "::ApplicationController"
|
107
|
+
|
101
108
|
if Rails.env.production?
|
102
109
|
config.media_storage = <%= @prod_media_storage %>
|
103
110
|
<%= @enable_file_upload && @prod_media_storage == ':s3' ? nil : '# ' %>config.s3_bucket = '<%= @s3_bucket %>'
|
@@ -3,7 +3,7 @@ module Storytime
|
|
3
3
|
module CurrentSite
|
4
4
|
def current_storytime_site(req = nil)
|
5
5
|
req ||= request if respond_to?(:request)
|
6
|
-
@current_storytime_site = Storytime::Site.find_by(custom_domain: req.host) || Storytime::Site.first
|
6
|
+
@current_storytime_site = Storytime::Site.current || Storytime::Site.find_by(custom_domain: req.host) || Storytime::Site.first
|
7
7
|
end
|
8
8
|
end
|
9
9
|
end
|
@@ -18,11 +18,13 @@ module Storytime
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def create_version
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
unless self.draft_content.blank?
|
22
|
+
if self.latest_version.nil? || self.draft_content != self.latest_version.content
|
23
|
+
version = self.versions.new
|
24
|
+
version.content = self.draft_content
|
25
|
+
version.user_id = self.draft_user_id
|
26
|
+
version.save
|
27
|
+
end
|
26
28
|
end
|
27
29
|
self.publish! if self.published?
|
28
30
|
end
|
@@ -38,7 +40,7 @@ module Storytime
|
|
38
40
|
|
39
41
|
def publish!
|
40
42
|
self.published = "1"
|
41
|
-
attrs = {self.class.draft_content_column => self.latest_version.content}
|
43
|
+
attrs = {self.class.draft_content_column => (self.latest_version.present? ? self.latest_version.content : "") }
|
42
44
|
self.update_columns(attrs)
|
43
45
|
end
|
44
46
|
|
@@ -78,8 +80,6 @@ module Storytime
|
|
78
80
|
|
79
81
|
self.draft_content_column = :content
|
80
82
|
|
81
|
-
validates_presence_of :draft_content
|
82
|
-
|
83
83
|
scope :published, -> { where("published_at IS NOT NULL").where("published_at <= ?", Time.now) }
|
84
84
|
scope :draft, -> { where("published_at IS NULL OR published_at > ?", Time.now) }
|
85
85
|
end
|
@@ -2,7 +2,7 @@ module Storytime
|
|
2
2
|
module Constraints
|
3
3
|
class PageConstraint
|
4
4
|
include Storytime::Concerns::CurrentSite
|
5
|
-
|
5
|
+
|
6
6
|
def matches?(request)
|
7
7
|
site = current_storytime_site(request)
|
8
8
|
site.pages.friendly.exists?(request.params[:id]) ||
|
@@ -10,4 +10,4 @@ module Storytime
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
13
|
-
end
|
13
|
+
end
|
data/lib/storytime/engine.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
module Storytime
|
2
2
|
module StorytimeHelpers
|
3
3
|
def storytime_snippet(name)
|
4
|
-
snippet = Storytime::Snippet.find_by(name: name)
|
4
|
+
snippet = Storytime::Snippet.find_by(name: name, site: current_storytime_site)
|
5
|
+
|
5
6
|
if snippet.nil?
|
6
|
-
""
|
7
|
-
|
8
|
-
render partial: "storytime/snippets/snippet", locals: {snippet: snippet}
|
7
|
+
content = I18n.exists?(name) ? I18n.t(name).html_safe : "Lorem ipsum dolor sit amet, consectetur adipiscing elit..."
|
8
|
+
snippet = Storytime::Snippet.create(name: name, content: content, site: current_storytime_site)
|
9
9
|
end
|
10
|
+
|
11
|
+
render partial: "storytime/snippets/snippet", locals: {snippet: snippet}
|
10
12
|
end
|
11
13
|
end
|
12
|
-
end
|
14
|
+
end
|
data/lib/storytime/version.rb
CHANGED
data/lib/storytime.rb
CHANGED
@@ -18,10 +18,18 @@ module Storytime
|
|
18
18
|
mattr_accessor :dashboard_namespace_path
|
19
19
|
@@dashboard_namespace_path = '/storytime'
|
20
20
|
|
21
|
-
# Path used to sign users in.
|
21
|
+
# Path used to sign users in.
|
22
22
|
mattr_accessor :login_path
|
23
23
|
@@login_path = '/users/sign_in'
|
24
24
|
|
25
|
+
# Path used to sign users out.
|
26
|
+
mattr_accessor :logout_path
|
27
|
+
@@logout_path = '/users/sign_out'
|
28
|
+
|
29
|
+
# Path used to register a new user.
|
30
|
+
mattr_accessor :registration_path
|
31
|
+
@@registration_path = "/users/sign_up"
|
32
|
+
|
25
33
|
# Method used for Storytime user logout path.
|
26
34
|
mattr_accessor :logout_method
|
27
35
|
@@logout_method = :delete
|
@@ -44,18 +52,19 @@ module Storytime
|
|
44
52
|
# HTML attributes to allow/disallow.
|
45
53
|
mattr_accessor :post_sanitizer
|
46
54
|
@@post_sanitizer = Proc.new do |draft_content|
|
47
|
-
|
48
|
-
HTML::WhiteListSanitizer.new
|
55
|
+
if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR <= 1
|
56
|
+
white_list_sanitizer = HTML::WhiteListSanitizer.new
|
57
|
+
tags = white_list_sanitizer.allowed_tags
|
58
|
+
attributes = white_list_sanitizer.allowed_attributes
|
49
59
|
else
|
50
|
-
Rails::Html::WhiteListSanitizer.new
|
60
|
+
white_list_sanitizer = Rails::Html::WhiteListSanitizer.new
|
61
|
+
tags = Loofah::HTML5::WhiteList::ALLOWED_ELEMENTS_WITH_LIBXML2
|
62
|
+
attributes = Loofah::HTML5::WhiteList::ALLOWED_ATTRIBUTES
|
51
63
|
end
|
52
64
|
|
53
|
-
attributes
|
54
|
-
id class href style src title width height alt value
|
55
|
-
target rel align disabled
|
56
|
-
)
|
65
|
+
attributes << "style"
|
57
66
|
|
58
|
-
white_list_sanitizer.sanitize(draft_content, attributes: attributes)
|
67
|
+
white_list_sanitizer.sanitize(draft_content, tags: tags, attributes: attributes)
|
59
68
|
end
|
60
69
|
|
61
70
|
# Enable Disqus comments using your forum's shortname,
|
@@ -99,9 +108,14 @@ module Storytime
|
|
99
108
|
mattr_accessor :aws_secret_key
|
100
109
|
@@aws_secret_key = ENV['STORYTIME_AWS_SECRET_KEY']
|
101
110
|
|
111
|
+
# Superclass for Storytime::ApplicationController
|
112
|
+
# Defaults to the host app's ApplicationController
|
113
|
+
mattr_accessor :application_controller_superclass
|
114
|
+
@@application_controller_superclass = "::ApplicationController"
|
115
|
+
|
102
116
|
class << self
|
103
117
|
attr_accessor :layout, :media_storage, :s3_bucket, :post_types
|
104
|
-
|
118
|
+
|
105
119
|
def configure
|
106
120
|
self.post_types ||= []
|
107
121
|
|
@@ -123,5 +137,9 @@ module Storytime
|
|
123
137
|
def user_class_symbol
|
124
138
|
@@user_class.underscore.to_sym
|
125
139
|
end
|
140
|
+
|
141
|
+
def application_controller_superclass
|
142
|
+
@@application_controller_superclass.constantize
|
143
|
+
end
|
126
144
|
end
|
127
|
-
end
|
145
|
+
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Storytime::DashboardController do
|
3
|
+
describe Storytime::DashboardController, type: :controller do
|
4
4
|
context "for actions of subclasses" do
|
5
5
|
class WidgetsController < Storytime::DashboardController; end
|
6
6
|
|
7
7
|
controller(WidgetsController) do
|
8
8
|
def index; end
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
it "requires login" do
|
12
12
|
get :index
|
13
13
|
flash[:alert].should == I18n.t('devise.failure.unauthenticated')
|
@@ -18,7 +18,7 @@ describe Storytime::DashboardController do
|
|
18
18
|
controller.view_paths.unshift(ActionView::FixtureResolver.new("widgets/index.html.erb" => ""))
|
19
19
|
FactoryGirl.create(:site)
|
20
20
|
sign_in FactoryGirl.create(:writer)
|
21
|
-
get :index
|
21
|
+
get :index
|
22
22
|
expect(flash[:error]).to eq("You are not authorized to perform this action.")
|
23
23
|
end
|
24
24
|
|
@@ -29,4 +29,4 @@ describe Storytime::DashboardController do
|
|
29
29
|
response.should redirect_to(new_dashboard_site_path)
|
30
30
|
end
|
31
31
|
end
|
32
|
-
end
|
32
|
+
end
|
@@ -13,7 +13,7 @@ Rails.application.configure do
|
|
13
13
|
config.eager_load = false
|
14
14
|
|
15
15
|
# Configure static asset server for tests with Cache-Control for performance.
|
16
|
-
config.
|
16
|
+
config.serve_static_files = true
|
17
17
|
config.static_cache_control = 'public, max-age=3600'
|
18
18
|
|
19
19
|
config.assets.debug = true
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended that you check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
14
|
+
ActiveRecord::Schema.define(version: 20150529192058) do
|
15
15
|
|
16
16
|
# These are extensions that must be enabled in order to support this database
|
17
17
|
enable_extension "plpgsql"
|
@@ -24,10 +24,10 @@ ActiveRecord::Schema.define(version: 20150402161427) do
|
|
24
24
|
t.datetime "created_at"
|
25
25
|
end
|
26
26
|
|
27
|
-
add_index "friendly_id_slugs", ["slug", "sluggable_type", "scope"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type_and_scope", unique: true
|
28
|
-
add_index "friendly_id_slugs", ["slug", "sluggable_type"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type"
|
29
|
-
add_index "friendly_id_slugs", ["sluggable_id"], name: "index_friendly_id_slugs_on_sluggable_id"
|
30
|
-
add_index "friendly_id_slugs", ["sluggable_type"], name: "index_friendly_id_slugs_on_sluggable_type"
|
27
|
+
add_index "friendly_id_slugs", ["slug", "sluggable_type", "scope"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type_and_scope", unique: true, using: :btree
|
28
|
+
add_index "friendly_id_slugs", ["slug", "sluggable_type"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type", using: :btree
|
29
|
+
add_index "friendly_id_slugs", ["sluggable_id"], name: "index_friendly_id_slugs_on_sluggable_id", using: :btree
|
30
|
+
add_index "friendly_id_slugs", ["sluggable_type"], name: "index_friendly_id_slugs_on_sluggable_type", using: :btree
|
31
31
|
|
32
32
|
create_table "storytime_actions", force: :cascade do |t|
|
33
33
|
t.string "name"
|
@@ -36,7 +36,7 @@ ActiveRecord::Schema.define(version: 20150402161427) do
|
|
36
36
|
t.datetime "updated_at"
|
37
37
|
end
|
38
38
|
|
39
|
-
add_index "storytime_actions", ["guid"], name: "index_storytime_actions_on_guid"
|
39
|
+
add_index "storytime_actions", ["guid"], name: "index_storytime_actions_on_guid", using: :btree
|
40
40
|
|
41
41
|
create_table "storytime_autosaves", force: :cascade do |t|
|
42
42
|
t.text "content"
|
@@ -47,8 +47,8 @@ ActiveRecord::Schema.define(version: 20150402161427) do
|
|
47
47
|
t.integer "site_id"
|
48
48
|
end
|
49
49
|
|
50
|
-
add_index "storytime_autosaves", ["autosavable_type", "autosavable_id"], name: "autosavable_index"
|
51
|
-
add_index "storytime_autosaves", ["site_id"], name: "index_storytime_autosaves_on_site_id"
|
50
|
+
add_index "storytime_autosaves", ["autosavable_type", "autosavable_id"], name: "autosavable_index", using: :btree
|
51
|
+
add_index "storytime_autosaves", ["site_id"], name: "index_storytime_autosaves_on_site_id", using: :btree
|
52
52
|
|
53
53
|
create_table "storytime_comments", force: :cascade do |t|
|
54
54
|
t.text "content"
|
@@ -59,9 +59,24 @@ ActiveRecord::Schema.define(version: 20150402161427) do
|
|
59
59
|
t.integer "site_id"
|
60
60
|
end
|
61
61
|
|
62
|
-
add_index "storytime_comments", ["post_id"], name: "index_storytime_comments_on_post_id"
|
63
|
-
add_index "storytime_comments", ["site_id"], name: "index_storytime_comments_on_site_id"
|
64
|
-
add_index "storytime_comments", ["user_id"], name: "index_storytime_comments_on_user_id"
|
62
|
+
add_index "storytime_comments", ["post_id"], name: "index_storytime_comments_on_post_id", using: :btree
|
63
|
+
add_index "storytime_comments", ["site_id"], name: "index_storytime_comments_on_site_id", using: :btree
|
64
|
+
add_index "storytime_comments", ["user_id"], name: "index_storytime_comments_on_user_id", using: :btree
|
65
|
+
|
66
|
+
create_table "storytime_links", force: :cascade do |t|
|
67
|
+
t.string "text"
|
68
|
+
t.integer "storytime_navigation_id"
|
69
|
+
t.integer "linkable_id"
|
70
|
+
t.string "linkable_type"
|
71
|
+
t.datetime "created_at", null: false
|
72
|
+
t.datetime "updated_at", null: false
|
73
|
+
t.integer "position"
|
74
|
+
t.string "url"
|
75
|
+
end
|
76
|
+
|
77
|
+
add_index "storytime_links", ["linkable_type", "linkable_id"], name: "index_storytime_links_on_linkable_type_and_linkable_id", using: :btree
|
78
|
+
add_index "storytime_links", ["position"], name: "index_storytime_links_on_position", using: :btree
|
79
|
+
add_index "storytime_links", ["storytime_navigation_id"], name: "index_storytime_links_on_storytime_navigation_id", using: :btree
|
65
80
|
|
66
81
|
create_table "storytime_media", force: :cascade do |t|
|
67
82
|
t.string "file"
|
@@ -71,8 +86,8 @@ ActiveRecord::Schema.define(version: 20150402161427) do
|
|
71
86
|
t.integer "site_id"
|
72
87
|
end
|
73
88
|
|
74
|
-
add_index "storytime_media", ["site_id"], name: "index_storytime_media_on_site_id"
|
75
|
-
add_index "storytime_media", ["user_id"], name: "index_storytime_media_on_user_id"
|
89
|
+
add_index "storytime_media", ["site_id"], name: "index_storytime_media_on_site_id", using: :btree
|
90
|
+
add_index "storytime_media", ["user_id"], name: "index_storytime_media_on_user_id", using: :btree
|
76
91
|
|
77
92
|
create_table "storytime_memberships", force: :cascade do |t|
|
78
93
|
t.integer "user_id"
|
@@ -82,9 +97,19 @@ ActiveRecord::Schema.define(version: 20150402161427) do
|
|
82
97
|
t.datetime "updated_at"
|
83
98
|
end
|
84
99
|
|
85
|
-
add_index "storytime_memberships", ["site_id"], name: "index_storytime_memberships_on_site_id"
|
86
|
-
add_index "storytime_memberships", ["storytime_role_id"], name: "index_storytime_memberships_on_storytime_role_id"
|
87
|
-
add_index "storytime_memberships", ["user_id"], name: "index_storytime_memberships_on_user_id"
|
100
|
+
add_index "storytime_memberships", ["site_id"], name: "index_storytime_memberships_on_site_id", using: :btree
|
101
|
+
add_index "storytime_memberships", ["storytime_role_id"], name: "index_storytime_memberships_on_storytime_role_id", using: :btree
|
102
|
+
add_index "storytime_memberships", ["user_id"], name: "index_storytime_memberships_on_user_id", using: :btree
|
103
|
+
|
104
|
+
create_table "storytime_navigations", force: :cascade do |t|
|
105
|
+
t.string "name"
|
106
|
+
t.string "handle"
|
107
|
+
t.integer "site_id"
|
108
|
+
t.datetime "created_at", null: false
|
109
|
+
t.datetime "updated_at", null: false
|
110
|
+
end
|
111
|
+
|
112
|
+
add_index "storytime_navigations", ["site_id"], name: "index_storytime_navigations_on_site_id", using: :btree
|
88
113
|
|
89
114
|
create_table "storytime_permissions", force: :cascade do |t|
|
90
115
|
t.integer "role_id"
|
@@ -94,9 +119,9 @@ ActiveRecord::Schema.define(version: 20150402161427) do
|
|
94
119
|
t.integer "site_id"
|
95
120
|
end
|
96
121
|
|
97
|
-
add_index "storytime_permissions", ["action_id"], name: "index_storytime_permissions_on_action_id"
|
98
|
-
add_index "storytime_permissions", ["role_id"], name: "index_storytime_permissions_on_role_id"
|
99
|
-
add_index "storytime_permissions", ["site_id"], name: "index_storytime_permissions_on_site_id"
|
122
|
+
add_index "storytime_permissions", ["action_id"], name: "index_storytime_permissions_on_action_id", using: :btree
|
123
|
+
add_index "storytime_permissions", ["role_id"], name: "index_storytime_permissions_on_role_id", using: :btree
|
124
|
+
add_index "storytime_permissions", ["site_id"], name: "index_storytime_permissions_on_site_id", using: :btree
|
100
125
|
|
101
126
|
create_table "storytime_posts", force: :cascade do |t|
|
102
127
|
t.integer "user_id"
|
@@ -118,9 +143,9 @@ ActiveRecord::Schema.define(version: 20150402161427) do
|
|
118
143
|
t.integer "blog_id"
|
119
144
|
end
|
120
145
|
|
121
|
-
add_index "storytime_posts", ["blog_id"], name: "index_storytime_posts_on_blog_id"
|
122
|
-
add_index "storytime_posts", ["slug"], name: "index_storytime_posts_on_slug"
|
123
|
-
add_index "storytime_posts", ["user_id"], name: "index_storytime_posts_on_user_id"
|
146
|
+
add_index "storytime_posts", ["blog_id"], name: "index_storytime_posts_on_blog_id", using: :btree
|
147
|
+
add_index "storytime_posts", ["slug"], name: "index_storytime_posts_on_slug", using: :btree
|
148
|
+
add_index "storytime_posts", ["user_id"], name: "index_storytime_posts_on_user_id", using: :btree
|
124
149
|
|
125
150
|
create_table "storytime_roles", force: :cascade do |t|
|
126
151
|
t.string "name"
|
@@ -128,7 +153,7 @@ ActiveRecord::Schema.define(version: 20150402161427) do
|
|
128
153
|
t.datetime "updated_at"
|
129
154
|
end
|
130
155
|
|
131
|
-
add_index "storytime_roles", ["name"], name: "index_storytime_roles_on_name"
|
156
|
+
add_index "storytime_roles", ["name"], name: "index_storytime_roles_on_name", using: :btree
|
132
157
|
|
133
158
|
create_table "storytime_sites", force: :cascade do |t|
|
134
159
|
t.string "title"
|
@@ -145,8 +170,8 @@ ActiveRecord::Schema.define(version: 20150402161427) do
|
|
145
170
|
t.string "discourse_name"
|
146
171
|
end
|
147
172
|
|
148
|
-
add_index "storytime_sites", ["root_post_id"], name: "index_storytime_sites_on_root_post_id"
|
149
|
-
add_index "storytime_sites", ["user_id"], name: "index_storytime_sites_on_user_id"
|
173
|
+
add_index "storytime_sites", ["root_post_id"], name: "index_storytime_sites_on_root_post_id", using: :btree
|
174
|
+
add_index "storytime_sites", ["user_id"], name: "index_storytime_sites_on_user_id", using: :btree
|
150
175
|
|
151
176
|
create_table "storytime_snippets", force: :cascade do |t|
|
152
177
|
t.string "name"
|
@@ -156,7 +181,7 @@ ActiveRecord::Schema.define(version: 20150402161427) do
|
|
156
181
|
t.integer "site_id"
|
157
182
|
end
|
158
183
|
|
159
|
-
add_index "storytime_snippets", ["name"], name: "index_storytime_snippets_on_name"
|
184
|
+
add_index "storytime_snippets", ["name"], name: "index_storytime_snippets_on_name", using: :btree
|
160
185
|
|
161
186
|
create_table "storytime_subscriptions", force: :cascade do |t|
|
162
187
|
t.string "email"
|
@@ -167,7 +192,7 @@ ActiveRecord::Schema.define(version: 20150402161427) do
|
|
167
192
|
t.integer "site_id"
|
168
193
|
end
|
169
194
|
|
170
|
-
add_index "storytime_subscriptions", ["token"], name: "index_storytime_subscriptions_on_token"
|
195
|
+
add_index "storytime_subscriptions", ["token"], name: "index_storytime_subscriptions_on_token", using: :btree
|
171
196
|
|
172
197
|
create_table "storytime_taggings", force: :cascade do |t|
|
173
198
|
t.integer "tag_id"
|
@@ -177,9 +202,9 @@ ActiveRecord::Schema.define(version: 20150402161427) do
|
|
177
202
|
t.integer "site_id"
|
178
203
|
end
|
179
204
|
|
180
|
-
add_index "storytime_taggings", ["post_id"], name: "index_storytime_taggings_on_post_id"
|
181
|
-
add_index "storytime_taggings", ["site_id"], name: "index_storytime_taggings_on_site_id"
|
182
|
-
add_index "storytime_taggings", ["tag_id"], name: "index_storytime_taggings_on_tag_id"
|
205
|
+
add_index "storytime_taggings", ["post_id"], name: "index_storytime_taggings_on_post_id", using: :btree
|
206
|
+
add_index "storytime_taggings", ["site_id"], name: "index_storytime_taggings_on_site_id", using: :btree
|
207
|
+
add_index "storytime_taggings", ["tag_id"], name: "index_storytime_taggings_on_tag_id", using: :btree
|
183
208
|
|
184
209
|
create_table "storytime_tags", force: :cascade do |t|
|
185
210
|
t.string "name"
|
@@ -198,9 +223,9 @@ ActiveRecord::Schema.define(version: 20150402161427) do
|
|
198
223
|
t.integer "site_id"
|
199
224
|
end
|
200
225
|
|
201
|
-
add_index "storytime_versions", ["site_id"], name: "index_storytime_versions_on_site_id"
|
202
|
-
add_index "storytime_versions", ["user_id"], name: "index_storytime_versions_on_user_id"
|
203
|
-
add_index "storytime_versions", ["versionable_type", "versionable_id"], name: "versionable_index"
|
226
|
+
add_index "storytime_versions", ["site_id"], name: "index_storytime_versions_on_site_id", using: :btree
|
227
|
+
add_index "storytime_versions", ["user_id"], name: "index_storytime_versions_on_user_id", using: :btree
|
228
|
+
add_index "storytime_versions", ["versionable_type", "versionable_id"], name: "versionable_index", using: :btree
|
204
229
|
|
205
230
|
create_table "users", force: :cascade do |t|
|
206
231
|
t.string "email", default: "", null: false
|
@@ -218,8 +243,8 @@ ActiveRecord::Schema.define(version: 20150402161427) do
|
|
218
243
|
t.string "storytime_name"
|
219
244
|
end
|
220
245
|
|
221
|
-
add_index "users", ["email"], name: "index_users_on_email", unique: true
|
222
|
-
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
246
|
+
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
|
247
|
+
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
|
223
248
|
|
224
249
|
create_table "widgets", force: :cascade do |t|
|
225
250
|
t.string "name"
|
@@ -227,4 +252,5 @@ ActiveRecord::Schema.define(version: 20150402161427) do
|
|
227
252
|
t.datetime "updated_at"
|
228
253
|
end
|
229
254
|
|
255
|
+
add_foreign_key "storytime_links", "storytime_navigations"
|
230
256
|
end
|
data/spec/features/blogs_spec.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe "Blogs" do
|
3
|
+
describe "Blogs", type: :feature do
|
4
4
|
before do
|
5
5
|
setup_site(FactoryGirl.create(:admin))
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
it "lists posts belonging to that blog" do
|
9
9
|
3.times{ FactoryGirl.create(:post, blog: @current_site.blogs.first, site: @current_site) }
|
10
10
|
other_blog_post = FactoryGirl.create(:post, site: @current_site)
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe "Comments" do
|
3
|
+
describe "Comments", type: :feature do
|
4
4
|
before do
|
5
5
|
# setup_site
|
6
6
|
login
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
it "lists comments on a post" do
|
10
10
|
post = FactoryGirl.create(:post, site: @current_site, blog: @current_site.blogs.first)
|
11
11
|
3.times{ FactoryGirl.create(:comment, post: post, site: @current_site) }
|
@@ -48,10 +48,10 @@ describe "Comments" do
|
|
48
48
|
|
49
49
|
expect(page).to have_content(comment_to_delete.content)
|
50
50
|
click_link "delete_comment_#{comment_to_delete.id}"
|
51
|
-
|
51
|
+
|
52
52
|
expect(page).to_not have_content(comment_to_delete.content)
|
53
53
|
|
54
54
|
expect{ comment_to_delete.reload }.to raise_error
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe "In the dashboard, Media" do
|
3
|
+
describe "In the dashboard, Media", type: :feature do
|
4
4
|
include Storytime::Dashboard::MediaHelper
|
5
5
|
|
6
6
|
before{ login_admin }
|
7
|
-
|
7
|
+
|
8
8
|
it "creates media", js: true do
|
9
9
|
visit dashboard_media_index_path
|
10
10
|
|
11
11
|
attach_file('media_file', "./spec/support/images/success-kid.jpg")
|
12
|
-
|
12
|
+
|
13
13
|
expect(find("#media_gallery").find("img")['src']).to have_content('success-kid.jpg')
|
14
14
|
end
|
15
15
|
|
@@ -18,14 +18,14 @@ describe "In the dashboard, Media" do
|
|
18
18
|
m2 = FactoryGirl.create(:media, site: @current_site)
|
19
19
|
|
20
20
|
visit dashboard_media_index_path
|
21
|
-
|
21
|
+
|
22
22
|
page.should have_image(m1.file_url(:thumb))
|
23
23
|
page.should have_image(m2.file_url(:thumb))
|
24
24
|
end
|
25
25
|
|
26
26
|
it "deletes an image", js: true do
|
27
27
|
image = FactoryGirl.create(:media, site: @current_site)
|
28
|
-
|
28
|
+
|
29
29
|
visit dashboard_media_index_path
|
30
30
|
page.should have_image(image.file_url(:thumb))
|
31
31
|
|
@@ -40,12 +40,12 @@ describe "In the dashboard, Media" do
|
|
40
40
|
visit url_for([:new, :dashboard, @current_site.blogs.first, :blog_post, only_path: true])
|
41
41
|
|
42
42
|
find(".insert-media-button").click
|
43
|
-
|
43
|
+
|
44
44
|
within "#media_#{media.id}" do
|
45
45
|
find(".insert-image-button").click
|
46
46
|
end
|
47
47
|
|
48
48
|
expect(page).to have_image(media.file_url)
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
end
|