diff --git a/app/assets/javascripts/newsletter.coffee b/app/assets/javascripts/newsletter.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/newsletter.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/newsletter.scss b/app/assets/stylesheets/newsletter.scss new file mode 100644 index 0000000..86adfd4 --- /dev/null +++ b/app/assets/stylesheets/newsletter.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Newsletter controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/newsletter_controller.rb b/app/controllers/newsletter_controller.rb new file mode 100644 index 0000000..fe16698 --- /dev/null +++ b/app/controllers/newsletter_controller.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +# Getting Newsletter emails +class NewsletterController < ApplicationController + def index; end + + def new + @new_email = NewEmail.new + end + + def create + @new_email = NewEmail.new + end + + def destroy; end +end diff --git a/app/controllers/site_controller.rb b/app/controllers/site_controller.rb index 141847a..05bf2c3 100644 --- a/app/controllers/site_controller.rb +++ b/app/controllers/site_controller.rb @@ -74,8 +74,6 @@ class SiteController < ApplicationController else return head(:bad_request) end - - end diff --git a/app/helpers/newsletter_helper.rb b/app/helpers/newsletter_helper.rb new file mode 100644 index 0000000..8253714 --- /dev/null +++ b/app/helpers/newsletter_helper.rb @@ -0,0 +1,2 @@ +module NewsletterHelper +end diff --git a/app/models/new_email.rb b/app/models/new_email.rb new file mode 100644 index 0000000..73b0311 --- /dev/null +++ b/app/models/new_email.rb @@ -0,0 +1,2 @@ +class NewEmail < ApplicationRecord +end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 38fd2e4..deeefa9 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -36,12 +36,12 @@ <%= yield %> - <%= javascript_include_tag 'browser.min', 'breakpoints.min', 'util', 'main' %> <%= yield :footer_scripts %> - + \ No newline at end of file diff --git a/app/views/newsletter/create.html.erb b/app/views/newsletter/create.html.erb new file mode 100644 index 0000000..6dcad57 --- /dev/null +++ b/app/views/newsletter/create.html.erb @@ -0,0 +1,2 @@ +

Newsletter#create

+

Find me in app/views/newsletter/create.html.erb

diff --git a/app/views/newsletter/index.html.erb b/app/views/newsletter/index.html.erb new file mode 100644 index 0000000..ab6c50b --- /dev/null +++ b/app/views/newsletter/index.html.erb @@ -0,0 +1,2 @@ +

Newsletter#index

+

Find me in app/views/newsletter/index.html.erb

diff --git a/app/views/newsletter/new.html.erb b/app/views/newsletter/new.html.erb new file mode 100644 index 0000000..f951722 --- /dev/null +++ b/app/views/newsletter/new.html.erb @@ -0,0 +1,2 @@ +

Newsletter#new

+

Find me in app/views/newsletter/new.html.erb

diff --git a/app/views/site/index.html.erb b/app/views/site/index.html.erb index 7ffebed..a347f52 100644 --- a/app/views/site/index.html.erb +++ b/app/views/site/index.html.erb @@ -10,12 +10,12 @@ Już niedługo powstanie tu pierwszy w Polsce internetowy kurs wzmacniania konstrukcji włóknami węglowymi CFRP. Jeżeli nie jesteś zainteresowany nowoczesnymi metodami wzmacniania budowli, innowacyjnymi materiałami, nie jesteś inżynierem albo technikiem budownictwa, architektem, bądź wschodzącą gwiazdą budowlanki na studiach, to nie klikaj w przycisk.

JESTEM CIEKAW - Wersja 1|Wersja 2 + - diff --git a/config/routes.rb b/config/routes.rb index 2112eb0..4e03207 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,5 @@ Rails.application.routes.draw do + resources :newsletter, only: %i[index new create destroy] namespace :admin do namespace :articles do get 'all_page/publish' diff --git a/db/migrate/20191202132743_create_new_emails.rb b/db/migrate/20191202132743_create_new_emails.rb new file mode 100644 index 0000000..e498d04 --- /dev/null +++ b/db/migrate/20191202132743_create_new_emails.rb @@ -0,0 +1,13 @@ +class CreateNewEmails < ActiveRecord::Migration[5.1] + def change + create_table :new_emails do |t| + t.string :email + t.boolean :active + t.datetime :accepted + + t.timestamps + end + add_index :new_emails, :email + add_index :new_emails, :active + end +end diff --git a/db/schema.rb b/db/schema.rb index 9e05be6..80dcca8 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.define(version: 20180119145343) do +ActiveRecord::Schema.define(version: 20191202132743) do create_table "admins", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci" do |t| t.string "email", default: "", null: false @@ -67,6 +67,16 @@ ActiveRecord::Schema.define(version: 20180119145343) do t.index ["sluggable_type"], name: "index_friendly_id_slugs_on_sluggable_type" end + create_table "new_emails", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci" do |t| + t.string "email" + t.boolean "active" + t.datetime "accepted" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["active"], name: "index_new_emails_on_active" + t.index ["email"], name: "index_new_emails_on_email" + end + create_table "published_pages", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci" do |t| t.string "name", limit: 40, null: false t.string "title", null: false @@ -74,6 +84,7 @@ ActiveRecord::Schema.define(version: 20180119145343) do t.string "meta_description" t.integer "all_page_id", null: false t.boolean "nofollow", default: false, null: false + t.integer "number_of_views", default: 0, null: false t.integer "type_of", null: false t.integer "article_id" t.integer "priority", default: 0, null: false @@ -83,6 +94,16 @@ ActiveRecord::Schema.define(version: 20180119145343) do t.integer "created_by" t.timestamp "updated_at" t.integer "updated_by" + t.index ["all_page_id"], name: "all_page_id" + t.index ["created_at"], name: "created_at" + t.index ["number_of_views"], name: "number_of_views" + t.index ["slug"], name: "slug" + t.index ["type_of"], name: "type_of" + end + + create_table "sc_settings", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci" do |t| + t.integer "index_number_of_views", default: 0, null: false + t.integer "contact_number_of_views", default: 0, null: false end end diff --git a/test/controllers/newsletter_controller_test.rb b/test/controllers/newsletter_controller_test.rb new file mode 100644 index 0000000..eb751f9 --- /dev/null +++ b/test/controllers/newsletter_controller_test.rb @@ -0,0 +1,19 @@ +require 'test_helper' + +class NewsletterControllerTest < ActionDispatch::IntegrationTest + test "should get index" do + get newsletter_index_url + assert_response :success + end + + test "should get new" do + get newsletter_new_url + assert_response :success + end + + test "should get create" do + get newsletter_create_url + assert_response :success + end + +end diff --git a/test/fixtures/new_emails.yml b/test/fixtures/new_emails.yml new file mode 100644 index 0000000..da2a2b6 --- /dev/null +++ b/test/fixtures/new_emails.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + email: MyString + active: false + accepted: 2019-12-02 14:27:43 + +two: + email: MyString + active: false + accepted: 2019-12-02 14:27:43 diff --git a/test/models/new_email_test.rb b/test/models/new_email_test.rb new file mode 100644 index 0000000..6154530 --- /dev/null +++ b/test/models/new_email_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class NewEmailTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end