From 2595129b6729aa3169af535914ad459653867a02 Mon Sep 17 00:00:00 2001 From: Michael Sipayung Date: Wed, 24 Jan 2024 12:33:22 +0700 Subject: [PATCH] bug fixes for address lists --- .idea/dataSources.xml | 7 ++ .../address_kabupaten_lists_controller.rb | 70 +++++++++++++++++++ .../address_kecamatan_lists_controller.rb | 70 +++++++++++++++++++ .../address_province_lists_controller.rb | 70 +++++++++++++++++++ app/helpers/address_kabupaten_lists_helper.rb | 2 + app/helpers/address_kecamatan_lists_helper.rb | 2 + app/helpers/address_province_lists_helper.rb | 2 + app/models/address_kabupaten_list.rb | 3 + app/models/address_kecamatan_list.rb | 4 ++ app/models/address_province_list.rb | 3 + .../_address_kabupaten_list.html.erb | 7 ++ .../_address_kabupaten_list.json.jbuilder | 2 + .../address_kabupaten_lists/_form.html.erb | 22 ++++++ .../address_kabupaten_lists/edit.html.erb | 10 +++ .../address_kabupaten_lists/index.html.erb | 14 ++++ .../index.json.jbuilder | 1 + .../address_kabupaten_lists/new.html.erb | 9 +++ .../address_kabupaten_lists/show.html.erb | 10 +++ .../show.json.jbuilder | 1 + .../_address_kecamatan_list.html.erb | 7 ++ .../_address_kecamatan_list.json.jbuilder | 2 + .../address_kecamatan_lists/_form.html.erb | 22 ++++++ .../address_kecamatan_lists/edit.html.erb | 10 +++ .../address_kecamatan_lists/index.html.erb | 14 ++++ .../index.json.jbuilder | 1 + .../address_kecamatan_lists/new.html.erb | 9 +++ .../address_kecamatan_lists/show.html.erb | 10 +++ .../show.json.jbuilder | 1 + .../_address_province_list.html.erb | 7 ++ .../_address_province_list.json.jbuilder | 2 + .../address_province_lists/_form.html.erb | 22 ++++++ .../address_province_lists/edit.html.erb | 10 +++ .../address_province_lists/index.html.erb | 14 ++++ .../index.json.jbuilder | 1 + app/views/address_province_lists/new.html.erb | 9 +++ .../address_province_lists/show.html.erb | 10 +++ .../address_province_lists/show.json.jbuilder | 1 + config/routes.rb | 3 + ...ince_list_ref_to_address_kabupaten_list.rb | 5 -- ...aten_list_ref_to_address_kecamatan_list.rb | 5 -- ...24023554_create_address_province_lists.rb} | 0 ...4025248_create_address_kabupaten_lists.rb} | 0 ...4025321_create_address_kecamatan_lists.rb} | 0 ...insi_list_ref_to_address_kecamatan_list.rb | 5 ++ ...atan_list_ref_to_address_kabupaten_list.rb | 5 ++ db/schema.rb | 14 ++-- ...address_kabupaten_lists_controller_test.rb | 63 +++++++++++++++++ ...address_kecamatan_lists_controller_test.rb | 57 +++++++++++++++ .../address_province_lists_controller_test.rb | 54 ++++++++++++++ test/fixtures/address_kabupaten_lists.yml | 14 ++-- test/fixtures/address_kecamatan_lists.yml | 18 +++-- test/fixtures/address_province_lists.yml | 10 +-- test/models/address_kabupaten_list_test.rb | 30 ++++++-- test/models/address_kecamatan_list_test.rb | 28 +++++++- test/models/address_province_list_test.rb | 26 ++++++- test/system/address_kabupaten_lists_test.rb | 41 +++++++++++ test/system/address_kecamatan_lists_test.rb | 41 +++++++++++ test/system/address_province_lists_test.rb | 41 +++++++++++ test/test_helper.rb | 2 +- 59 files changed, 883 insertions(+), 40 deletions(-) create mode 100644 app/controllers/address_kabupaten_lists_controller.rb create mode 100644 app/controllers/address_kecamatan_lists_controller.rb create mode 100644 app/controllers/address_province_lists_controller.rb create mode 100644 app/helpers/address_kabupaten_lists_helper.rb create mode 100644 app/helpers/address_kecamatan_lists_helper.rb create mode 100644 app/helpers/address_province_lists_helper.rb create mode 100644 app/views/address_kabupaten_lists/_address_kabupaten_list.html.erb create mode 100644 app/views/address_kabupaten_lists/_address_kabupaten_list.json.jbuilder create mode 100644 app/views/address_kabupaten_lists/_form.html.erb create mode 100644 app/views/address_kabupaten_lists/edit.html.erb create mode 100644 app/views/address_kabupaten_lists/index.html.erb create mode 100644 app/views/address_kabupaten_lists/index.json.jbuilder create mode 100644 app/views/address_kabupaten_lists/new.html.erb create mode 100644 app/views/address_kabupaten_lists/show.html.erb create mode 100644 app/views/address_kabupaten_lists/show.json.jbuilder create mode 100644 app/views/address_kecamatan_lists/_address_kecamatan_list.html.erb create mode 100644 app/views/address_kecamatan_lists/_address_kecamatan_list.json.jbuilder create mode 100644 app/views/address_kecamatan_lists/_form.html.erb create mode 100644 app/views/address_kecamatan_lists/edit.html.erb create mode 100644 app/views/address_kecamatan_lists/index.html.erb create mode 100644 app/views/address_kecamatan_lists/index.json.jbuilder create mode 100644 app/views/address_kecamatan_lists/new.html.erb create mode 100644 app/views/address_kecamatan_lists/show.html.erb create mode 100644 app/views/address_kecamatan_lists/show.json.jbuilder create mode 100644 app/views/address_province_lists/_address_province_list.html.erb create mode 100644 app/views/address_province_lists/_address_province_list.json.jbuilder create mode 100644 app/views/address_province_lists/_form.html.erb create mode 100644 app/views/address_province_lists/edit.html.erb create mode 100644 app/views/address_province_lists/index.html.erb create mode 100644 app/views/address_province_lists/index.json.jbuilder create mode 100644 app/views/address_province_lists/new.html.erb create mode 100644 app/views/address_province_lists/show.html.erb create mode 100644 app/views/address_province_lists/show.json.jbuilder delete mode 100644 db/migrate/20240117024408_add_address_province_list_ref_to_address_kabupaten_list.rb delete mode 100644 db/migrate/20240117024847_add_address_kabupaten_list_ref_to_address_kecamatan_list.rb rename db/migrate/{20240117020414_create_address_province_lists.rb => 20240124023554_create_address_province_lists.rb} (100%) rename db/migrate/{20240117020517_create_address_kabupaten_lists.rb => 20240124025248_create_address_kabupaten_lists.rb} (100%) rename db/migrate/{20240117020453_create_address_kecamatan_lists.rb => 20240124025321_create_address_kecamatan_lists.rb} (100%) create mode 100644 db/migrate/20240124030807_add_address_provinsi_list_ref_to_address_kecamatan_list.rb create mode 100644 db/migrate/20240124030936_add_address_kecamatan_list_ref_to_address_kabupaten_list.rb create mode 100644 test/controllers/address_kabupaten_lists_controller_test.rb create mode 100644 test/controllers/address_kecamatan_lists_controller_test.rb create mode 100644 test/controllers/address_province_lists_controller_test.rb create mode 100644 test/system/address_kabupaten_lists_test.rb create mode 100644 test/system/address_kecamatan_lists_test.rb create mode 100644 test/system/address_province_lists_test.rb diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml index 2225d82..cbc8610 100644 --- a/.idea/dataSources.xml +++ b/.idea/dataSources.xml @@ -22,5 +22,12 @@ jdbc:sqlite:identifier.sqlite $ProjectFileDir$ + + sqlite.xerial + true + org.sqlite.JDBC + jdbc:sqlite:identifier.sqlite + $ProjectFileDir$ + \ No newline at end of file diff --git a/app/controllers/address_kabupaten_lists_controller.rb b/app/controllers/address_kabupaten_lists_controller.rb new file mode 100644 index 0000000..015f11a --- /dev/null +++ b/app/controllers/address_kabupaten_lists_controller.rb @@ -0,0 +1,70 @@ +class AddressKabupatenListsController < ApplicationController + before_action :set_address_kabupaten_list, only: %i[ show edit update destroy ] + + # GET /address_kabupaten_lists or /address_kabupaten_lists.json + def index + @address_kabupaten_lists = AddressKabupatenList.all + end + + # GET /address_kabupaten_lists/1 or /address_kabupaten_lists/1.json + def show + end + + # GET /address_kabupaten_lists/new + def new + @address_kabupaten_list = AddressKabupatenList.new + end + + # GET /address_kabupaten_lists/1/edit + def edit + end + + # POST /address_kabupaten_lists or /address_kabupaten_lists.json + def create + @address_kabupaten_list = AddressKabupatenList.new(address_kabupaten_list_params) + + respond_to do |format| + if @address_kabupaten_list.save + format.html { redirect_to address_kabupaten_list_url(@address_kabupaten_list), notice: "Address kabupaten list was successfully created." } + format.json { render :show, status: :created, location: @address_kabupaten_list } + else + format.html { render :new, status: :unprocessable_entity } + format.json { render json: @address_kabupaten_list.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /address_kabupaten_lists/1 or /address_kabupaten_lists/1.json + def update + respond_to do |format| + if @address_kabupaten_list.update(address_kabupaten_list_params) + format.html { redirect_to address_kabupaten_list_url(@address_kabupaten_list), notice: "Address kabupaten list was successfully updated." } + format.json { render :show, status: :ok, location: @address_kabupaten_list } + else + format.html { render :edit, status: :unprocessable_entity } + format.json { render json: @address_kabupaten_list.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /address_kabupaten_lists/1 or /address_kabupaten_lists/1.json + def destroy + @address_kabupaten_list.destroy! + + respond_to do |format| + format.html { redirect_to address_kabupaten_lists_url, notice: "Address kabupaten list was successfully destroyed." } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_address_kabupaten_list + @address_kabupaten_list = AddressKabupatenList.find(params[:id]) + end + + # Only allow a list of trusted parameters through. + def address_kabupaten_list_params + params.require(:address_kabupaten_list).permit(:kabupaten, :address_kecamatan_list_id) + end +end diff --git a/app/controllers/address_kecamatan_lists_controller.rb b/app/controllers/address_kecamatan_lists_controller.rb new file mode 100644 index 0000000..fa22466 --- /dev/null +++ b/app/controllers/address_kecamatan_lists_controller.rb @@ -0,0 +1,70 @@ +class AddressKecamatanListsController < ApplicationController + before_action :set_address_kecamatan_list, only: %i[ show edit update destroy ] + + # GET /address_kecamatan_lists or /address_kecamatan_lists.json + def index + @address_kecamatan_lists = AddressKecamatanList.all + end + + # GET /address_kecamatan_lists/1 or /address_kecamatan_lists/1.json + def show + end + + # GET /address_kecamatan_lists/new + def new + @address_kecamatan_list = AddressKecamatanList.new + end + + # GET /address_kecamatan_lists/1/edit + def edit + end + + # POST /address_kecamatan_lists or /address_kecamatan_lists.json + def create + @address_kecamatan_list = AddressKecamatanList.new(address_kecamatan_list_params) + + respond_to do |format| + if @address_kecamatan_list.save + format.html { redirect_to address_kecamatan_list_url(@address_kecamatan_list), notice: "Address kecamatan list was successfully created." } + format.json { render :show, status: :created, location: @address_kecamatan_list } + else + format.html { render :new, status: :unprocessable_entity } + format.json { render json: @address_kecamatan_list.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /address_kecamatan_lists/1 or /address_kecamatan_lists/1.json + def update + respond_to do |format| + if @address_kecamatan_list.update(address_kecamatan_list_params) + format.html { redirect_to address_kecamatan_list_url(@address_kecamatan_list), notice: "Address kecamatan list was successfully updated." } + format.json { render :show, status: :ok, location: @address_kecamatan_list } + else + format.html { render :edit, status: :unprocessable_entity } + format.json { render json: @address_kecamatan_list.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /address_kecamatan_lists/1 or /address_kecamatan_lists/1.json + def destroy + @address_kecamatan_list.destroy! + + respond_to do |format| + format.html { redirect_to address_kecamatan_lists_url, notice: "Address kecamatan list was successfully destroyed." } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_address_kecamatan_list + @address_kecamatan_list = AddressKecamatanList.find(params[:id]) + end + + # Only allow a list of trusted parameters through. + def address_kecamatan_list_params + params.require(:address_kecamatan_list).permit(:kecamatan, :address_province_list_id) + end +end diff --git a/app/controllers/address_province_lists_controller.rb b/app/controllers/address_province_lists_controller.rb new file mode 100644 index 0000000..b79537e --- /dev/null +++ b/app/controllers/address_province_lists_controller.rb @@ -0,0 +1,70 @@ +class AddressProvinceListsController < ApplicationController + before_action :set_address_province_list, only: %i[ show edit update destroy ] + + # GET /address_province_lists or /address_province_lists.json + def index + @address_province_lists = AddressProvinceList.all + end + + # GET /address_province_lists/1 or /address_province_lists/1.json + def show + end + + # GET /address_province_lists/new + def new + @address_province_list = AddressProvinceList.new + end + + # GET /address_province_lists/1/edit + def edit + end + + # POST /address_province_lists or /address_province_lists.json + def create + @address_province_list = AddressProvinceList.new(address_province_list_params) + + respond_to do |format| + if @address_province_list.save + format.html { redirect_to address_province_list_url(@address_province_list), notice: "Address province list was successfully created." } + format.json { render :show, status: :created, location: @address_province_list } + else + format.html { render :new, status: :unprocessable_entity } + format.json { render json: @address_province_list.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /address_province_lists/1 or /address_province_lists/1.json + def update + respond_to do |format| + if @address_province_list.update(address_province_list_params) + format.html { redirect_to address_province_list_url(@address_province_list), notice: "Address province list was successfully updated." } + format.json { render :show, status: :ok, location: @address_province_list } + else + format.html { render :edit, status: :unprocessable_entity } + format.json { render json: @address_province_list.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /address_province_lists/1 or /address_province_lists/1.json + def destroy + @address_province_list.destroy! + + respond_to do |format| + format.html { redirect_to address_province_lists_url, notice: "Address province list was successfully destroyed." } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_address_province_list + @address_province_list = AddressProvinceList.find(params[:id]) + end + + # Only allow a list of trusted parameters through. + def address_province_list_params + params.require(:address_province_list).permit(:provinsi) + end +end diff --git a/app/helpers/address_kabupaten_lists_helper.rb b/app/helpers/address_kabupaten_lists_helper.rb new file mode 100644 index 0000000..58f9101 --- /dev/null +++ b/app/helpers/address_kabupaten_lists_helper.rb @@ -0,0 +1,2 @@ +module AddressKabupatenListsHelper +end diff --git a/app/helpers/address_kecamatan_lists_helper.rb b/app/helpers/address_kecamatan_lists_helper.rb new file mode 100644 index 0000000..f83e714 --- /dev/null +++ b/app/helpers/address_kecamatan_lists_helper.rb @@ -0,0 +1,2 @@ +module AddressKecamatanListsHelper +end diff --git a/app/helpers/address_province_lists_helper.rb b/app/helpers/address_province_lists_helper.rb new file mode 100644 index 0000000..766b7ea --- /dev/null +++ b/app/helpers/address_province_lists_helper.rb @@ -0,0 +1,2 @@ +module AddressProvinceListsHelper +end diff --git a/app/models/address_kabupaten_list.rb b/app/models/address_kabupaten_list.rb index f2c1466..e3d8048 100644 --- a/app/models/address_kabupaten_list.rb +++ b/app/models/address_kabupaten_list.rb @@ -1,2 +1,5 @@ class AddressKabupatenList < ApplicationRecord + belongs_to :address_kecamatan_list + validates :kabupaten, presence: true, uniqueness: true, + length: { minimum: 3, maximum: 35 } end diff --git a/app/models/address_kecamatan_list.rb b/app/models/address_kecamatan_list.rb index 73d3c75..8121b0b 100644 --- a/app/models/address_kecamatan_list.rb +++ b/app/models/address_kecamatan_list.rb @@ -1,2 +1,6 @@ class AddressKecamatanList < ApplicationRecord + has_many :address_kabupaten_lists, dependent: :destroy + belongs_to :address_province_list + validates :kecamatan, presence: true, uniqueness: true, + length: { minimum: 3, maximum: 35 } end diff --git a/app/models/address_province_list.rb b/app/models/address_province_list.rb index 99c0123..683a7ef 100644 --- a/app/models/address_province_list.rb +++ b/app/models/address_province_list.rb @@ -1,2 +1,5 @@ class AddressProvinceList < ApplicationRecord + has_many :address_kecamatan_lists, dependent: :destroy + validates :provinsi, presence: true, uniqueness: true, + length: { minimum: 3, maximum: 35 } end diff --git a/app/views/address_kabupaten_lists/_address_kabupaten_list.html.erb b/app/views/address_kabupaten_lists/_address_kabupaten_list.html.erb new file mode 100644 index 0000000..360a596 --- /dev/null +++ b/app/views/address_kabupaten_lists/_address_kabupaten_list.html.erb @@ -0,0 +1,7 @@ +
+

