mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-25 05:45:15 +00:00
Add model TermsOfServiceFile
We want to enable instance managers to upload TOS files. I also added the rails_helper which is a new convention. It can contain more Rails specific configuration we currently have in the spec_helper.
This commit is contained in:
8
app/models/terms_of_service_file.rb
Normal file
8
app/models/terms_of_service_file.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class TermsOfServiceFile < ApplicationRecord
|
||||
# The most recently uploaded file is the current one.
|
||||
def self.current
|
||||
order(:id).last
|
||||
end
|
||||
end
|
||||
11
db/migrate/20210415015550_create_terms_of_service_files.rb
Normal file
11
db/migrate/20210415015550_create_terms_of_service_files.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class CreateTermsOfServiceFiles < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
# rubocop:disable Style/SymbolProc
|
||||
create_table :terms_of_service_files do |t|
|
||||
t.timestamps
|
||||
end
|
||||
# rubocop:enable Style/SymbolProc
|
||||
end
|
||||
end
|
||||
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2021_04_14_171109) do
|
||||
ActiveRecord::Schema.define(version: 2021_04_15_015550) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@@ -1145,6 +1145,11 @@ ActiveRecord::Schema.define(version: 2021_04_14_171109) do
|
||||
t.index ["name"], name: "index_tags_on_name", unique: true
|
||||
end
|
||||
|
||||
create_table "terms_of_service_files", force: :cascade do |t|
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
create_table "variant_overrides", force: :cascade do |t|
|
||||
t.integer "variant_id", null: false
|
||||
t.integer "hub_id", null: false
|
||||
|
||||
20
spec/models/terms_of_service_file_spec.rb
Normal file
20
spec/models/terms_of_service_file_spec.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe TermsOfServiceFile do
|
||||
describe ".current" do
|
||||
it "returns nil" do
|
||||
expect(TermsOfServiceFile.current).to be_nil
|
||||
end
|
||||
|
||||
it "returns the last one" do
|
||||
existing = [
|
||||
TermsOfServiceFile.create!,
|
||||
TermsOfServiceFile.create!,
|
||||
]
|
||||
|
||||
expect(TermsOfServiceFile.current).to eq existing.last
|
||||
end
|
||||
end
|
||||
end
|
||||
3
spec/rails_helper.rb
Normal file
3
spec/rails_helper.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
Reference in New Issue
Block a user