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
|
||||
@card.move_down
|
||||
end
|
||||
@card.save(current_member)
|
||||
@card.edit_save(current_member)
|
||||
redirect_to section_cards_url(@card.section.id),notice: "#{@card.header} moved"
|
||||
end
|
||||
|
||||
def new
|
||||
@section = Section.find(params[:section_id])
|
||||
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"
|
||||
end
|
||||
|
||||
def destroy
|
||||
@card.destroy
|
||||
@card.delete_save!
|
||||
redirect_to section_cards_url(@card.section.id) , notice: "#{@card.header} removed"
|
||||
end
|
||||
|
||||
|
@ -9,15 +9,34 @@ module Merged
|
||||
end
|
||||
|
||||
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.add("merged")
|
||||
git.add( Image.root )
|
||||
begin
|
||||
g.config('user.email', current_member.email)
|
||||
git.commit(params[:message])
|
||||
redirect_to changes_index_url , notice: "Changes commited"
|
||||
rescue
|
||||
redirect_to changes_index_url , notice: "Error occurred"
|
||||
end
|
||||
redirect_to changes_index_url
|
||||
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
|
||||
|
||||
def update
|
||||
if( !params[:name].blank? && (params[:name] != @page.name))
|
||||
@page.add_redirect
|
||||
@page.name = params[:name]
|
||||
@page.save(current_member.email)
|
||||
redirect_to page_url(@page) , notice: "Page renamed"
|
||||
@page.edit_save(current_member.email)
|
||||
message = "Page renamed"
|
||||
end
|
||||
redirect_to page_url(@page) , notice: message
|
||||
end
|
||||
|
||||
def create
|
||||
name = params[:name]
|
||||
message = "Must enter name" 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
|
||||
if( name.blank? )
|
||||
@pages = Page.all
|
||||
flash.now.alert = message
|
||||
flash.now.alert = "Must enter name"
|
||||
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
|
||||
|
||||
def destroy
|
||||
@page.destroy()
|
||||
@page.delete()
|
||||
redirect_to pages_url, notice: "Page #{@page.name} was removed."
|
||||
end
|
||||
|
||||
|
@ -19,7 +19,7 @@ module Merged
|
||||
page = Page.find(params[:page_id])
|
||||
template = params[:template]
|
||||
new_section = page.new_section(template)
|
||||
new_section.save(current_member.email)
|
||||
new_section.add_save(current_member.email)
|
||||
if(template.blank?) # new
|
||||
redirect_to section_select_template_url(new_section.id), notice: "New section created"
|
||||
else # copy
|
||||
@ -28,13 +28,13 @@ module Merged
|
||||
end
|
||||
|
||||
def destroy
|
||||
@section.destroy()
|
||||
@section.delete
|
||||
redirect_to page_sections_url(@section.page.id) , notice: "Section #{@section.header} removed"
|
||||
end
|
||||
|
||||
def set_image
|
||||
@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}"
|
||||
end
|
||||
|
||||
@ -42,7 +42,7 @@ module Merged
|
||||
template = params[:template]
|
||||
raise "no template given" if template.blank?
|
||||
@section.set_template( template )
|
||||
@section.save
|
||||
@section.edit_save(current_member.email)
|
||||
redirect_to section_url(@section.id)
|
||||
end
|
||||
|
||||
@ -50,7 +50,7 @@ module Merged
|
||||
card_template = params[:card_template]
|
||||
raise "no card template given" if card_template.blank?
|
||||
@section.card_template = card_template
|
||||
@section.save
|
||||
@section.edit_save(current_member.email)
|
||||
redirect_to section_url(@section.id)
|
||||
end
|
||||
|
||||
@ -60,7 +60,7 @@ module Merged
|
||||
else
|
||||
@section.move_down
|
||||
end
|
||||
@section.save
|
||||
@section.edit_save(current_member.email)
|
||||
redirect_to page_sections_url(@section.page.id)
|
||||
end
|
||||
|
||||
@ -74,7 +74,7 @@ module Merged
|
||||
@section.option_definitions.each do |option|
|
||||
@section.set_option(option.name, options[option.name])
|
||||
end if options
|
||||
@section.save(current_member.email)
|
||||
@section.edit_save(current_member.email)
|
||||
redirect_to :section , notice: "Update ok"
|
||||
end
|
||||
|
||||
|
@ -28,9 +28,9 @@
|
||||
- changeset(type , element).each do |name|
|
||||
%span=name.last
|
||||
|
||||
.flex.flex-col.bg-white
|
||||
.flex.items-center.justify-center.flex-1
|
||||
.max-w-xl.px-4.py-8.mx-auto.text-center
|
||||
.grid.grid-cols-3.bg-white
|
||||
.items-center.justify-center.col-span-2
|
||||
.max-w-xl.px-4.py-8.mx-auto.text-center.commit_changes
|
||||
= form_tag( merged.changes_commit_path() , {method: :post } ) do
|
||||
%h1.text-2xl.font-bold.tracking-tight.text-gray-900.sm:text-4xl
|
||||
Commit changes
|
||||
@ -39,3 +39,9 @@
|
||||
%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")
|
||||
=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
|
||||
%p
|
||||
= green_button( "New Section" , merged.new_page_section_path(@page.id) )
|
||||
.relative.block
|
||||
.relative.block.delete_page
|
||||
%p
|
||||
= form_tag( merged.page_path(@page.id) , {method: :delete } ) do
|
||||
=submit_button( "Delete Page" , true)
|
||||
|
@ -2,6 +2,7 @@ Merged::Engine.routes.draw do
|
||||
|
||||
get 'changes/index'
|
||||
post 'changes/commit'
|
||||
post 'changes/reset'
|
||||
get "styles/index"
|
||||
|
||||
post 'form/sendit'
|
||||
|
@ -36,6 +36,7 @@ class PagesWrite < ActionDispatch::IntegrationTest
|
||||
within(".new_page") do
|
||||
click_on ("New Page")
|
||||
end
|
||||
assert_equal "/merged/pages" , current_path
|
||||
end
|
||||
def test_new_works_with_name
|
||||
visit "/merged/pages"
|
||||
@ -43,6 +44,17 @@ class PagesWrite < ActionDispatch::IntegrationTest
|
||||
fill_in 'Name', with: 'New Page'
|
||||
click_on ("New Page")
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user