+ Kabupaten: + <%= address_kabupaten_list.kabupaten %> +

+ +
diff --git a/app/views/address_kabupaten_lists/_address_kabupaten_list.json.jbuilder b/app/views/address_kabupaten_lists/_address_kabupaten_list.json.jbuilder new file mode 100644 index 0000000..6402ef1 --- /dev/null +++ b/app/views/address_kabupaten_lists/_address_kabupaten_list.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! address_kabupaten_list, :id, :kabupaten, :created_at, :updated_at +json.url address_kabupaten_list_url(address_kabupaten_list, format: :json) diff --git a/app/views/address_kabupaten_lists/_form.html.erb b/app/views/address_kabupaten_lists/_form.html.erb new file mode 100644 index 0000000..8a0d2a1 --- /dev/null +++ b/app/views/address_kabupaten_lists/_form.html.erb @@ -0,0 +1,22 @@ +<%= form_with(model: address_kabupaten_list) do |form| %> + <% if address_kabupaten_list.errors.any? %> +
+

<%= pluralize(address_kabupaten_list.errors.count, "error") %> prohibited this address_kabupaten_list from being saved:

+ + +
+ <% end %> + +
+ <%= form.label :kabupaten, style: "display: block" %> + <%= form.text_field :kabupaten %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/address_kabupaten_lists/edit.html.erb b/app/views/address_kabupaten_lists/edit.html.erb new file mode 100644 index 0000000..8040fba --- /dev/null +++ b/app/views/address_kabupaten_lists/edit.html.erb @@ -0,0 +1,10 @@ +

