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
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe "In the dashboard, Users" do
|
3
|
+
describe "In the dashboard, Users", type: :feature do
|
4
4
|
context "as Admin" do
|
5
5
|
before{ login_admin }
|
6
6
|
|
@@ -11,7 +11,7 @@ describe "In the dashboard, Users" do
|
|
11
11
|
visit storytime.dashboard_path
|
12
12
|
|
13
13
|
click_link @current_site.title
|
14
|
-
|
14
|
+
|
15
15
|
expect(page).to have_link(@current_site.title, href: "")
|
16
16
|
expect(page).to have_link(other_site.title, href: storytime.dashboard_url(host: other_site.custom_domain, port: Capybara.current_session.server.port))
|
17
17
|
end
|
@@ -47,12 +47,70 @@ describe "In the dashboard, Users" do
|
|
47
47
|
|
48
48
|
find("#membership_#{membership.id}").hover
|
49
49
|
click_link("delete_membership_#{membership.id}")
|
50
|
-
|
50
|
+
|
51
51
|
expect(page).to_not have_content(user.storytime_name)
|
52
52
|
|
53
53
|
expect(Storytime.user_class.count).to eq(user_count)
|
54
54
|
expect(Storytime::Membership.count).to eq(membership_count-1)
|
55
55
|
end
|
56
56
|
|
57
|
+
it "edits own profile", js: true do
|
58
|
+
u = User.last
|
59
|
+
|
60
|
+
visit storytime.dashboard_path
|
61
|
+
click_link "utility-menu-toggle"
|
62
|
+
click_link "profile-link"
|
63
|
+
fill_in "membership_user_attributes_email", with: "new_email@example.com"
|
64
|
+
click_button "Save"
|
65
|
+
|
66
|
+
within "#storytime-modal" do
|
67
|
+
storytime_name_field = find_field("membership_user_attributes_storytime_name").value
|
68
|
+
storytime_email_field = find_field("membership_user_attributes_email").value
|
69
|
+
|
70
|
+
expect(storytime_name_field).to eq(u.storytime_name)
|
71
|
+
expect(storytime_email_field).to eq("new_email@example.com")
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
it "edits another user's profile", js: true do
|
76
|
+
FactoryGirl.create :membership, site: @current_site
|
77
|
+
u = User.last
|
78
|
+
|
79
|
+
visit storytime.dashboard_path
|
80
|
+
click_link "utility-menu-toggle"
|
81
|
+
click_link "users-link"
|
82
|
+
|
83
|
+
click_link u.storytime_name
|
84
|
+
|
85
|
+
fill_in "membership_user_attributes_email", with: "change_email@example.com"
|
86
|
+
click_button "Save"
|
87
|
+
|
88
|
+
within "#storytime-modal" do
|
89
|
+
storytime_name_field = find_field("membership_user_attributes_storytime_name").value
|
90
|
+
storytime_email_field = find_field("membership_user_attributes_email").value
|
91
|
+
|
92
|
+
expect(storytime_name_field).to eq(u.storytime_name)
|
93
|
+
expect(storytime_email_field).to eq("change_email@example.com")
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
it "creates a user", js: true do
|
98
|
+
visit storytime.dashboard_path
|
99
|
+
click_link "utility-menu-toggle"
|
100
|
+
click_link "users-link"
|
101
|
+
|
102
|
+
click_link "new-user-link"
|
103
|
+
|
104
|
+
fill_in "user_storytime_name", with: "New Storytime Username"
|
105
|
+
fill_in "user_email", with: "new_user@example.com"
|
106
|
+
select "Editor", from: "Storytime role"
|
107
|
+
fill_in "user_password", with: "password"
|
108
|
+
fill_in "user_password_confirmation", with: "password"
|
109
|
+
click_button "Save"
|
110
|
+
|
111
|
+
within "#storytime-modal" do
|
112
|
+
expect(page).to have_content "New Storytime Username"
|
113
|
+
end
|
114
|
+
end
|
57
115
|
end
|
58
|
-
end
|
116
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "In the dashboard, Navigations", type: :feature do
|
4
|
+
|
5
|
+
before{ login_admin }
|
6
|
+
|
7
|
+
it "renders the navigations index" do
|
8
|
+
visit dashboard_navigations_path
|
9
|
+
expect(page).to have_content I18n.t('storytime.dashboard.navigations.index.header')
|
10
|
+
end
|
11
|
+
|
12
|
+
it "creates a new navigation list" do
|
13
|
+
visit new_dashboard_navigation_path
|
14
|
+
|
15
|
+
expect{
|
16
|
+
fill_in "navigation_name", with: "Main Navigation"
|
17
|
+
fill_in "navigation_handle", with: "main"
|
18
|
+
find("input[name='commit']").click()
|
19
|
+
}.to change(Storytime::Navigation, :count).by(1)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "updates a navigation list" do
|
23
|
+
Storytime::Site.current_id = current_site.id
|
24
|
+
nav = FactoryGirl.create(:navigation, site_id: current_site.id)
|
25
|
+
visit edit_dashboard_navigation_path(nav)
|
26
|
+
|
27
|
+
fill_in "navigation_name", with: "New Name"
|
28
|
+
find("input[name='commit']").click()
|
29
|
+
|
30
|
+
nav.reload
|
31
|
+
expect(nav.name).to eq "New Name"
|
32
|
+
end
|
33
|
+
end
|
@@ -1,21 +1,31 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe "In the dashboard, Pages" do
|
4
|
-
before do
|
3
|
+
describe "In the dashboard, Pages", type: :feature do
|
4
|
+
before do
|
5
5
|
login_admin
|
6
6
|
end
|
7
7
|
|
8
8
|
describe "index" do
|
9
|
-
before do
|
9
|
+
before do
|
10
10
|
3.times{ FactoryGirl.create(:page, site: current_site) }
|
11
11
|
3.times{ FactoryGirl.create(:page, published_at: nil, site: current_site) }
|
12
12
|
end
|
13
13
|
|
14
14
|
let!(:other_site_page){ FactoryGirl.create(:page) }
|
15
15
|
|
16
|
-
it "lists
|
16
|
+
it "lists all pages" do
|
17
17
|
visit dashboard_pages_path
|
18
|
-
|
18
|
+
|
19
|
+
current_site.pages.each do |p|
|
20
|
+
expect(page).to have_link_to_post(p)
|
21
|
+
end
|
22
|
+
|
23
|
+
expect(page).not_to have_link_to_post(other_site_page)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "lists draft pages" do
|
27
|
+
visit dashboard_pages_path(draft: true)
|
28
|
+
|
19
29
|
current_site.pages.each do |p|
|
20
30
|
expect(page).to have_link_to_post(p) if p.published_at.nil?
|
21
31
|
expect(page).not_to have_link_to_post(p) if p.published_at.present?
|
@@ -27,7 +37,7 @@ describe "In the dashboard, Pages" do
|
|
27
37
|
|
28
38
|
it "lists published pages" do
|
29
39
|
visit dashboard_pages_path(published: true)
|
30
|
-
|
40
|
+
|
31
41
|
# need the type designation so Blogs, which are Page subclasses, don't show up in the query
|
32
42
|
current_site.pages.where(type: "Storytime::Page").each do |p|
|
33
43
|
expect(page).not_to have_link_to_post(p) if p.published_at.nil?
|
@@ -38,7 +48,7 @@ describe "In the dashboard, Pages" do
|
|
38
48
|
expect(page).not_to have_link_to_post(other_site_page)
|
39
49
|
end
|
40
50
|
end
|
41
|
-
|
51
|
+
|
42
52
|
it "creates a page", js: true do
|
43
53
|
page_count = Storytime::Page.count
|
44
54
|
|
@@ -46,16 +56,16 @@ describe "In the dashboard, Pages" do
|
|
46
56
|
|
47
57
|
find('#post-title-input').set("The Page")
|
48
58
|
find('#medium-editor-post').set("The content of my page")
|
49
|
-
|
59
|
+
|
50
60
|
click_link "Save / Publish"
|
51
61
|
click_button "Save Draft"
|
52
|
-
|
62
|
+
|
53
63
|
expect(page).to have_content(I18n.t('flash.posts.create.success'))
|
54
64
|
expect(Storytime::Page.count).to eq(page_count + 1)
|
55
65
|
|
56
66
|
pg = Storytime::Page.last
|
57
67
|
expect(pg.title).to eq("The Page")
|
58
|
-
expect(pg.draft_content).to eq("
|
68
|
+
expect(pg.draft_content).to eq("The content of my page")
|
59
69
|
expect(pg.user).to eq(current_user)
|
60
70
|
expect(pg.site).to eq(current_site)
|
61
71
|
expect(pg.type).to eq("Storytime::Page")
|
@@ -67,20 +77,20 @@ describe "In the dashboard, Pages" do
|
|
67
77
|
pg = FactoryGirl.create(:page, site: current_site, published_at: nil)
|
68
78
|
original_creator = pg.user
|
69
79
|
page_count = Storytime::Page.count
|
70
|
-
|
80
|
+
|
71
81
|
visit edit_dashboard_page_path(pg)
|
72
82
|
find('#post-title-input').set("The Story")
|
73
83
|
find('#medium-editor-post').set("It was a dark and stormy night...")
|
74
|
-
|
84
|
+
|
75
85
|
click_link "advanced-settings-panel-toggle"
|
76
86
|
click_button "Save Draft"
|
77
|
-
|
87
|
+
|
78
88
|
expect(page).to have_content(I18n.t('flash.posts.update.success'))
|
79
89
|
expect(Storytime::Page.count).to eq(page_count)
|
80
90
|
|
81
91
|
pg = Storytime::Page.last
|
82
92
|
expect(pg.title).to eq("The Story")
|
83
|
-
expect(pg.draft_content).to eq("
|
93
|
+
expect(pg.draft_content).to eq("It was a dark and stormy night...")
|
84
94
|
expect(pg.user).to eq(original_creator)
|
85
95
|
expect(pg.type).to eq("Storytime::Page")
|
86
96
|
expect(pg).to_not be_published
|
@@ -91,7 +101,7 @@ describe "In the dashboard, Pages" do
|
|
91
101
|
page_count = Storytime::Page.count
|
92
102
|
|
93
103
|
visit edit_dashboard_page_path(storytime_page)
|
94
|
-
|
104
|
+
|
95
105
|
click_button "post-utilities"
|
96
106
|
click_link "Delete"
|
97
107
|
|
@@ -99,5 +109,5 @@ describe "In the dashboard, Pages" do
|
|
99
109
|
expect { storytime_page.reload }.to raise_error
|
100
110
|
expect(Storytime::Page.count).to eq(page_count - 1)
|
101
111
|
end
|
102
|
-
|
112
|
+
|
103
113
|
end
|
@@ -1,10 +1,27 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe "In the dashboard, Posts" do
|
3
|
+
describe "In the dashboard, Posts", type: :feature do
|
4
4
|
before do
|
5
5
|
login_admin
|
6
6
|
end
|
7
7
|
|
8
|
+
it "lists all posts" do
|
9
|
+
blog = @current_site.blogs.first
|
10
|
+
FactoryGirl.create(:post, blog: blog, site: @current_site, published_at: nil)
|
11
|
+
2.times{ FactoryGirl.create(:post, blog: blog, site: @current_site, published_at: 1.hours.ago) }
|
12
|
+
static_page = FactoryGirl.create(:page)
|
13
|
+
|
14
|
+
visit url_for([storytime, :dashboard, blog, :blog_page_post_index, only_path: true])
|
15
|
+
|
16
|
+
within "#main" do
|
17
|
+
blog.posts.each do |p|
|
18
|
+
expect(page).to have_content(p.title)
|
19
|
+
end
|
20
|
+
|
21
|
+
expect(page).not_to have_content(static_page.title)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
8
25
|
it "lists draft posts" do
|
9
26
|
blog = @current_site.blogs.first
|
10
27
|
3.times{ FactoryGirl.create(:post, blog: blog, site: @current_site, published_at: nil) }
|
@@ -12,8 +29,8 @@ describe "In the dashboard, Posts" do
|
|
12
29
|
FactoryGirl.create(:post)
|
13
30
|
static_page = FactoryGirl.create(:page)
|
14
31
|
|
15
|
-
visit url_for([storytime, :dashboard, blog, :blog_page_post_index, only_path: true])
|
16
|
-
|
32
|
+
visit url_for([storytime, :dashboard, blog, :blog_page_post_index, draft: true, only_path: true])
|
33
|
+
|
17
34
|
within "#main" do
|
18
35
|
blog.posts.each do |p|
|
19
36
|
expect(page).to have_content(p.title) if p.published_at.nil?
|
@@ -23,7 +40,25 @@ describe "In the dashboard, Posts" do
|
|
23
40
|
expect(page).not_to have_content(static_page.title)
|
24
41
|
end
|
25
42
|
end
|
26
|
-
|
43
|
+
|
44
|
+
it "lists published posts" do
|
45
|
+
blog = @current_site.blogs.first
|
46
|
+
FactoryGirl.create(:post, blog: blog, site: @current_site, published_at: nil)
|
47
|
+
2.times{ FactoryGirl.create(:post, blog: blog, site: @current_site, published_at: 3.hours.ago) }
|
48
|
+
static_page = FactoryGirl.create(:page)
|
49
|
+
|
50
|
+
visit url_for([storytime, :dashboard, blog, :blog_page_post_index, published: true, only_path: true])
|
51
|
+
|
52
|
+
within "#main" do
|
53
|
+
blog.posts.each do |p|
|
54
|
+
expect(page).to_not have_content(p.title) if p.published_at.nil?
|
55
|
+
expect(page).to have_content(p.title) if p.published_at.present?
|
56
|
+
end
|
57
|
+
|
58
|
+
expect(page).not_to have_content(static_page.title)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
27
62
|
it "creates a post", js: true do
|
28
63
|
post_count = Storytime::BlogPost.count
|
29
64
|
media = FactoryGirl.create(:media)
|
@@ -32,20 +67,20 @@ describe "In the dashboard, Posts" do
|
|
32
67
|
|
33
68
|
find('#post-title-input').set("The Story")
|
34
69
|
find('#medium-editor-post').set("It was a dark and stormy night...")
|
35
|
-
|
70
|
+
|
36
71
|
click_link "Save / Publish"
|
37
72
|
|
38
73
|
fill_in "blog_post_excerpt", with: "It was a dark and stormy night..."
|
39
74
|
find("#featured_media_id", visible: false).set media.id
|
40
|
-
|
75
|
+
|
41
76
|
click_button "save-draft-submit"
|
42
|
-
|
77
|
+
|
43
78
|
expect(page).to have_content(I18n.t('flash.posts.create.success'))
|
44
79
|
expect(Storytime::BlogPost.count).to eq(post_count + 1)
|
45
80
|
|
46
81
|
post = Storytime::BlogPost.last
|
47
82
|
expect(post.title).to eq("The Story")
|
48
|
-
expect(post.draft_content).to eq("
|
83
|
+
expect(post.draft_content).to eq("It was a dark and stormy night...")
|
49
84
|
expect(post.user).to eq(current_user)
|
50
85
|
expect(post.type).to eq("Storytime::BlogPost")
|
51
86
|
expect(post.featured_media).to eq(media)
|
@@ -60,15 +95,15 @@ describe "In the dashboard, Posts" do
|
|
60
95
|
find('#post-title-input').set("Snow Crash")
|
61
96
|
find('#medium-editor-post').set("It was a dark and stormy night...")
|
62
97
|
find('#blog_post_excerpt', visible: false).set("It was a dark and stormy night...")
|
63
|
-
|
98
|
+
|
64
99
|
click_button "Preview"
|
65
|
-
|
100
|
+
|
66
101
|
expect(page).to have_content(I18n.t('flash.posts.create.success'))
|
67
102
|
expect(Storytime::BlogPost.count).to eq(post_count + 1)
|
68
103
|
|
69
104
|
post = Storytime::BlogPost.last
|
70
105
|
expect(post.title).to eq("Snow Crash")
|
71
|
-
expect(post.draft_content).to eq("
|
106
|
+
expect(post.draft_content).to eq("It was a dark and stormy night...")
|
72
107
|
expect(post.user).to eq(current_user)
|
73
108
|
expect(post.type).to eq("Storytime::BlogPost")
|
74
109
|
expect(post).to_not be_published
|
@@ -88,7 +123,7 @@ describe "In the dashboard, Posts" do
|
|
88
123
|
visit url_for([:edit, :dashboard, post, only_path: true])
|
89
124
|
|
90
125
|
find('#medium-editor-post').set("Some content to autosave")
|
91
|
-
|
126
|
+
|
92
127
|
page.execute_script "Storytime.instance.editor.editor.autosavePostForm()"
|
93
128
|
|
94
129
|
expect(page).to have_content("Draft saved at")
|
@@ -99,7 +134,7 @@ describe "In the dashboard, Posts" do
|
|
99
134
|
|
100
135
|
post.reload
|
101
136
|
expect(post.autosave).not_to be_nil
|
102
|
-
expect(post.autosave.content).to eq("
|
137
|
+
expect(post.autosave.content).to eq("Some content to autosave")
|
103
138
|
expect(Storytime::BlogPost.count).to eq(post_count)
|
104
139
|
end
|
105
140
|
|
@@ -122,7 +157,7 @@ describe "In the dashboard, Posts" do
|
|
122
157
|
post = post.reload
|
123
158
|
post.draft_content = nil # clear the cached copy of draft_content so it reloads
|
124
159
|
expect(post.title).to eq("The Story")
|
125
|
-
expect(post.draft_content).to eq("
|
160
|
+
expect(post.draft_content).to eq("It was a dark and stormy night...")
|
126
161
|
expect(post.user).to eq(original_creator)
|
127
162
|
expect(post).to_not be_published
|
128
163
|
end
|
@@ -134,10 +169,25 @@ describe "In the dashboard, Posts" do
|
|
134
169
|
|
135
170
|
post = Storytime::BlogPost.first
|
136
171
|
visit url_for([:edit, :dashboard, post, only_path: true])
|
137
|
-
|
172
|
+
|
138
173
|
expect{
|
139
174
|
click_button "post-utilities"
|
140
175
|
click_link "Delete"
|
141
176
|
}.to change(Storytime::BlogPost, :count).by(-1)
|
142
177
|
end
|
178
|
+
|
179
|
+
it "deletes a post from the index view", js: true do
|
180
|
+
blog = @current_site.blogs.first
|
181
|
+
3.times{ FactoryGirl.create(:post, blog: blog, site: @current_site, published_at: nil) }
|
182
|
+
expect(Storytime::BlogPost.count).to eq(3)
|
183
|
+
|
184
|
+
post = Storytime::BlogPost.first
|
185
|
+
visit url_for([storytime, :dashboard, blog, :blog_page_post_index, only_path: true])
|
186
|
+
|
187
|
+
expect{
|
188
|
+
find("#blogpost_#{post.id}").hover
|
189
|
+
click_link "delete_blogpost_#{post.id}"
|
190
|
+
expect(page).to_not have_selector "#blogpost_#{post.id}"
|
191
|
+
}.to change(Storytime::BlogPost, :count).by(-1)
|
192
|
+
end
|
143
193
|
end
|
@@ -1,24 +1,24 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe "In the dashboard, Sites" do
|
3
|
+
describe "In the dashboard, Sites", type: :feature do
|
4
4
|
|
5
5
|
it "creates a site" do
|
6
6
|
login FactoryGirl.create(:user), true
|
7
7
|
expect(Storytime::Site.count).to eq(0)
|
8
|
-
|
8
|
+
|
9
9
|
visit new_dashboard_site_path
|
10
10
|
|
11
11
|
fill_in "site_title", with: "The Site"
|
12
12
|
fill_in "site_custom_domain", with: "example.lvh.me"
|
13
13
|
fill_in "site_subscription_email_from", with: "test@example.com"
|
14
|
-
|
14
|
+
|
15
15
|
click_button "Save"
|
16
16
|
|
17
17
|
# since creating a site redirects you to a new domain, you are not logged in
|
18
18
|
fill_in "user_email", with: current_user.email
|
19
19
|
fill_in "user_password", with: current_user.password
|
20
20
|
click_on "Log in"
|
21
|
-
|
21
|
+
|
22
22
|
expect(page).to have_content("Pages")
|
23
23
|
expect(Storytime::Site.count).to eq(1)
|
24
24
|
|
@@ -39,7 +39,7 @@ describe "In the dashboard, Sites" do
|
|
39
39
|
click_link "site-settings-link"
|
40
40
|
fill_in "site_title", with: "The Site's New Name"
|
41
41
|
click_button "Save"
|
42
|
-
|
42
|
+
|
43
43
|
expect(page).to have_content("Your changes were saved successfully")
|
44
44
|
site.reload
|
45
45
|
expect(site.title).to eq "The Site's New Name"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe "In the dashboard, Snippets" do
|
4
|
-
before do
|
3
|
+
describe "In the dashboard, Snippets", type: :feature do
|
4
|
+
before do
|
5
5
|
login_admin
|
6
6
|
end
|
7
7
|
|
@@ -9,7 +9,7 @@ describe "In the dashboard, Snippets" do
|
|
9
9
|
3.times{ FactoryGirl.create(:snippet, site: @current_site) }
|
10
10
|
visit storytime.dashboard_url
|
11
11
|
find("#snippets-link").trigger('click')
|
12
|
-
|
12
|
+
|
13
13
|
within "#storytime-modal" do
|
14
14
|
Storytime::Snippet.all.each do |s|
|
15
15
|
expect(page).to have_link(s.name, href: url_for([:edit, :dashboard, s, only_path: true]))
|
@@ -17,7 +17,7 @@ describe "In the dashboard, Snippets" do
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
it "creates a snippet", js: true do
|
22
22
|
visit storytime.dashboard_url
|
23
23
|
find("#snippets-link").trigger('click')
|
@@ -59,7 +59,7 @@ describe "In the dashboard, Snippets" do
|
|
59
59
|
|
60
60
|
find("#snippet_#{snippet.id}").hover()
|
61
61
|
click_link "delete_snippet_#{snippet.id}"
|
62
|
-
|
62
|
+
|
63
63
|
within "#storytime-modal" do
|
64
64
|
expect(page).to_not have_content snippet.name
|
65
65
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe "In the dashboard, Subscriptions" do
|
3
|
+
describe "In the dashboard, Subscriptions", type: :feature do
|
4
4
|
before do
|
5
5
|
login_admin
|
6
6
|
end
|
@@ -27,7 +27,7 @@ describe "In the dashboard, Subscriptions" do
|
|
27
27
|
|
28
28
|
fill_in "subscription_email", with: "some_random_email@example.com"
|
29
29
|
click_button "Save"
|
30
|
-
|
30
|
+
|
31
31
|
within "#storytime-modal" do
|
32
32
|
expect(page).to have_content "some_random_email@example.com"
|
33
33
|
end
|
@@ -42,7 +42,7 @@ describe "In the dashboard, Subscriptions" do
|
|
42
42
|
visit storytime.dashboard_path
|
43
43
|
click_link "utility-menu-toggle"
|
44
44
|
click_link "subscriptions-link"
|
45
|
-
|
45
|
+
|
46
46
|
within "#storytime-modal" do
|
47
47
|
click_link "edit-subscription-#{subscription.id}"
|
48
48
|
end
|
@@ -53,8 +53,8 @@ describe "In the dashboard, Subscriptions" do
|
|
53
53
|
click_button "Save"
|
54
54
|
end
|
55
55
|
|
56
|
-
within "#storytime-modal" do
|
56
|
+
within "#storytime-modal" do
|
57
57
|
expect(page).to have_content "johndoe@example.com"
|
58
58
|
end
|
59
59
|
end
|
60
|
-
end
|
60
|
+
end
|
data/spec/features/pages_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe "Pages" do
|
3
|
+
describe "Pages", type: :feature do
|
4
4
|
before do
|
5
5
|
setup_site(FactoryGirl.create(:admin))
|
6
6
|
end
|
@@ -10,5 +10,5 @@ describe "Pages" do
|
|
10
10
|
visit url_for([pg, only_path: true])
|
11
11
|
page.should have_content(pg.content)
|
12
12
|
end
|
13
|
-
|
14
|
-
end
|
13
|
+
|
14
|
+
end
|
data/spec/features/posts_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe "Subscriptions" do
|
3
|
+
describe "Subscriptions", type: :feature do
|
4
4
|
before do
|
5
5
|
setup_site(FactoryGirl.create(:admin))
|
6
6
|
end
|
@@ -46,4 +46,4 @@ describe "Subscriptions" do
|
|
46
46
|
expect(subscription_1.subscribed?).to eq(false)
|
47
47
|
expect(subscription_2.subscribed?).to eq(true)
|
48
48
|
end
|
49
|
-
end
|
49
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'pry'
|
3
|
+
|
4
|
+
include Storytime::StorytimeHelpers
|
5
|
+
|
6
|
+
describe "Storytime::StorytimeHelpers", :type => :helper do
|
7
|
+
describe "storytime_snippet" do
|
8
|
+
before(:each) do
|
9
|
+
@site = FactoryGirl.create(:site)
|
10
|
+
expect_any_instance_of(Storytime::StorytimeHelpers).to receive(:current_storytime_site).at_least(:once).and_return(@site)
|
11
|
+
expect_any_instance_of(ApplicationHelper).to receive(:logged_in_storytime_user?).at_least(:once).and_return(false)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "when no snippet is found" do
|
15
|
+
it "creates snippet from I18n translation with same name" do
|
16
|
+
existing_translation = storytime_snippet("layout.title")
|
17
|
+
|
18
|
+
expect(storytime_snippet("layout.title")).to include("Storytime")
|
19
|
+
end
|
20
|
+
|
21
|
+
it "creates snippet with 'Lorem ipsum' placeholder text" do
|
22
|
+
missing_translation_div = storytime_snippet("nothing.here")
|
23
|
+
|
24
|
+
expect(missing_translation_div).to include("Lorem ipsum dolor sit amet, consectetur adipiscing elit...")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "when snippet is found" do
|
29
|
+
it "returns snippet partial" do
|
30
|
+
snippet = FactoryGirl.create(:snippet, site: @site)
|
31
|
+
snippet_div = storytime_snippet(snippet.name)
|
32
|
+
|
33
|
+
expect(snippet_div).to include(snippet.content)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Storytime::Navigation do
|
4
|
+
describe "#handle" do
|
5
|
+
it "parameterizes the title to set the handle" do
|
6
|
+
nav = FactoryGirl.create(:navigation, handle: nil)
|
7
|
+
expect(nav.handle).to eq nav.name.parameterize
|
8
|
+
end
|
9
|
+
|
10
|
+
it "parameterizes the handle" do
|
11
|
+
nav = FactoryGirl.create(:navigation, handle: "my Handle")
|
12
|
+
expect(nav.handle).to eq "my-handle"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "does not change the handle if the title changes" do
|
16
|
+
nav = FactoryGirl.create(:navigation, handle: "my Handle")
|
17
|
+
nav.update(name: "New Name")
|
18
|
+
expect(nav.handle).to eq "my-handle"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe "Root path" do
|
3
|
+
describe "Root path", type: :request do
|
4
4
|
it "routes to blog_homepage#show when site homepage is a blog" do
|
5
5
|
site = FactoryGirl.create(:site)
|
6
6
|
user = FactoryGirl.create(:admin)
|
@@ -22,21 +22,21 @@ describe "Root path" do
|
|
22
22
|
site.save
|
23
23
|
|
24
24
|
get "/"
|
25
|
-
|
25
|
+
|
26
26
|
expect(request.params[:controller]).to eq("storytime/homepage")
|
27
27
|
expect(request.params[:action]).to eq("show")
|
28
28
|
expect(response.body).to match(home_page.title)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
describe "Post path" do
|
32
|
+
describe "Post path", type: :request do
|
33
33
|
it "uses /posts/post-slug when site#post_slug_style is default" do
|
34
34
|
site = FactoryGirl.create(:site, post_slug_style: :default, custom_domain: "www.example.com")
|
35
35
|
post = FactoryGirl.create(:post, site: site)
|
36
36
|
expect(storytime.post_path(post)).to eq("/posts/#{post.slug}")
|
37
37
|
|
38
38
|
get url_for([post, only_path: true])
|
39
|
-
|
39
|
+
|
40
40
|
expect(request.params[:controller]).to eq("storytime/posts")
|
41
41
|
expect(request.params[:action]).to eq("show")
|
42
42
|
expect(request.params[:id]).to eq(post.slug)
|
@@ -46,11 +46,11 @@ describe "Post path" do
|
|
46
46
|
site = FactoryGirl.create(:site, post_slug_style: :day_and_name, custom_domain: "www.example.com")
|
47
47
|
post = FactoryGirl.create(:post, site: site)
|
48
48
|
date = post.created_at.to_date
|
49
|
-
|
49
|
+
|
50
50
|
expect(url_for([post, only_path: true])).to eq("/#{date.year}/#{date.strftime('%m')}/#{date.strftime('%d')}/#{post.slug}")
|
51
51
|
|
52
52
|
get url_for([post, only_path: true])
|
53
|
-
|
53
|
+
|
54
54
|
expect(request.params[:controller]).to eq("storytime/posts")
|
55
55
|
expect(request.params[:action]).to eq("show")
|
56
56
|
expect(request.params[:id]).to eq(post.slug)
|
@@ -63,7 +63,7 @@ describe "Post path" do
|
|
63
63
|
expect(url_for([post, only_path: true])).to eq("/#{date.year}/#{date.strftime('%m')}/#{post.slug}")
|
64
64
|
|
65
65
|
get url_for([post, only_path: true])
|
66
|
-
|
66
|
+
|
67
67
|
expect(request.params[:controller]).to eq("storytime/posts")
|
68
68
|
expect(request.params[:action]).to eq("show")
|
69
69
|
expect(request.params[:id]).to eq(post.slug)
|
@@ -75,7 +75,7 @@ describe "Post path" do
|
|
75
75
|
expect(url_for([post, only_path: true])).to eq("/posts/#{post.id}")
|
76
76
|
|
77
77
|
get url_for([post, only_path: true])
|
78
|
-
|
78
|
+
|
79
79
|
expect(request.params[:controller]).to eq("storytime/posts")
|
80
80
|
expect(request.params[:action]).to eq("show")
|
81
81
|
expect(request.params[:id]).to eq(post.id.to_s)
|