diff --git a/Gemfile b/Gemfile index 3741cb2..974c397 100644 --- a/Gemfile +++ b/Gemfile @@ -5,11 +5,11 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } gemspec gem 'sprockets-rails', require: 'sprockets/railtie' -gem 'rspec-rails' , require: "rspec-rails" gem 'haml-rails' , require: "haml-rails" gem "tailwindcss-rails" gem "importmap-rails" gem "sprockets-rails" +gem "devise" gem "ruby2js" , path: "../ruby2js" @@ -19,6 +19,8 @@ group :development, :test do gem "selenium-webdriver" gem "webdrivers" gem "puma" + gem 'rspec-rails' , require: "rspec-rails" + gem 'guard-minitest' end # Start debugger with binding.b [https://github.com/ruby/debug] diff --git a/Gemfile.lock b/Gemfile.lock index c91beff..e23a806 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -90,6 +90,7 @@ GEM addressable (2.8.1) public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) + bcrypt (3.1.18) builder (3.2.4) capybara (3.38.0) addressable @@ -103,6 +104,12 @@ GEM coderay (1.1.3) concurrent-ruby (1.1.10) crass (1.0.6) + devise (4.8.1) + bcrypt (~> 3.0) + orm_adapter (~> 0.1) + railties (>= 4.1.0) + responders + warden (~> 1.2.3) diff-lcs (1.5.0) erubi (1.11.0) ffi (1.15.5) @@ -122,6 +129,9 @@ GEM shellany (~> 0.0) thor (>= 0.18.1) guard-compat (1.2.1) + guard-minitest (2.4.6) + guard-compat (~> 1.2) + minitest (>= 3.0) guard-rspec (4.7.3) guard (~> 2.1) guard-compat (~> 1.1) @@ -170,6 +180,7 @@ GEM notiffany (0.1.3) nenv (~> 0.1) shellany (~> 0.0) + orm_adapter (0.5.0) parser (3.1.3.0) ast (~> 2.4.1) pry (0.14.1) @@ -215,6 +226,9 @@ GEM rchardet (1.8.0) redcarpet (3.5.1) regexp_parser (2.1.1) + responders (3.0.1) + actionpack (>= 5.0) + railties (>= 5.0) rexml (3.2.5) rspec (3.12.0) rspec-core (~> 3.12.0) @@ -258,6 +272,8 @@ GEM timeout (0.3.0) tzinfo (2.0.5) concurrent-ruby (~> 1.0) + warden (1.2.9) + rack (>= 2.0.9) webdrivers (5.2.0) nokogiri (~> 1.6) rubyzip (>= 1.3.0) @@ -275,6 +291,8 @@ PLATFORMS DEPENDENCIES capybara + devise + guard-minitest guard-rspec haml-rails importmap-rails diff --git a/Guardfile b/Guardfile index a49b5ac..92e8462 100644 --- a/Guardfile +++ b/Guardfile @@ -24,6 +24,14 @@ # * zeus: 'zeus rspec' (requires the server to be started separately) # * 'just' rspec: 'rspec' + +guard :minitest do + # with Minitest::Unit + watch(%r{^test/(.*)\/?(.*)_test\.rb$}) + watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}#{m[2]}_test.rb" } + watch(%r{^test/test_helper\.rb$}) { 'test' } +end + guard :rspec, cmd: "bundle exec rspec" do require "guard/rspec/dsl" dsl = Guard::RSpec::Dsl.new(self) diff --git a/app/controllers/merged/cards_controller.rb b/app/controllers/merged/cards_controller.rb index eee004d..ba9f88d 100644 --- a/app/controllers/merged/cards_controller.rb +++ b/app/controllers/merged/cards_controller.rb @@ -45,7 +45,7 @@ module Merged @card.option_definitions.each do |option| @card.set_option(option.name, options[option.name]) end if options - @card.save + @card.save(current_member) redirect_to section_cards_url(@card.section.id) , notice: "Updated #{@card.header}" end diff --git a/app/controllers/merged/sections_controller.rb b/app/controllers/merged/sections_controller.rb index 2af7f49..56c9e12 100644 --- a/app/controllers/merged/sections_controller.rb +++ b/app/controllers/merged/sections_controller.rb @@ -75,7 +75,7 @@ module Merged @section.option_definitions.each do |option| @section.set_option(option.name, options[option.name]) end if options - @section.save + @section.save(current_member.email) redirect_to :section , notice: "Update ok" end diff --git a/app/models/merged/page.rb b/app/models/merged/page.rb index ecae9d3..6180b9c 100644 --- a/app/models/merged/page.rb +++ b/app/models/merged/page.rb @@ -60,11 +60,10 @@ module Merged [has_sections , has_cards] end - def save + def save(editor) olds = self.redirects.to_s.split(" ") olds.delete( self.name.to_s ) self.redirects = olds.join(" ") - updated_at = Time.now super end diff --git a/app/models/merged/view_base.rb b/app/models/merged/view_base.rb index 0b1cc89..334b4b1 100644 --- a/app/models/merged/view_base.rb +++ b/app/models/merged/view_base.rb @@ -12,6 +12,12 @@ module Merged fields :options , :updated_at , :updated_by + def save( editor ) + self.updated_at = Time.now + self.updated_by = editor + super() + end + def has_option?(option) options.has_key?(option) and !options[option].blank? end diff --git a/app/views/merged/sections/show.haml b/app/views/merged/sections/show.haml index 495cf04..6751e35 100644 --- a/app/views/merged/sections/show.haml +++ b/app/views/merged/sections/show.haml @@ -22,7 +22,7 @@ = yellow_button("Change Image", merged.images_path(section_id: @section.id)) = red_button( "Remove image", merged.section_set_image_path( @section.id , image: "")) - .basis-80.grow + .basis-80.grow.content_update = section_form( class: "mx-auto mt-8 mb-0 max-w space-y-4") do %label.block %h4.text-lg.font-bold Header diff --git a/spec/features/merged/section_spec.rb b/spec/features/merged/section_spec.rb index 2dd100c..598fee2 100644 --- a/spec/features/merged/section_spec.rb +++ b/spec/features/merged/section_spec.rb @@ -17,5 +17,15 @@ RSpec.feature "Sections", type: :feature do find_link("Edit").click end end + + describe "show page" do + it "returns http success" do + visit "/merged/pages" + click_on ("index") + within("#section_31") do + find_link("Edit").click + end + end + end end end