Editing address kabupaten list

+ +<%= render "form", address_kabupaten_list: @address_kabupaten_list %> + +
+ +
+ <%= link_to "Show this address kabupaten list", @address_kabupaten_list %> | + <%= link_to "Back to address kabupaten lists", address_kabupaten_lists_path %> +
diff --git a/app/views/address_kabupaten_lists/index.html.erb b/app/views/address_kabupaten_lists/index.html.erb new file mode 100644 index 0000000..6ddccfa --- /dev/null +++ b/app/views/address_kabupaten_lists/index.html.erb @@ -0,0 +1,14 @@ +

<%= notice %>

+ +

Address kabupaten lists

+ +
+ <% @address_kabupaten_lists.each do |address_kabupaten_list| %> + <%= render address_kabupaten_list %> +

+ <%= link_to "Show this address kabupaten list", address_kabupaten_list %> +

+ <% end %> +
+ +<%= link_to "New address kabupaten list", new_address_kabupaten_list_path %> diff --git a/app/views/address_kabupaten_lists/index.json.jbuilder b/app/views/address_kabupaten_lists/index.json.jbuilder new file mode 100644 index 0000000..4d99802 --- /dev/null +++ b/app/views/address_kabupaten_lists/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @address_kabupaten_lists, partial: "address_kabupaten_lists/address_kabupaten_list", as: :address_kabupaten_list diff --git a/app/views/address_kabupaten_lists/new.html.erb b/app/views/address_kabupaten_lists/new.html.erb new file mode 100644 index 0000000..1ea8db0 --- /dev/null +++ b/app/views/address_kabupaten_lists/new.html.erb @@ -0,0 +1,9 @@ +

