create members

This commit is contained in:
Torsten 2022-12-20 17:05:26 +02:00
parent 3c0d125990
commit d2890636fd
19 changed files with 308 additions and 27 deletions

View File

@ -13,6 +13,8 @@ gem "sassc-rails"
gem 'haml-rails'
gem "ruby2js" , path: "../ruby2js"
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2"

View File

@ -8,6 +8,14 @@ PATH
mini_magick
rails (>= 7.0.4)
redcarpet
ruby2js (~> 5.0, >= 5.0.1)
PATH
remote: ../ruby2js
specs:
ruby2js (5.0.1)
parser
regexp_parser (~> 2.1.1)
GEM
remote: https://rubygems.org/
@ -81,8 +89,9 @@ GEM
tzinfo (~> 2.0)
addressable (2.8.1)
public_suffix (>= 2.0.2, < 6.0)
ast (2.4.2)
bindex (0.8.1)
bootsnap (1.14.0)
bootsnap (1.15.0)
msgpack (~> 1.2)
builder (3.2.4)
capybara (3.38.0)
@ -94,18 +103,18 @@ GEM
rack-test (>= 0.6.3)
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
childprocess (4.1.0)
coderay (1.1.3)
concurrent-ruby (1.1.10)
crass (1.0.6)
debug (1.6.3)
irb (>= 1.3.6)
date (3.3.2)
debug (1.7.0)
irb (>= 1.5.0)
reline (>= 0.3.1)
diff-lcs (1.5.0)
erubi (1.11.0)
ffi (1.15.5)
formatador (1.1.0)
git (1.12.0)
git (1.13.0)
addressable (~> 2.8)
rchardet (~> 1.8)
globalid (1.0.0)
@ -124,7 +133,7 @@ GEM
guard (~> 2.1)
guard-compat (~> 1.1)
rspec (>= 2.99.0, < 4.0)
haml (6.0.12)
haml (6.1.1)
temple (>= 0.8.2)
thor
tilt
@ -138,13 +147,13 @@ GEM
importmap-rails (1.1.5)
actionpack (>= 6.0.0)
railties (>= 6.0.0)
io-console (0.5.11)
irb (1.5.0)
io-console (0.6.0)
irb (1.6.1)
reline (>= 0.3.0)
listen (3.7.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
loofah (2.19.0)
loofah (2.19.1)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
lumberjack (1.2.8)
@ -164,21 +173,24 @@ GEM
minitest (5.16.3)
msgpack (1.6.0)
nenv (0.3.0)
net-imap (0.3.1)
net-imap (0.3.2)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.0)
net-protocol (0.2.1)
timeout
net-smtp (0.3.3)
net-protocol
nio4r (2.5.8)
nokogiri (1.13.9-x86_64-linux)
nokogiri (1.13.10-x86_64-linux)
racc (~> 1.4)
notiffany (0.1.3)
nenv (~> 0.1)
shellany (~> 0.0)
open4 (1.3.4)
parser (3.1.3.0)
ast (~> 2.4.1)
passenger (6.0.15)
rack
rake (>= 0.8.1)
@ -210,8 +222,8 @@ GEM
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.4.3)
loofah (~> 2.3)
rails-html-sanitizer (1.4.4)
loofah (~> 2.19, >= 2.19.1)
railties (7.0.4)
actionpack (= 7.0.4)
activesupport (= 7.0.4)
@ -225,8 +237,8 @@ GEM
ffi (~> 1.0)
rchardet (1.8.0)
redcarpet (3.5.1)
regexp_parser (2.6.1)
reline (0.3.1)
regexp_parser (2.1.1)
reline (0.3.2)
io-console (~> 0.5)
rexml (3.2.5)
rspec (3.12.0)
@ -235,10 +247,10 @@ GEM
rspec-mocks (~> 3.12.0)
rspec-core (3.12.0)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.0)
rspec-expectations (3.12.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.0)
rspec-mocks (3.12.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.0)
@ -251,8 +263,7 @@ GEM
sprockets (> 3.0)
sprockets-rails
tilt
selenium-webdriver (4.6.1)
childprocess (>= 0.5, < 5.0)
selenium-webdriver (4.7.1)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
@ -305,6 +316,7 @@ DEPENDENCIES
pg (~> 1.1)
puma (~> 5.0)
rails (~> 7.0.4)
ruby2js!
sassc-rails
selenium-webdriver
sprockets-rails

View File

