Skip to content

Commit

Permalink
ページ作成機能:管理画面:プレビュー機能
Browse files Browse the repository at this point in the history
  • Loading branch information
appirits-ymatsumoto committed Jun 5, 2015
1 parent a18100d commit 2ea8777
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions backend/app/controllers/comable/admin/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def new
end

def edit
set_preview_session
end

def create
Expand Down Expand Up @@ -56,6 +57,11 @@ def page_params
:published_at # 公開日時
)
end

def set_preview_session
session[Comable::Page::PREVIEW_SESSION_KEY] ||= {}
session[Comable::Page::PREVIEW_SESSION_KEY][@page.slug] = true
end
end
end
end
2 changes: 1 addition & 1 deletion backend/app/views/comable/admin/pages/edit.slim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
i.fa.fa-bars
ul.dropdown-menu.dropdown-menu-right
li
= link_to comable.admin_page_path(@page) do
= link_to comable.page_path(slug: @page.slug) do
span.fa.fa-external-link>
= Comable.t('admin.preview')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
get :edit, id: page.to_param
expect(assigns(:page)).to eq(page)
end

it 'create preview session' do
page = create(:page)
get :edit, id: page.to_param
expect(session[Comable::Page::PREVIEW_SESSION_KEY][page.slug]).to eq(true)
end
end

describe 'POST create' do
Expand Down

0 comments on commit 2ea8777

Please sign in to comment.