New address kabupaten list

+ +<%= render "form", address_kabupaten_list: @address_kabupaten_list %> + +
+ +
+ <%= link_to "Back to address kabupaten lists", address_kabupaten_lists_path %> +
diff --git a/app/views/address_kabupaten_lists/show.html.erb b/app/views/address_kabupaten_lists/show.html.erb new file mode 100644 index 0000000..55f3c6d --- /dev/null +++ b/app/views/address_kabupaten_lists/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @address_kabupaten_list %> + +
+ <%= link_to "Edit this address kabupaten list", edit_address_kabupaten_list_path(@address_kabupaten_list) %> | + <%= link_to "Back to address kabupaten lists", address_kabupaten_lists_path %> + + <%= button_to "Destroy this address kabupaten list", @address_kabupaten_list, method: :delete %> +
diff --git a/app/views/address_kabupaten_lists/show.json.jbuilder b/app/views/address_kabupaten_lists/show.json.jbuilder new file mode 100644 index 0000000..96fd999 --- /dev/null +++ b/app/views/address_kabupaten_lists/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "address_kabupaten_lists/address_kabupaten_list", address_kabupaten_list: @address_kabupaten_list diff --git a/app/views/address_kecamatan_lists/_address_kecamatan_list.html.erb b/app/views/address_kecamatan_lists/_address_kecamatan_list.html.erb new file mode 100644 index 0000000..a76d8d7 --- /dev/null +++ b/app/views/address_kecamatan_lists/_address_kecamatan_list.html.erb @@ -0,0 +1,7 @@ +
+

+ Kecamatan: + <%= address_kecamatan_list.kecamatan %> +

+ +
diff --git a/app/views/address_kecamatan_lists/_address_kecamatan_list.json.jbuilder b/app/views/address_kecamatan_lists/_address_kecamatan_list.json.jbuilder new file mode 100644 index 0000000..8ce548b --- /dev/null +++ b/app/views/address_kecamatan_lists/_address_kecamatan_list.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! address_kecamatan_list, :id, :kecamatan, :created_at, :updated_at +json.url address_kecamatan_list_url(address_kecamatan_list, format: :json) diff --git a/app/views/address_kecamatan_lists/_form.html.erb b/app/views/address_kecamatan_lists/_form.html.erb new file mode 100644 index 0000000..1aa7201 --- /dev/null +++ b/app/views/address_kecamatan_lists/_form.html.erb @@ -0,0 +1,22 @@ +<%= form_with(model: address_kecamatan_list) do |form| %> + <% if address_kecamatan_list.errors.any? %> +
+

<%= pluralize(address_kecamatan_list.errors.count, "error") %> prohibited this address_kecamatan_list from being saved:

+ + +
+ <% end %> + +
+ <%= form.label :kecamatan, style: "display: block" %> + <%= form.text_field :kecamatan %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/address_kecamatan_lists/edit.html.erb b/app/views/address_kecamatan_lists/edit.html.erb new file mode 100644 index 0000000..bc37cd4 --- /dev/null +++ b/app/views/address_kecamatan_lists/edit.html.erb @@ -0,0 +1,10 @@ +

Editing address kecamatan list

+ +<%= render "form", address_kecamatan_list: @address_kecamatan_list %> + +
+ +
+ <%= link_to "Show this address kecamatan list", @address_kecamatan_list %> | + <%= link_to "Back to address kecamatan lists", address_kecamatan_lists_path %> +
diff --git a/app/views/address_kecamatan_lists/index.html.erb b/app/views/address_kecamatan_lists/index.html.erb new file mode 100644 index 0000000..817930b --- /dev/null +++ b/app/views/address_kecamatan_lists/index.html.erb @@ -0,0 +1,14 @@ +

<%= notice %>

+ +

Address kecamatan lists

+ +
+ <% @address_kecamatan_lists.each do |address_kecamatan_list| %> + <%= render address_kecamatan_list %> +

+ <%= link_to "Show this address kecamatan list", address_kecamatan_list %> +

+ <% end %> +
+ +<%= link_to "New address kecamatan list", new_address_kecamatan_list_path %> diff --git a/app/views/address_kecamatan_lists/index.json.jbuilder b/app/views/address_kecamatan_lists/index.json.jbuilder new file mode 100644 index 0000000..bded9f5 --- /dev/null +++ b/app/views/address_kecamatan_lists/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @address_kecamatan_lists, partial: "address_kecamatan_lists/address_kecamatan_list", as: :address_kecamatan_list diff --git a/app/views/address_kecamatan_lists/new.html.erb b/app/views/address_kecamatan_lists/new.html.erb new file mode 100644 index 0000000..3d0923c --- /dev/null +++ b/app/views/address_kecamatan_lists/new.html.erb @@ -0,0 +1,9 @@ +

New address kecamatan list

