From 42e0da1aa05ea1e652b9556a1a7648a18a98070f Mon Sep 17 00:00:00 2001 From: songtianlun Date: Fri, 17 Jan 2025 18:05:42 +0800 Subject: [PATCH] feat: add city and weather art models - Create City model with attributes: name, country, latitude, longitude, and featured. - Create WeatherArt model with attributes: weather_date, weather_condition, description, and prompt. - Add migration files for creating cities and weather arts tables. - Include fixture files for cities and weather arts for testing. - Add basic test files for both models. These changes introduce new models and database tables to support city and weather art data, enabling future features related to weather information and city management. --- app/models/city.rb | 2 ++ app/models/weather_art.rb | 2 ++ db/migrate/20250117093758_create_cities.rb | 13 +++++++++++++ db/migrate/20250117095400_create_weather_arts.rb | 12 ++++++++++++ test/fixtures/cities.yml | 15 +++++++++++++++ test/fixtures/weather_arts.yml | 13 +++++++++++++ test/models/city_test.rb | 7 +++++++ test/models/weather_art_test.rb | 7 +++++++ 8 files changed, 71 insertions(+) create mode 100644 app/models/city.rb create mode 100644 app/models/weather_art.rb create mode 100644 db/migrate/20250117093758_create_cities.rb create mode 100644 db/migrate/20250117095400_create_weather_arts.rb create mode 100644 test/fixtures/cities.yml create mode 100644 test/fixtures/weather_arts.yml create mode 100644 test/models/city_test.rb create mode 100644 test/models/weather_art_test.rb diff --git a/app/models/city.rb b/app/models/city.rb new file mode 100644 index 0000000..f2188b0 --- /dev/null +++ b/app/models/city.rb @@ -0,0 +1,2 @@ +class City < ApplicationRecord +end diff --git a/app/models/weather_art.rb b/app/models/weather_art.rb new file mode 100644 index 0000000..845bff4 --- /dev/null +++ b/app/models/weather_art.rb @@ -0,0 +1,2 @@ +class WeatherArt < ApplicationRecord +end diff --git a/db/migrate/20250117093758_create_cities.rb b/db/migrate/20250117093758_create_cities.rb new file mode 100644 index 0000000..6ee56b4 --- /dev/null +++ b/db/migrate/20250117093758_create_cities.rb @@ -0,0 +1,13 @@ +class CreateCities < ActiveRecord::Migration[8.0] + def change + create_table :cities do |t| + t.string :name + t.string :country + t.decimal :latitude + t.decimal :longitude + t.boolean :featured + + t.timestamps + end + end +end diff --git a/db/migrate/20250117095400_create_weather_arts.rb b/db/migrate/20250117095400_create_weather_arts.rb new file mode 100644 index 0000000..eb06cbc --- /dev/null +++ b/db/migrate/20250117095400_create_weather_arts.rb @@ -0,0 +1,12 @@ +class CreateWeatherArts < ActiveRecord::Migration[8.0] + def change + create_table :weather_arts do |t| + t.date :weather_date + t.string :weather_condition + t.text :description + t.string :prompt + + t.timestamps + end + end +end diff --git a/test/fixtures/cities.yml b/test/fixtures/cities.yml new file mode 100644 index 0000000..64687c3 --- /dev/null +++ b/test/fixtures/cities.yml @@ -0,0 +1,15 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyString + country: MyString + latitude: 9.99 + longitude: 9.99 + featured: false + +two: + name: MyString + country: MyString + latitude: 9.99 + longitude: 9.99 + featured: false diff --git a/test/fixtures/weather_arts.yml b/test/fixtures/weather_arts.yml new file mode 100644 index 0000000..246ddaf --- /dev/null +++ b/test/fixtures/weather_arts.yml @@ -0,0 +1,13 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + weather_date: 2025-01-17 + weather_condition: MyString + description: MyText + prompt: MyString + +two: + weather_date: 2025-01-17 + weather_condition: MyString + description: MyText + prompt: MyString diff --git a/test/models/city_test.rb b/test/models/city_test.rb new file mode 100644 index 0000000..a294ebc --- /dev/null +++ b/test/models/city_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class CityTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/weather_art_test.rb b/test/models/weather_art_test.rb new file mode 100644 index 0000000..f00458e --- /dev/null +++ b/test/models/weather_art_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class WeatherArtTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end