@ -0,0 +1,58 @@
class MembersController < ApplicationController
before_action :set_member, only: %i[ show edit update destroy ]
# GET /members
def index
@members = Member.all
end
# GET /members/1
def show
end
# GET /members/new
def new
@member = Member.new
end
# GET /members/1/edit
def edit
end
# POST /members
def create
@member = Member.new(member_params)
if @member.save
redirect_to @member, notice: "Member was successfully created."
else
render :new, status: :unprocessable_entity
end
end
# PATCH/PUT /members/1
def update
if @member.update(member_params)
redirect_to @member, notice: "Member was successfully updated."
else
render :edit, status: :unprocessable_entity
end
end
# DELETE /members/1
def destroy
@member.destroy
redirect_to members_url, notice: "Member was successfully destroyed."
end
private
# Use callbacks to share common setup or constraints between actions.
def set_member
@member = Member.find(params[:id])
end
# Only allow a list of trusted parameters through.
def member_params
params.require(:member).permit(:name, :public)
end
end

View File

@ -0,0 +1,2 @@
module MembersHelper
end

2
app/models/member.rb Normal file
View File

@ -0,0 +1,2 @@
class Member < ApplicationRecord
end

View File

@ -1,7 +1,7 @@
%footer.bg-white{"aria-label" => "Site Footer"}
.max-w-screen-xl.px-4.py-16.mx-auto.sm:px-6.lg:px-8
.lg:flex.lg:items-start.lg:gap-8
%a.inline-flex.items-center{"aria-label" => "Hub Feenix", :href => "/", :title => "Company"}
%a.inline-flex.items-center{"aria-label" => "Hub Feenix", :href => "/", :title => "Hub Feenix"}
= image_tag("feenix_lintu" , class: "h-20")
.grid.grid-cols-2.gap-8.mt-8.lg:mt-0.lg:grid-cols-5.lg:gap-y-16
.col-span-2
@ -27,14 +27,14 @@
=main.capitalize
.col-span-2.sm:col-span-1
%p.font-medium.text-gray-900 Hub Feenix
%nav.mt-6{"aria-label" => "Footer Navigation - Company"}
%nav.mt-6{"aria-label" => "Footer Navigation - Hub Feenix"}
%ul.space-y-4.text-sm
%li
%a.text-gray-700.transition.hover:opacity-75{:href => "/about"}
About
.col-span-2.sm:col-span-1
%p.font-medium.text-gray-900 Event Spaces
%nav.mt-6{"aria-label" => "Footer Navigation - Company"}
%nav.mt-6{"aria-label" => "Footer Navigation - Hub Feenix"}
%ul.space-y-4.text-sm
%li
%a.text-gray-700.transition.hover:opacity-75{:href => "/retreats"}

View File

@ -1,6 +1,6 @@
%header.px-4.py-5.mx-auto.sm:max-w-xl.md:max-w-full.lg:max-w-screen-xl.md:px-24.lg:px-8
.relative.flex.items-center.justify-between
%a.inline-flex.items-center{"aria-label" => "Hub Feenix", :href => "/", :title => "Company"}
%a.inline-flex.items-center{"aria-label" => "Hub Feenix", :href => "/", :title => "Hub Feenix"}
= image_tag("feenix_lintu" , class: "h-20")
%span.ml-2.text-xl.font-bold.tracking-wide.text-gray-800.uppercase Hub Feenix
%ul.flex.items-center.hidden.space-x-8.lg:flex
@ -8,14 +8,14 @@
%li
%a.font-medium.tracking-wide.text-gray-700.transition-colors.duration-400.hover:text-cyan-800{"aria-label" => "Our product", :href => "/#{link}", :title => link.capitalize}= link.capitalize
%li
= link_to "facebook.com" do
= link_to "https://www.facebook.com/hubfeenix" , :target => "_blank" do
= image_tag("fb" , class: "h-10 rounded-md")
%li
%a.inline-flex.items-center.justify-center.h-12.px-6.font-medium.tracking-wide.text-white.transition.duration-200.rounded-lg.shadow-md.bg-green-800.hover:bg-blue-800.focus:shadow-outline.focus:outline-none{"aria-label" => "Sign up", :href => "/", :title => "Log in or Sign up"}
Login
.lg:hidden.flex.items-center.justify-between
.mr-20
= link_to "facebook.com" do
= link_to "https://www.facebook.com/hubfeenix" , :target => "_blank" do
= image_tag("fb" , class: "h-10 rounded-md")
%button.p-2.-mr-1.transition.duration-200.rounded.focus:outline-none.focus:shadow-outline.hover:bg-deep-purple-50.focus:bg-deep-purple-50{"aria-label" => "Open Menu", :title => "Open Menu" , onclick: "menu_on();"}
%svg.w-5.text-gray-600{:viewbox => "0 0 24 24"}
@ -27,7 +27,7 @@
.p-5.bg-white.border.rounded.shadow-sm
.flex.items-center.justify-between.mb-4
%div
%a.inline-flex.items-center{"aria-label" => "Company", :href => "/", :title => "Company"}
%a.inline-flex.items-center{"aria-label" => "Hub Feenix", :href => "/", :title => "Hub Feenix"}
= image_tag("feenix_lintu" , class: "h-20")
%span.ml-2.text-xl.font-bold.tracking-wide.text-gray-800.uppercase Hub Feenix
%div

