lastish from the api changes (coverage not 100) and change reset
This commit is contained in:
parent
ac18050586
commit
ba022b5259
@ -18,19 +18,19 @@ module Merged
|
|||||||
else
|
else
|
||||||
@card.move_down
|
@card.move_down
|
||||||
end
|
end
|
||||||
@card.save(current_member)
|
@card.edit_save(current_member)
|
||||||
redirect_to section_cards_url(@card.section.id),notice: "#{@card.header} moved"
|
redirect_to section_cards_url(@card.section.id),notice: "#{@card.header} moved"
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@section = Section.find(params[:section_id])
|
@section = Section.find(params[:section_id])
|
||||||
new_card = @section.new_card
|
new_card = @section.new_card
|
||||||
new_card.save(current_member.email)
|
new_card.add_save(current_member.email)
|
||||||
redirect_to section_cards_url(@section.id) , notice: "Card created"
|
redirect_to section_cards_url(@section.id) , notice: "Card created"
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@card.destroy
|
@card.delete_save!
|
||||||
redirect_to section_cards_url(@card.section.id) , notice: "#{@card.header} removed"
|
redirect_to section_cards_url(@card.section.id) , notice: "#{@card.header} removed"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -9,15 +9,34 @@ module Merged
|
|||||||
end
|
end
|
||||||
|
|
||||||
def commit
|
def commit
|
||||||
raise "must have message" if params[:message].blank?
|
if params[:message].blank?
|
||||||
|
message = "must have message"
|
||||||
|
redirect_to changes_index_url , alert: message
|
||||||
|
else
|
||||||
git = Git.open(Rails.root)
|
git = Git.open(Rails.root)
|
||||||
git.add("merged")
|
git.add("merged")
|
||||||
git.add( Image.root )
|
git.add( Image.root )
|
||||||
begin
|
begin
|
||||||
|
g.config('user.email', current_member.email)
|
||||||
git.commit(params[:message])
|
git.commit(params[:message])
|
||||||
|
redirect_to changes_index_url , notice: "Changes commited"
|
||||||
rescue
|
rescue
|
||||||
end
|
redirect_to changes_index_url , notice: "Error occurred"
|
||||||
redirect_to changes_index_url
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def reset
|
||||||
|
git = Git.open(Rails.root)
|
||||||
|
begin
|
||||||
|
git.checkout_file("HEAD" , "merged")
|
||||||
|
ChangeSet.current.zero
|
||||||
|
message = "Changes reset"
|
||||||
|
rescue
|
||||||
|
message = "Unknown error occured"
|
||||||
|
end
|
||||||
|
redirect_to changes_index_url , notice: message
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@ -12,28 +12,30 @@ module Merged
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
if( !params[:name].blank? && (params[:name] != @page.name))
|
||||||
@page.add_redirect
|
@page.add_redirect
|
||||||
@page.name = params[:name]
|
@page.name = params[:name]
|
||||||
@page.save(current_member.email)
|
@page.edit_save(current_member.email)
|
||||||
redirect_to page_url(@page) , notice: "Page renamed"
|
message = "Page renamed"
|
||||||
|
end
|
||||||
|
redirect_to page_url(@page) , notice: message
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
name = params[:name]
|
name = params[:name]
|
||||||
message = "Must enter name" if name.blank?
|
if( name.blank? )
|
||||||
if( ! message.nil?)
|
|
||||||
@page = Page.new_page(name)
|
|
||||||
@page.save(current_member.email)
|
|
||||||
redirect_to new_page_section_url(@page.id) , notice: "Page was successfully created."
|
|
||||||
else
|
|
||||||
@pages = Page.all
|
@pages = Page.all
|
||||||
flash.now.alert = message
|
flash.now.alert = "Must enter name"
|
||||||
render :index
|
render :index
|
||||||
|
else
|
||||||
|
@page = Page.new_page(name)
|
||||||
|
@page.add_save(current_member.email)
|
||||||
|
redirect_to new_page_section_url(@page.id) , notice: "Page was successfully created."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@page.destroy()
|
@page.delete()
|
||||||
redirect_to pages_url, notice: "Page #{@page.name} was removed."
|
redirect_to pages_url, notice: "Page #{@page.name} was removed."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ module Merged
|
|||||||
page = Page.find(params[:page_id])
|
page = Page.find(params[:page_id])
|
||||||
template = params[:template]
|
template = params[:template]
|
||||||
new_section = page.new_section(template)
|
new_section = page.new_section(template)
|
||||||
new_section.save(current_member.email)
|
new_section.add_save(current_member.email)
|
||||||
if(template.blank?) # new
|
if(template.blank?) # new
|
||||||
redirect_to section_select_template_url(new_section.id), notice: "New section created"
|
redirect_to section_select_template_url(new_section.id), notice: "New section created"
|
||||||
else # copy
|
else # copy
|
||||||
@ -28,13 +28,13 @@ module Merged
|
|||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@section.destroy()
|
@section.delete
|
||||||
redirect_to page_sections_url(@section.page.id) , notice: "Section #{@section.header} removed"
|
redirect_to page_sections_url(@section.page.id) , notice: "Section #{@section.header} removed"
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_image
|
def set_image
|
||||||
@section.image_id = params[:image_id].to_i
|
@section.image_id = params[:image_id].to_i
|
||||||
@section.save
|
@section.edit_save(current_member.email)
|
||||||
redirect_to section_url(@section.id) , notice: "Image selected: #{@section.image.name}"
|
redirect_to section_url(@section.id) , notice: "Image selected: #{@section.image.name}"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ module Merged
|
|||||||
template = params[:template]
|
template = params[:template]
|
||||||
raise "no template given" if template.blank?
|
raise "no template given" if template.blank?
|
||||||
@section.set_template( template )
|
@section.set_template( template )
|
||||||
@section.save
|
@section.edit_save(current_member.email)
|
||||||
redirect_to section_url(@section.id)
|
redirect_to section_url(@section.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ module Merged
|
|||||||
card_template = params[:card_template]
|
card_template = params[:card_template]
|
||||||
raise "no card template given" if card_template.blank?
|
raise "no card template given" if card_template.blank?
|
||||||
@section.card_template = card_template
|
@section.card_template = card_template
|
||||||
@section.save
|
@section.edit_save(current_member.email)
|
||||||
redirect_to section_url(@section.id)
|
redirect_to section_url(@section.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ module Merged
|
|||||||
else
|
else
|
||||||
@section.move_down
|
@section.move_down
|
||||||
end
|
end
|
||||||
@section.save
|
@section.edit_save(current_member.email)
|
||||||
redirect_to page_sections_url(@section.page.id)
|
redirect_to page_sections_url(@section.page.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ module Merged
|
|||||||
@section.option_definitions.each do |option|
|
@section.option_definitions.each do |option|
|
||||||
@section.set_option(option.name, options[option.name])
|
@section.set_option(option.name, options[option.name])
|
||||||
end if options
|
end if options
|
||||||
@section.save(current_member.email)
|
@section.edit_save(current_member.email)
|
||||||
redirect_to :section , notice: "Update ok"
|
redirect_to :section , notice: "Update ok"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -28,9 +28,9 @@
|
|||||||
- changeset(type , element).each do |name|
|
- changeset(type , element).each do |name|
|
||||||
%span=name.last
|
%span=name.last
|
||||||
|
|
||||||
.flex.flex-col.bg-white
|
.grid.grid-cols-3.bg-white
|
||||||
.flex.items-center.justify-center.flex-1
|
.items-center.justify-center.col-span-2
|
||||||
.max-w-xl.px-4.py-8.mx-auto.text-center
|
.max-w-xl.px-4.py-8.mx-auto.text-center.commit_changes
|
||||||
= form_tag( merged.changes_commit_path() , {method: :post } ) do
|
= form_tag( merged.changes_commit_path() , {method: :post } ) do
|
||||||
%h1.text-2xl.font-bold.tracking-tight.text-gray-900.sm:text-4xl
|
%h1.text-2xl.font-bold.tracking-tight.text-gray-900.sm:text-4xl
|
||||||
Commit changes
|
Commit changes
|
||||||
@ -39,3 +39,9 @@
|
|||||||
%h4.text-lg.font-bold Message (short summary of changes)
|
%h4.text-lg.font-bold Message (short summary of changes)
|
||||||
= text_field_tag( :message , "", class: "block w-full rounded-lg border-gray-200 p-4 pr-12 text-sm shadow-sm")
|
= text_field_tag( :message , "", class: "block w-full rounded-lg border-gray-200 p-4 pr-12 text-sm shadow-sm")
|
||||||
=submit_button( "Commit")
|
=submit_button( "Commit")
|
||||||
|
|
||||||
|
.max-w-xl.px-4.py-8.mx-auto.text-center.reset_changes
|
||||||
|
= form_tag( merged.changes_reset_path() , {method: :post } ) do
|
||||||
|
%h1.text-2xl.font-bold.tracking-tight.text-gray-900.sm:text-4xl
|
||||||
|
Reset changes
|
||||||
|
=submit_button( "Reset" ,true)
|
||||||
|
@ -63,7 +63,7 @@
|
|||||||
.relative.block
|
.relative.block
|
||||||
%p
|
%p
|
||||||
= green_button( "New Section" , merged.new_page_section_path(@page.id) )
|
= green_button( "New Section" , merged.new_page_section_path(@page.id) )
|
||||||
.relative.block
|
.relative.block.delete_page
|
||||||
%p
|
%p
|
||||||
= form_tag( merged.page_path(@page.id) , {method: :delete } ) do
|
= form_tag( merged.page_path(@page.id) , {method: :delete } ) do
|
||||||
=submit_button( "Delete Page" , true)
|
=submit_button( "Delete Page" , true)
|
||||||
|
@ -2,6 +2,7 @@ Merged::Engine.routes.draw do
|
|||||||
|
|
||||||
get 'changes/index'
|
get 'changes/index'
|
||||||
post 'changes/commit'
|
post 'changes/commit'
|
||||||
|
post 'changes/reset'
|
||||||
get "styles/index"
|
get "styles/index"
|
||||||
|
|
||||||
post 'form/sendit'
|
post 'form/sendit'
|
||||||
|
@ -36,6 +36,7 @@ class PagesWrite < ActionDispatch::IntegrationTest
|
|||||||
within(".new_page") do
|
within(".new_page") do
|
||||||
click_on ("New Page")
|
click_on ("New Page")
|
||||||
end
|
end
|
||||||
|
assert_equal "/merged/pages" , current_path
|
||||||
end
|
end
|
||||||
def test_new_works_with_name
|
def test_new_works_with_name
|
||||||
visit "/merged/pages"
|
visit "/merged/pages"
|
||||||
@ -43,6 +44,17 @@ class PagesWrite < ActionDispatch::IntegrationTest
|
|||||||
fill_in 'Name', with: 'New Page'
|
fill_in 'Name', with: 'New Page'
|
||||||
click_on ("New Page")
|
click_on ("New Page")
|
||||||
end
|
end
|
||||||
|
assert_equal "/merged/sections/41/select_template" , current_path
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_delete_works
|
||||||
|
id = Merged::Page.first.id
|
||||||
|
visit merged.page_sections_path(id)
|
||||||
|
within(".delete_page") do
|
||||||
|
click_on ("Delete Page")
|
||||||
|
end
|
||||||
|
assert_equal "/merged/pages" , current_path
|
||||||
|
assert_raise(ActiveHash::RecordNotFound) {visit merged.page_path(id)}
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user