+ +<%= render "form", address_kecamatan_list: @address_kecamatan_list %> + +
+ +
+ <%= link_to "Back to address kecamatan lists", address_kecamatan_lists_path %> +
diff --git a/app/views/address_kecamatan_lists/show.html.erb b/app/views/address_kecamatan_lists/show.html.erb new file mode 100644 index 0000000..47f9a07 --- /dev/null +++ b/app/views/address_kecamatan_lists/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @address_kecamatan_list %> + +
+ <%= link_to "Edit this address kecamatan list", edit_address_kecamatan_list_path(@address_kecamatan_list) %> | + <%= link_to "Back to address kecamatan lists", address_kecamatan_lists_path %> + + <%= button_to "Destroy this address kecamatan list", @address_kecamatan_list, method: :delete %> +
diff --git a/app/views/address_kecamatan_lists/show.json.jbuilder b/app/views/address_kecamatan_lists/show.json.jbuilder new file mode 100644 index 0000000..0159069 --- /dev/null +++ b/app/views/address_kecamatan_lists/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "address_kecamatan_lists/address_kecamatan_list", address_kecamatan_list: @address_kecamatan_list diff --git a/app/views/address_province_lists/_address_province_list.html.erb b/app/views/address_province_lists/_address_province_list.html.erb new file mode 100644 index 0000000..029aa74 --- /dev/null +++ b/app/views/address_province_lists/_address_province_list.html.erb @@ -0,0 +1,7 @@ +
+

+ Provinsi: + <%= address_province_list.provinsi %> +

+ +
diff --git a/app/views/address_province_lists/_address_province_list.json.jbuilder b/app/views/address_province_lists/_address_province_list.json.jbuilder new file mode 100644 index 0000000..05dc3ef --- /dev/null +++ b/app/views/address_province_lists/_address_province_list.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! address_province_list, :id, :provinsi, :created_at, :updated_at +json.url address_province_list_url(address_province_list, format: :json) diff --git a/app/views/address_province_lists/_form.html.erb b/app/views/address_province_lists/_form.html.erb new file mode 100644 index 0000000..d05ec24 --- /dev/null +++ b/app/views/address_province_lists/_form.html.erb @@ -0,0 +1,22 @@ +<%= form_with(model: address_province_list) do |form| %> + <% if address_province_list.errors.any? %> +
+

<%= pluralize(address_province_list.errors.count, "error") %> prohibited this address_province_list from being saved:

+ + +
+ <% end %> + +
+ <%= form.label :provinsi, style: "display: block" %> + <%= form.text_field :provinsi %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/address_province_lists/edit.html.erb b/app/views/address_province_lists/edit.html.erb new file mode 100644 index 0000000..7e027d3 --- /dev/null +++ b/app/views/address_province_lists/edit.html.erb @@ -0,0 +1,10 @@ +

Editing address province list

+ +<%= render "form", address_province_list: @address_province_list %> + +
+ +
+ <%= link_to "Show this address province list", @address_province_list %> | + <%= link_to "Back to address province lists", address_province_lists_path %> +
diff --git a/app/views/address_province_lists/index.html.erb b/app/views/address_province_lists/index.html.erb new file mode 100644 index 0000000..21180fd --- /dev/null +++ b/app/views/address_province_lists/index.html.erb @@ -0,0 +1,14 @@ +

<%= notice %>

+ +

Address province lists

+ +
+ <% @address_province_lists.each do |address_province_list| %> + <%= render address_province_list %> +

+ <%= link_to "Show this address province list", address_province_list %> +

+ <% end %> +
+ +<%= link_to "New address province list", new_address_province_list_path %> diff --git a/app/views/address_province_lists/index.json.jbuilder b/app/views/address_province_lists/index.json.jbuilder new file mode 100644 index 0000000..ea5c0a1 --- /dev/null +++ b/app/views/address_province_lists/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @address_province_lists, partial: "address_province_lists/address_province_list", as: :address_province_list diff --git a/app/views/address_province_lists/new.html.erb b/app/views/address_province_lists/new.html.erb new file mode 100644 index 0000000..8518324 --- /dev/null +++ b/app/views/address_province_lists/new.html.erb @@ -0,0 +1,9 @@ +

New address province list