View File

@ -0,0 +1,16 @@
= form_for @member do |f|
- if @member.errors.any?
#error_explanation
%h2= "#{pluralize(@member.errors.count, "error")} prohibited this member from being saved:"
%ul
- @member.errors.full_messages.each do |message|
%li= message
.field
= f.label :name
= f.text_field :name
.field
= f.label :public
= f.check_box :public
.actions
= f.submit 'Save'

View File

@ -0,0 +1,7 @@
%h1 Editing member
= render 'form'
= link_to 'Show', @member
\|
= link_to 'Back', members_path

View File

@ -0,0 +1,23 @@
%h1 Listing members
%table
%thead
%tr
%th Name
%th Public
%th
%th
%th
%tbody
- @members.each do |member|
%tr
%td= member.name
%td= member.public
%td= link_to 'Show', member
%td= link_to 'Edit', edit_member_path(member)
%td= link_to 'Destroy', member, method: :delete, data: { confirm: 'Are you sure?' }
%br
= link_to 'New Member', new_member_path

View File

@ -0,0 +1,5 @@
%h1 New member
= render 'form'
= link_to 'Back', members_path

View File

@ -0,0 +1,12 @@
%p#notice= notice
%p
%b Name:
= @member.name
%p
%b Public:
= @member.public
= link_to 'Edit', edit_member_path(@member)
\|
= link_to 'Back', members_path

View File

@ -1,4 +1,5 @@
Rails.application.routes.draw do
resources :members
mount Merged::Engine => "/merged"

View File

@ -0,0 +1,10 @@
class CreateMembers < ActiveRecord::Migration[7.0]
def change
create_table :members do |t|
t.string :name
t.boolean :public
t.timestamps
end
end
end

24
db/schema.rb generated Normal file
View File

@ -0,0 +1,24 @@
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rails
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.0].define(version: 2022_12_20_150444) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
create_table "members", force: :cascade do |t|
t.string "name"
t.boolean "public"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
end

View File

@ -0,0 +1,48 @@
require "test_helper"
class MembersControllerTest < ActionDispatch::IntegrationTest
setup do
@member = members(:one)
end
test "should get index" do
get members_url
assert_response :success
end
test "should get new" do
get new_member_url
assert_response :success
end
test "should create member" do
assert_difference("Member.count") do
post members_url, params: { member: { name: @member.name, public: @member.public } }
end
assert_redirected_to member_url(Member.last)
end
test "should show member" do
get member_url(@member)
assert_response :success
end
test "should get edit" do
get edit_member_url(@member)
assert_response :success
end
test "should update member" do
patch member_url(@member), params: { member: { name: @member.name, public: @member.public } }
assert_redirected_to member_url(@member)
end
test "should destroy member" do
assert_difference("Member.count", -1) do
delete member_url(@member)
end
assert_redirected_to members_url
end
end

9
test/fixtures/members.yml vendored Normal file
View File

@ -0,0 +1,9 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
name: MyString
public: false
two:
name: MyString
public: false

View File

@ -0,0 +1,7 @@
require "test_helper"
class MemberTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View File

@ -0,0 +1,43 @@
require "application_system_test_case"
class MembersTest < ApplicationSystemTestCase
setup do
@member = members(:one)
end
test "visiting the index" do
visit members_url
assert_selector "h1", text: "Members"
end
test "should create member" do
visit members_url
click_on "New member"
fill_in "Name", with: @member.name
check "Public" if @member.public
click_on "Create Member"
assert_text "Member was successfully created"
click_on "Back"
end
test "should update Member" do
visit member_url(@member)
click_on "Edit this member", match: :first
fill_in "Name", with: @member.name
check "Public" if @member.public
click_on "Update Member"
assert_text "Member was successfully updated"
click_on "Back"
end
test "should destroy Member" do
visit member_url(@member)
click_on "Destroy this member", match: :first
assert_text "Member was successfully destroyed"
end
end