create members
This commit is contained in:
parent
3c0d125990
commit
d2890636fd
2
Gemfile
2
Gemfile
@ -13,6 +13,8 @@ gem "sassc-rails"
|
|||||||
|
|
||||||
gem 'haml-rails'
|
gem 'haml-rails'
|
||||||
|
|
||||||
|
gem "ruby2js" , path: "../ruby2js"
|
||||||
|
|
||||||
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
|
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
|
||||||
# gem "image_processing", "~> 1.2"
|
# gem "image_processing", "~> 1.2"
|
||||||
|
|
||||||
|
52
Gemfile.lock
52
Gemfile.lock
@ -8,6 +8,14 @@ PATH
|
|||||||
mini_magick
|
mini_magick
|
||||||
rails (>= 7.0.4)
|
rails (>= 7.0.4)
|
||||||
redcarpet
|
redcarpet
|
||||||
|
ruby2js (~> 5.0, >= 5.0.1)
|
||||||
|
|
||||||
|
PATH
|
||||||
|
remote: ../ruby2js
|
||||||
|
specs:
|
||||||
|
ruby2js (5.0.1)
|
||||||
|
parser
|
||||||
|
regexp_parser (~> 2.1.1)
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
@ -81,8 +89,9 @@ GEM
|
|||||||
tzinfo (~> 2.0)
|
tzinfo (~> 2.0)
|
||||||
addressable (2.8.1)
|
addressable (2.8.1)
|
||||||
public_suffix (>= 2.0.2, < 6.0)
|
public_suffix (>= 2.0.2, < 6.0)
|
||||||
|
ast (2.4.2)
|
||||||
bindex (0.8.1)
|
bindex (0.8.1)
|
||||||
bootsnap (1.14.0)
|
bootsnap (1.15.0)
|
||||||
msgpack (~> 1.2)
|
msgpack (~> 1.2)
|
||||||
builder (3.2.4)
|
builder (3.2.4)
|
||||||
capybara (3.38.0)
|
capybara (3.38.0)
|
||||||
@ -94,18 +103,18 @@ GEM
|
|||||||
rack-test (>= 0.6.3)
|
rack-test (>= 0.6.3)
|
||||||
regexp_parser (>= 1.5, < 3.0)
|
regexp_parser (>= 1.5, < 3.0)
|
||||||
xpath (~> 3.2)
|
xpath (~> 3.2)
|
||||||
childprocess (4.1.0)
|
|
||||||
coderay (1.1.3)
|
coderay (1.1.3)
|
||||||
concurrent-ruby (1.1.10)
|
concurrent-ruby (1.1.10)
|
||||||
crass (1.0.6)
|
crass (1.0.6)
|
||||||
debug (1.6.3)
|
date (3.3.2)
|
||||||
irb (>= 1.3.6)
|
debug (1.7.0)
|
||||||
|
irb (>= 1.5.0)
|
||||||
reline (>= 0.3.1)
|
reline (>= 0.3.1)
|
||||||
diff-lcs (1.5.0)
|
diff-lcs (1.5.0)
|
||||||
erubi (1.11.0)
|
erubi (1.11.0)
|
||||||
ffi (1.15.5)
|
ffi (1.15.5)
|
||||||
formatador (1.1.0)
|
formatador (1.1.0)
|
||||||
git (1.12.0)
|
git (1.13.0)
|
||||||
addressable (~> 2.8)
|
addressable (~> 2.8)
|
||||||
rchardet (~> 1.8)
|
rchardet (~> 1.8)
|
||||||
globalid (1.0.0)
|
globalid (1.0.0)
|
||||||
@ -124,7 +133,7 @@ GEM
|
|||||||
guard (~> 2.1)
|
guard (~> 2.1)
|
||||||
guard-compat (~> 1.1)
|
guard-compat (~> 1.1)
|
||||||
rspec (>= 2.99.0, < 4.0)
|
rspec (>= 2.99.0, < 4.0)
|
||||||
haml (6.0.12)
|
haml (6.1.1)
|
||||||
temple (>= 0.8.2)
|
temple (>= 0.8.2)
|
||||||
thor
|
thor
|
||||||
tilt
|
tilt
|
||||||
@ -138,13 +147,13 @@ GEM
|
|||||||
importmap-rails (1.1.5)
|
importmap-rails (1.1.5)
|
||||||
actionpack (>= 6.0.0)
|
actionpack (>= 6.0.0)
|
||||||
railties (>= 6.0.0)
|
railties (>= 6.0.0)
|
||||||
io-console (0.5.11)
|
io-console (0.6.0)
|
||||||
irb (1.5.0)
|
irb (1.6.1)
|
||||||
reline (>= 0.3.0)
|
reline (>= 0.3.0)
|
||||||
listen (3.7.1)
|
listen (3.7.1)
|
||||||
rb-fsevent (~> 0.10, >= 0.10.3)
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
||||||
rb-inotify (~> 0.9, >= 0.9.10)
|
rb-inotify (~> 0.9, >= 0.9.10)
|
||||||
loofah (2.19.0)
|
loofah (2.19.1)
|
||||||
crass (~> 1.0.2)
|
crass (~> 1.0.2)
|
||||||
nokogiri (>= 1.5.9)
|
nokogiri (>= 1.5.9)
|
||||||
lumberjack (1.2.8)
|
lumberjack (1.2.8)
|
||||||
@ -164,21 +173,24 @@ GEM
|
|||||||
minitest (5.16.3)
|
minitest (5.16.3)
|
||||||
msgpack (1.6.0)
|
msgpack (1.6.0)
|
||||||
nenv (0.3.0)
|
nenv (0.3.0)
|
||||||
net-imap (0.3.1)
|
net-imap (0.3.2)
|
||||||
|
date
|
||||||
net-protocol
|
net-protocol
|
||||||
net-pop (0.1.2)
|
net-pop (0.1.2)
|
||||||
net-protocol
|
net-protocol
|
||||||
net-protocol (0.2.0)
|
net-protocol (0.2.1)
|
||||||
timeout
|
timeout
|
||||||
net-smtp (0.3.3)
|
net-smtp (0.3.3)
|
||||||
net-protocol
|
net-protocol
|
||||||
nio4r (2.5.8)
|
nio4r (2.5.8)
|
||||||
nokogiri (1.13.9-x86_64-linux)
|
nokogiri (1.13.10-x86_64-linux)
|
||||||
racc (~> 1.4)
|
racc (~> 1.4)
|
||||||
notiffany (0.1.3)
|
notiffany (0.1.3)
|
||||||
nenv (~> 0.1)
|
nenv (~> 0.1)
|
||||||
shellany (~> 0.0)
|
shellany (~> 0.0)
|
||||||
open4 (1.3.4)
|
open4 (1.3.4)
|
||||||
|
parser (3.1.3.0)
|
||||||
|
ast (~> 2.4.1)
|
||||||
passenger (6.0.15)
|
passenger (6.0.15)
|
||||||
rack
|
rack
|
||||||
rake (>= 0.8.1)
|
rake (>= 0.8.1)
|
||||||
@ -210,8 +222,8 @@ GEM
|
|||||||
rails-dom-testing (2.0.3)
|
rails-dom-testing (2.0.3)
|
||||||
activesupport (>= 4.2.0)
|
activesupport (>= 4.2.0)
|
||||||
nokogiri (>= 1.6)
|
nokogiri (>= 1.6)
|
||||||
rails-html-sanitizer (1.4.3)
|
rails-html-sanitizer (1.4.4)
|
||||||
loofah (~> 2.3)
|
loofah (~> 2.19, >= 2.19.1)
|
||||||
railties (7.0.4)
|
railties (7.0.4)
|
||||||
actionpack (= 7.0.4)
|
actionpack (= 7.0.4)
|
||||||
activesupport (= 7.0.4)
|
activesupport (= 7.0.4)
|
||||||
@ -225,8 +237,8 @@ GEM
|
|||||||
ffi (~> 1.0)
|
ffi (~> 1.0)
|
||||||
rchardet (1.8.0)
|
rchardet (1.8.0)
|
||||||
redcarpet (3.5.1)
|
redcarpet (3.5.1)
|
||||||
regexp_parser (2.6.1)
|
regexp_parser (2.1.1)
|
||||||
reline (0.3.1)
|
reline (0.3.2)
|
||||||
io-console (~> 0.5)
|
io-console (~> 0.5)
|
||||||
rexml (3.2.5)
|
rexml (3.2.5)
|
||||||
rspec (3.12.0)
|
rspec (3.12.0)
|
||||||
@ -235,10 +247,10 @@ GEM
|
|||||||
rspec-mocks (~> 3.12.0)
|
rspec-mocks (~> 3.12.0)
|
||||||
rspec-core (3.12.0)
|
rspec-core (3.12.0)
|
||||||
rspec-support (~> 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)
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
rspec-support (~> 3.12.0)
|
rspec-support (~> 3.12.0)
|
||||||
rspec-mocks (3.12.0)
|
rspec-mocks (3.12.1)
|
||||||
diff-lcs (>= 1.2.0, < 2.0)
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
rspec-support (~> 3.12.0)
|
rspec-support (~> 3.12.0)
|
||||||
rspec-support (3.12.0)
|
rspec-support (3.12.0)
|
||||||
@ -251,8 +263,7 @@ GEM
|
|||||||
sprockets (> 3.0)
|
sprockets (> 3.0)
|
||||||
sprockets-rails
|
sprockets-rails
|
||||||
tilt
|
tilt
|
||||||
selenium-webdriver (4.6.1)
|
selenium-webdriver (4.7.1)
|
||||||
childprocess (>= 0.5, < 5.0)
|
|
||||||
rexml (~> 3.2, >= 3.2.5)
|
rexml (~> 3.2, >= 3.2.5)
|
||||||
rubyzip (>= 1.2.2, < 3.0)
|
rubyzip (>= 1.2.2, < 3.0)
|
||||||
websocket (~> 1.0)
|
websocket (~> 1.0)
|
||||||
@ -305,6 +316,7 @@ DEPENDENCIES
|
|||||||
pg (~> 1.1)
|
pg (~> 1.1)
|
||||||
puma (~> 5.0)
|
puma (~> 5.0)
|
||||||
rails (~> 7.0.4)
|
rails (~> 7.0.4)
|
||||||
|
ruby2js!
|
||||||
sassc-rails
|
sassc-rails
|
||||||
selenium-webdriver
|
selenium-webdriver
|
||||||
sprockets-rails
|
sprockets-rails
|
||||||
|
58
app/controllers/members_controller.rb
Normal file
58
app/controllers/members_controller.rb
Normal 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
|
2
app/helpers/members_helper.rb
Normal file
2
app/helpers/members_helper.rb
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
module MembersHelper
|
||||||
|
end
|
2
app/models/member.rb
Normal file
2
app/models/member.rb
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
class Member < ApplicationRecord
|
||||||
|
end
|
@ -1,7 +1,7 @@
|
|||||||
%footer.bg-white{"aria-label" => "Site Footer"}
|
%footer.bg-white{"aria-label" => "Site Footer"}
|
||||||
.max-w-screen-xl.px-4.py-16.mx-auto.sm:px-6.lg:px-8
|
.max-w-screen-xl.px-4.py-16.mx-auto.sm:px-6.lg:px-8
|
||||||
.lg:flex.lg:items-start.lg:gap-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")
|
= 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
|
.grid.grid-cols-2.gap-8.mt-8.lg:mt-0.lg:grid-cols-5.lg:gap-y-16
|
||||||
.col-span-2
|
.col-span-2
|
||||||
@ -27,14 +27,14 @@
|
|||||||
=main.capitalize
|
=main.capitalize
|
||||||
.col-span-2.sm:col-span-1
|
.col-span-2.sm:col-span-1
|
||||||
%p.font-medium.text-gray-900 Hub Feenix
|
%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
|
%ul.space-y-4.text-sm
|
||||||
%li
|
%li
|
||||||
%a.text-gray-700.transition.hover:opacity-75{:href => "/about"}
|
%a.text-gray-700.transition.hover:opacity-75{:href => "/about"}
|
||||||
About
|
About
|
||||||
.col-span-2.sm:col-span-1
|
.col-span-2.sm:col-span-1
|
||||||
%p.font-medium.text-gray-900 Event Spaces
|
%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
|
%ul.space-y-4.text-sm
|
||||||
%li
|
%li
|
||||||
%a.text-gray-700.transition.hover:opacity-75{:href => "/retreats"}
|
%a.text-gray-700.transition.hover:opacity-75{:href => "/retreats"}
|
||||||
|
@ -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
|
%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
|
.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")
|
= image_tag("feenix_lintu" , class: "h-20")
|
||||||
%span.ml-2.text-xl.font-bold.tracking-wide.text-gray-800.uppercase Hub Feenix
|
%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
|
%ul.flex.items-center.hidden.space-x-8.lg:flex
|
||||||
@ -8,14 +8,14 @@
|
|||||||
%li
|
%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
|
%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
|
%li
|
||||||
= link_to "facebook.com" do
|
= link_to "https://www.facebook.com/hubfeenix" , :target => "_blank" do
|
||||||
= image_tag("fb" , class: "h-10 rounded-md")
|
= image_tag("fb" , class: "h-10 rounded-md")
|
||||||
%li
|
%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"}
|
%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
|
Login
|
||||||
.lg:hidden.flex.items-center.justify-between
|
.lg:hidden.flex.items-center.justify-between
|
||||||
.mr-20
|
.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")
|
= 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();"}
|
%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"}
|
%svg.w-5.text-gray-600{:viewbox => "0 0 24 24"}
|
||||||
@ -27,7 +27,7 @@
|
|||||||
.p-5.bg-white.border.rounded.shadow-sm
|
.p-5.bg-white.border.rounded.shadow-sm
|
||||||
.flex.items-center.justify-between.mb-4
|
.flex.items-center.justify-between.mb-4
|
||||||
%div
|
%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")
|
= image_tag("feenix_lintu" , class: "h-20")
|
||||||
%span.ml-2.text-xl.font-bold.tracking-wide.text-gray-800.uppercase Hub Feenix
|
%span.ml-2.text-xl.font-bold.tracking-wide.text-gray-800.uppercase Hub Feenix
|
||||||
%div
|
%div
|
||||||
|
16
app/views/members/_form.html.haml
Normal file
16
app/views/members/_form.html.haml
Normal 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'
|
7
app/views/members/edit.html.haml
Normal file
7
app/views/members/edit.html.haml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
%h1 Editing member
|
||||||
|
|
||||||
|
= render 'form'
|
||||||
|
|
||||||
|
= link_to 'Show', @member
|
||||||
|
\|
|
||||||
|
= link_to 'Back', members_path
|
23
app/views/members/index.html.haml
Normal file
23
app/views/members/index.html.haml
Normal 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
|
5
app/views/members/new.html.haml
Normal file
5
app/views/members/new.html.haml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
%h1 New member
|
||||||
|
|
||||||
|
= render 'form'
|
||||||
|
|
||||||
|
= link_to 'Back', members_path
|
12
app/views/members/show.html.haml
Normal file
12
app/views/members/show.html.haml
Normal 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
|
@ -1,4 +1,5 @@
|
|||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
|
resources :members
|
||||||
|
|
||||||
mount Merged::Engine => "/merged"
|
mount Merged::Engine => "/merged"
|
||||||
|
|
||||||
|
10
db/migrate/20221220150444_create_members.rb
Normal file
10
db/migrate/20221220150444_create_members.rb
Normal 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
24
db/schema.rb
generated
Normal 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
|
48
test/controllers/members_controller_test.rb
Normal file
48
test/controllers/members_controller_test.rb
Normal 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
9
test/fixtures/members.yml
vendored
Normal 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
|
7
test/models/member_test.rb
Normal file
7
test/models/member_test.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
require "test_helper"
|
||||||
|
|
||||||
|
class MemberTest < ActiveSupport::TestCase
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
43
test/system/members_test.rb
Normal file
43
test/system/members_test.rb
Normal 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
|
Loading…
Reference in New Issue
Block a user