+ +<%= render "form", address_province_list: @address_province_list %> + +
+ +
+ <%= link_to "Back to address province lists", address_province_lists_path %> +
diff --git a/app/views/address_province_lists/show.html.erb b/app/views/address_province_lists/show.html.erb new file mode 100644 index 0000000..fa8fff5 --- /dev/null +++ b/app/views/address_province_lists/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @address_province_list %> + +
+ <%= link_to "Edit this address province list", edit_address_province_list_path(@address_province_list) %> | + <%= link_to "Back to address province lists", address_province_lists_path %> + + <%= button_to "Destroy this address province list", @address_province_list, method: :delete %> +
diff --git a/app/views/address_province_lists/show.json.jbuilder b/app/views/address_province_lists/show.json.jbuilder new file mode 100644 index 0000000..3fd0194 --- /dev/null +++ b/app/views/address_province_lists/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "address_province_lists/address_province_list", address_province_list: @address_province_list diff --git a/config/routes.rb b/config/routes.rb index 38ea8a6..b307f6b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,7 @@ Rails.application.routes.draw do + resources :address_kabupaten_lists + resources :address_kecamatan_lists + resources :address_province_lists resources :achievement_kategori_lists resources :achievement_tingkat_lists resources :source_motivation_lists diff --git a/db/migrate/20240117024408_add_address_province_list_ref_to_address_kabupaten_list.rb b/db/migrate/20240117024408_add_address_province_list_ref_to_address_kabupaten_list.rb deleted file mode 100644 index 7cb3915..0000000 --- a/db/migrate/20240117024408_add_address_province_list_ref_to_address_kabupaten_list.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddAddressProvinceListRefToAddressKabupatenList < ActiveRecord::Migration[7.1] - def change - add_reference :address_kabupaten_lists, :address_province_list, null: false, foreign_key: true - end -end diff --git a/db/migrate/20240117024847_add_address_kabupaten_list_ref_to_address_kecamatan_list.rb b/db/migrate/20240117024847_add_address_kabupaten_list_ref_to_address_kecamatan_list.rb deleted file mode 100644 index 31cbaf8..0000000 --- a/db/migrate/20240117024847_add_address_kabupaten_list_ref_to_address_kecamatan_list.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddAddressKabupatenListRefToAddressKecamatanList < ActiveRecord::Migration[7.1] - def change - add_reference :address_kecamatan_lists, :address_kabupaten_list, null: false, foreign_key: true - end -end diff --git a/db/migrate/20240117020414_create_address_province_lists.rb b/db/migrate/20240124023554_create_address_province_lists.rb similarity index 100% rename from db/migrate/20240117020414_create_address_province_lists.rb rename to db/migrate/20240124023554_create_address_province_lists.rb diff --git a/db/migrate/20240117020517_create_address_kabupaten_lists.rb b/db/migrate/20240124025248_create_address_kabupaten_lists.rb similarity index 100% rename from db/migrate/20240117020517_create_address_kabupaten_lists.rb rename to db/migrate/20240124025248_create_address_kabupaten_lists.rb diff --git a/db/migrate/20240117020453_create_address_kecamatan_lists.rb b/db/migrate/20240124025321_create_address_kecamatan_lists.rb similarity index 100% rename from db/migrate/20240117020453_create_address_kecamatan_lists.rb rename to db/migrate/20240124025321_create_address_kecamatan_lists.rb diff --git a/db/migrate/20240124030807_add_address_provinsi_list_ref_to_address_kecamatan_list.rb b/db/migrate/20240124030807_add_address_provinsi_list_ref_to_address_kecamatan_list.rb new file mode 100644 index 0000000..bb674c4 --- /dev/null +++ b/db/migrate/20240124030807_add_address_provinsi_list_ref_to_address_kecamatan_list.rb @@ -0,0 +1,5 @@ +class AddAddressProvinsiListRefToAddressKecamatanList < ActiveRecord::Migration[7.1] + def change + add_reference :address_kecamatan_lists, :address_province_list, null: false, foreign_key: true + end +end diff --git a/db/migrate/20240124030936_add_address_kecamatan_list_ref_to_address_kabupaten_list.rb b/db/migrate/20240124030936_add_address_kecamatan_list_ref_to_address_kabupaten_list.rb new file mode 100644 index 0000000..185e1ee --- /dev/null +++ b/db/migrate/20240124030936_add_address_kecamatan_list_ref_to_address_kabupaten_list.rb @@ -0,0 +1,5 @@ +class AddAddressKecamatanListRefToAddressKabupatenList < ActiveRecord::Migration[7.1] + def change + add_reference :address_kabupaten_lists, :address_kecamatan_list, null: false, foreign_key: true + end +end diff --git a/db/schema.rb b/db/schema.rb index b8b9701..9b4fef0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_01_24_014337) do +ActiveRecord::Schema[7.1].define(version: 2024_01_24_030936) do create_table "achievement_kategori_lists", force: :cascade do |t| t.string "kategori" t.datetime "created_at", null: false @@ -66,16 +66,16 @@ t.string "kabupaten" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.integer "address_province_list_id", null: false - t.index ["address_province_list_id"], name: "index_address_kabupaten_lists_on_address_province_list_id" + t.integer "address_kecamatan_list_id", null: false + t.index ["address_kecamatan_list_id"], name: "index_address_kabupaten_lists_on_address_kecamatan_list_id" end create_table "address_kecamatan_lists", force: :cascade do |t| t.string "kecamatan" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.integer "address_kabupaten_list_id", null: false - t.index ["address_kabupaten_list_id"], name: "index_address_kecamatan_lists_on_address_kabupaten_list_id" + t.integer "address_province_list_id", null: false + t.index ["address_province_list_id"], name: "index_address_kecamatan_lists_on_address_province_list_id" end create_table "address_province_lists", force: :cascade do |t| @@ -324,8 +324,8 @@ add_foreign_key "achievements", "users" add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id" - add_foreign_key "address_kabupaten_lists", "address_province_lists" - add_foreign_key "address_kecamatan_lists", "address_kabupaten_lists" + add_foreign_key "address_kabupaten_lists", "address_kecamatan_lists" + add_foreign_key "address_kecamatan_lists", "address_province_lists" add_foreign_key "addresses", "users" add_foreign_key "costs", "users" add_foreign_key "extras", "users" diff --git a/test/controllers/address_kabupaten_lists_controller_test.rb b/test/controllers/address_kabupaten_lists_controller_test.rb new file mode 100644 index 0000000..1106a7c --- /dev/null +++ b/test/controllers/address_kabupaten_lists_controller_test.rb @@ -0,0 +1,63 @@ +require "test_helper" + +class AddressKabupatenListsControllerTest < ActionDispatch::IntegrationTest + setup do + get login_path + post login_path, params: { + session: {email: users(:michael).email, password: 'password'} + } + @address_kabupaten_list = address_kabupaten_lists(:kabacehtimur) + end + + test "should get index" do + get address_kabupaten_lists_url + assert_response :success + end + + test "should get new" do + get new_address_kabupaten_list_url + assert_response :success + end + + test "should create address_kabupaten_list" do + assert_difference("AddressKabupatenList.count") do + post address_kabupaten_lists_url, + params: { address_kabupaten_list: { kabupaten: 'luake' } } + end + + assert_redirected_to address_kabupaten_list_url(AddressKabupatenList.last) + end + + test "should show address_kabupaten_list" do + get address_kabupaten_list_url(@address_kabupaten_list) + assert_response :success + end + + test "should get edit" do + get edit_address_kabupaten_list_url(@address_kabupaten_list) + assert_response :success + end + + test "should update address_kabupaten_list" do + patch address_kabupaten_list_url(@address_kabupaten_list), + params: { address_kabupaten_list: { kabupaten: 'lumajang' } } + assert_redirected_to address_kabupaten_list_url(@address_kabupaten_list) + end + + test "should destroy address_kabupaten_list" do + assert_not_nil AddressKabupatenList.find_by_kabupaten 'kab aceh timur' + assert_not_nil AddressKabupatenList.find_by_kabupaten 'kab aceh tengah' + + assert_difference("AddressKabupatenList.count", -1) do + delete address_kabupaten_list_url(@address_kabupaten_list) + end + assert_nil AddressKabupatenList.find_by_kabupaten 'kab aceh timur' + + @address_kabupaten_list = address_kabupaten_lists(:kabacehtengah) + assert_difference("AddressKabupatenList.count", -1) do + delete address_kabupaten_list_url(@address_kabupaten_list) + end + assert_nil AddressKabupatenList.find_by_kabupaten 'kab aceh tengah' + assert_redirected_to address_kabupaten_lists_url + end +end diff --git a/test/controllers/address_kecamatan_lists_controller_test.rb b/test/controllers/address_kecamatan_lists_controller_test.rb new file mode 100644 index 0000000..e7ab98d --- /dev/null +++ b/test/controllers/address_kecamatan_lists_controller_test.rb @@ -0,0 +1,57 @@ +require "test_helper" + +class AddressKecamatanListsControllerTest < ActionDispatch::IntegrationTest + setup do + get login_path + post login_path, params: { + session: {email: users(:michael).email, password: 'password'} + } + @address_kecamatan_list = address_kecamatan_lists(:acehtengah) + end + + test "should get index" do + get address_kecamatan_lists_url + assert_response :success + end + + test "should get new" do + get new_address_kecamatan_list_url + assert_response :success + end + + test "should create address_kecamatan_list" do + @province = address_province_lists(:aceh) + assert_difference("AddressKecamatanList.count") do + post address_kecamatan_lists_url, + params: { address_kecamatan_list: { kecamatan: 'aceh barat', + address_province_list_id: @province.id} } + end + assert_not_nil AddressKecamatanList.find_by_kecamatan 'aceh barat' + assert_redirected_to address_kecamatan_list_url(AddressKecamatanList.last) + end + + test "should show address_kecamatan_list" do + get address_kecamatan_list_url(@address_kecamatan_list) + assert_response :success + end + + test "should get edit" do + get edit_address_kecamatan_list_url(@address_kecamatan_list) + assert_response :success + end + + test "should update address_kecamatan_list" do + patch address_kecamatan_list_url(@address_kecamatan_list), + params: { address_kecamatan_list: { kecamatan: 'ngurah' } } + assert_not_nil AddressKecamatanList.find_by_kecamatan 'ngurah' + assert_redirected_to address_kecamatan_list_url(@address_kecamatan_list) + end + + test "should destroy address_kecamatan_list" do + assert_difference("AddressKecamatanList.count", -1) do + delete address_kecamatan_list_url(@address_kecamatan_list) + end + + assert_redirected_to address_kecamatan_lists_url + end +end diff --git a/test/controllers/address_province_lists_controller_test.rb b/test/controllers/address_province_lists_controller_test.rb new file mode 100644 index 0000000..cfc98e9 --- /dev/null +++ b/test/controllers/address_province_lists_controller_test.rb @@ -0,0 +1,54 @@ +require "test_helper" + +class AddressProvinceListsControllerTest < ActionDispatch::IntegrationTest + setup do + get login_path + post login_path, params: { + session: {email: users(:michael).email, password: 'password'} + } + @address_province_list = address_province_lists(:aceh) + end + + test "should get index" do + get address_province_lists_url + assert_response :success + end + + test "should get new" do + get new_address_province_list_url + assert_response :success + end + + test "should create address_province_list" do + assert_difference("AddressProvinceList.count") do + post address_province_lists_url, + params: { address_province_list: { provinsi: 'jawa tengah' } } + end + + assert_redirected_to address_province_list_url(AddressProvinceList.last) + end + + test "should show address_province_list" do + get address_province_list_url(@address_province_list) + assert_response :success + end + + test "should get edit" do + get edit_address_province_list_url(@address_province_list) + assert_response :success + end + + test "should update address_province_list" do + patch address_province_list_url(@address_province_list), + params: { address_province_list: { provinsi: 'jawa barat' } } + assert_redirected_to address_province_list_url(@address_province_list) + end + + test "should destroy address_province_list" do + assert_difference("AddressProvinceList.count", -1) do + delete address_province_list_url(@address_province_list) + end + + assert_redirected_to address_province_lists_url + end +end diff --git a/test/fixtures/address_kabupaten_lists.yml b/test/fixtures/address_kabupaten_lists.yml index eeb8e34..8e19683 100644 --- a/test/fixtures/address_kabupaten_lists.yml +++ b/test/fixtures/address_kabupaten_lists.yml @@ -1,7 +1,13 @@ # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html -#one: -# kabupaten: MyString +kabacehtengah: + address_kecamatan_list_id: 19009 + kabupaten: kab aceh tengah -#two: -# kabupaten: MyString +kabacehselatan: + address_kecamatan_list_id: 19009 + kabupaten: kab aceh selatan + +kabacehtimur: + address_kecamatan_list_id: 19009 + kabupaten: kab aceh timur diff --git a/test/fixtures/address_kecamatan_lists.yml b/test/fixtures/address_kecamatan_lists.yml index 9b02d97..f2a4e18 100644 --- a/test/fixtures/address_kecamatan_lists.yml +++ b/test/fixtures/address_kecamatan_lists.yml @@ -1,7 +1,17 @@ # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html -#one: -# kecamatan: MyString +acehtengah: + id: 19009 + address_province_list_id: 1300900 + kecamatan: aceh tengah -#two: -# kecamatan: MyString +acehselatan: + address_province_list_id: 1300900 + kecamatan: aceh selatan + +acehtimur: + address_province_list_id: 1300900 + kecamatan: aceh timur +tobasamosir: + address_province_list_id: 1300911 + kecamatan: toba samosir diff --git a/test/fixtures/address_province_lists.yml b/test/fixtures/address_province_lists.yml index d8b1f55..1508e4a 100644 --- a/test/fixtures/address_province_lists.yml +++ b/test/fixtures/address_province_lists.yml @@ -1,7 +1,9 @@ # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html -#one: -# provinsi: MyString +aceh: + id: 1300900 + provinsi: aceh nag -#two: -# provinsi: MyString +sumut: + id: 1300911 + provinsi: sumatera utara diff --git a/test/models/address_kabupaten_list_test.rb b/test/models/address_kabupaten_list_test.rb index 79a8571..7813780 100644 --- a/test/models/address_kabupaten_list_test.rb +++ b/test/models/address_kabupaten_list_test.rb @@ -1,7 +1,29 @@ require "test_helper" class AddressKabupatenListTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end + def setup + @address_kabupaten = + AddressKabupatenList.new(kabupaten: 'toba', + address_kecamatan_list_id: address_kecamatan_lists(:one).id) + end + test "should be valid kabupaten" do + assert @address_kabupaten.valid? + end + test "kabupaten should be present" do + @address_kabupaten.kabupaten = " " + assert_not @address_kabupaten.valid? + end + test "kabupaten should be unique" do + duplicate_kabupaten = @address_kabupaten.dup + @address_kabupaten.save + assert_not duplicate_kabupaten.valid? + end + test "should reject for too long kabupaten" do + @address_kabupaten.kabupaten = "a" * 36 + assert @address_kabupaten.valid? + end + test "should reject for too short kebupaten" do + @address_kabupaten.kabupaten = 'a'*2 + assert_not @address_kabupaten.valid? + end +end \ No newline at end of file diff --git a/test/models/address_kecamatan_list_test.rb b/test/models/address_kecamatan_list_test.rb index 99484ee..0f92b18 100644 --- a/test/models/address_kecamatan_list_test.rb +++ b/test/models/address_kecamatan_list_test.rb @@ -1,7 +1,29 @@ require "test_helper" class AddressKecamatanListTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end + def setup + @address_kecamatan = + AddressKecamatanList.new(kecamatan: 'toba', + address_province_list_id: address_province_lists(:one).id) + end + test "should be valid kecamatan" do + assert @address_kecamatan.valid? + end + test "kecamatan should be present" do + @address_kecamatan.kecamatan = " " + assert_not @address_kecamatan.valid? + end + test "kecamatan should be unique" do + duplicate_kecamatan = @address_kecamatan.dup + @address_kecamatan.save + assert_not duplicate_kecamatan.valid? + end + test "should reject for too long kecamatan" do + @address_kecamatan.kecamatan = "a" * 36 + assert_not @address_kecamatan.valid? + end + test "should reject for too short kecamatan" do + @address_kecamatan.kecamatan = "a" * 2 + assert_not @address_kecamatan.valid? + end end diff --git a/test/models/address_province_list_test.rb b/test/models/address_province_list_test.rb index 6efdfe3..a778b4b 100644 --- a/test/models/address_province_list_test.rb +++ b/test/models/address_province_list_test.rb @@ -1,7 +1,27 @@ require "test_helper" class AddressProvinceListTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end + def after_setup + @province = AddressProvinceList.new(provinsi: 'jawa barat') + end + test "should accept right province" do + assert @province.valid? + end + test "should reject empty province" do + @province.provinsi = '' + assert_not @province.valid? + end + test "should reject duplicate province" do + @province.save + @province2 = AddressProvinceList.new(provinsi: 'jawa barat') + assert_not @province2.valid? + end + test "should reject for too short province" do + @province.provinsi = 'a'*2 + assert_not @province.valid? + end + test "should reject for too long province" do + @province.provinsi = 'a'*36 + assert_not @province.valid? + end end diff --git a/test/system/address_kabupaten_lists_test.rb b/test/system/address_kabupaten_lists_test.rb new file mode 100644 index 0000000..0d7d6b5 --- /dev/null +++ b/test/system/address_kabupaten_lists_test.rb @@ -0,0 +1,41 @@ +require "application_system_test_case" + +class AddressKabupatenListsTest < ApplicationSystemTestCase + setup do + @address_kabupaten_list = address_kabupaten_lists(:one) + end + + test "visiting the index" do + visit address_kabupaten_lists_url + assert_selector "h1", text: "Address kabupaten lists" + end + + test "should create address kabupaten list" do + visit address_kabupaten_lists_url + click_on "New address kabupaten list" + + fill_in "Kabupaten", with: @address_kabupaten_list.kabupaten + click_on "Create Address kabupaten list" + + assert_text "Address kabupaten list was successfully created" + click_on "Back" + end + + test "should update Address kabupaten list" do + visit address_kabupaten_list_url(@address_kabupaten_list) + click_on "Edit this address kabupaten list", match: :first + + fill_in "Kabupaten", with: @address_kabupaten_list.kabupaten + click_on "Update Address kabupaten list" + + assert_text "Address kabupaten list was successfully updated" + click_on "Back" + end + + test "should destroy Address kabupaten list" do + visit address_kabupaten_list_url(@address_kabupaten_list) + click_on "Destroy this address kabupaten list", match: :first + + assert_text "Address kabupaten list was successfully destroyed" + end +end diff --git a/test/system/address_kecamatan_lists_test.rb b/test/system/address_kecamatan_lists_test.rb new file mode 100644 index 0000000..1f16ff3 --- /dev/null +++ b/test/system/address_kecamatan_lists_test.rb @@ -0,0 +1,41 @@ +require "application_system_test_case" + +class AddressKecamatanListsTest < ApplicationSystemTestCase + setup do + @address_kecamatan_list = address_kecamatan_lists(:one) + end + + test "visiting the index" do + visit address_kecamatan_lists_url + assert_selector "h1", text: "Address kecamatan lists" + end + + test "should create address kecamatan list" do + visit address_kecamatan_lists_url + click_on "New address kecamatan list" + + fill_in "Kecamatan", with: @address_kecamatan_list.kecamatan + click_on "Create Address kecamatan list" + + assert_text "Address kecamatan list was successfully created" + click_on "Back" + end + + test "should update Address kecamatan list" do + visit address_kecamatan_list_url(@address_kecamatan_list) + click_on "Edit this address kecamatan list", match: :first + + fill_in "Kecamatan", with: @address_kecamatan_list.kecamatan + click_on "Update Address kecamatan list" + + assert_text "Address kecamatan list was successfully updated" + click_on "Back" + end + + test "should destroy Address kecamatan list" do + visit address_kecamatan_list_url(@address_kecamatan_list) + click_on "Destroy this address kecamatan list", match: :first + + assert_text "Address kecamatan list was successfully destroyed" + end +end diff --git a/test/system/address_province_lists_test.rb b/test/system/address_province_lists_test.rb new file mode 100644 index 0000000..fdf8a0c --- /dev/null +++ b/test/system/address_province_lists_test.rb @@ -0,0 +1,41 @@ +require "application_system_test_case" + +class AddressProvinceListsTest < ApplicationSystemTestCase + setup do + @address_province_list = address_province_lists(:one) + end + + test "visiting the index" do + visit address_province_lists_url + assert_selector "h1", text: "Address province lists" + end + + test "should create address province list" do + visit address_province_lists_url + click_on "New address province list" + + fill_in "Provinsi", with: @address_province_list.provinsi + click_on "Create Address province list" + + assert_text "Address province list was successfully created" + click_on "Back" + end + + test "should update Address province list" do + visit address_province_list_url(@address_province_list) + click_on "Edit this address province list", match: :first + + fill_in "Provinsi", with: @address_province_list.provinsi + click_on "Update Address province list" + + assert_text "Address province list was successfully updated" + click_on "Back" + end + + test "should destroy Address province list" do + visit address_province_list_url(@address_province_list) + click_on "Destroy this address province list", match: :first + + assert_text "Address province list was successfully destroyed" + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb index ca5c420..ce77d48 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -2,7 +2,7 @@ require_relative "../config/environment" require "rails/test_help" require "minitest/reporters" -Minitest::Reporters.use! +# Minitest::Reporters.use! #for convenience, but conflict on rubymine idea module ActiveSupport