diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 83eab7e5553a95f962a74f7d22e361147db4eeda..034cb645221bc4c342c5d8674e05892d4d3aafd7 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -19,18 +19,16 @@ //= require turbolinks //= require_tree . $(document).ready(function(e){ + //Only changes the name of the selected tem in the drop down $('.search-panel .dropdown-menu').find('a').click(function(e) { - e.preventDefault(); - var concept = $(this).text(); - $('.search-panel span#search_concept').text(concept); + //prevents the page from refreshing when clicking an item + e.preventDefault(); + $('.search-panel span#search_concept').text($(this).text()); }); - $('#toggle').click(function() { - $(this).toggleClass('clicked'); - }); + //When the mouse goes off the navbar toggle button, it will not be highlighted $(".navbar-toggle").mouseup(function(){ $(this).blur(); }) - }); \ No newline at end of file diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index ffe1f8e8c2efbeb8c78352f9d07c00d3c3273929..ad5b3843e9ed5c4894d9e3222fe9172008f3af13 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -18,26 +18,20 @@ @import "bootstrap-sprockets"; @import "bootstrap"; +/* Variables*/ $warm-colour: #efefef; $shadow-effect: inset 0px 0px 50px rgba(0,0,0,0.55); $hover-colour: #d3d3d3; - $font: sans serif; - $white: #FFFFFF; /* Nav bar colours */ $navbar-background: #323232; - - /*Toggle button background colour */ $toggle-active-background: #3c3c3c; - /* Globally setting font family to be sans serif */ * { font-family: $font !important; } - - /*Sets the background color*/ body { background: $warm-colour; @@ -51,6 +45,7 @@ body { } +/* Setting some global attributes for the tag hr */ hr { height: 1px; color: #d2d2d2; @@ -59,16 +54,13 @@ hr { border: none; } +/* Setting some global attributes for the tag a */ a:hover, a:focus, a:active { background: transparent; text-decoration: none; color: inherit; } - - - - /* DEVISE: LOGIN STYLING ========================================*/ @@ -205,6 +197,8 @@ Flash container msg } +/* Editing the footer so that the text are in line + making sure the footer covers the whole width*/ footer { width: 100%; background-color: $navbar-background; diff --git a/app/assets/stylesheets/pages.scss b/app/assets/stylesheets/pages.scss index a6b1604466d170ec98f59fb6d98799f6f3a915ec..e223cc9ab5b719cdd148ef93659282e45331a599 100644 --- a/app/assets/stylesheets/pages.scss +++ b/app/assets/stylesheets/pages.scss @@ -2,7 +2,8 @@ // They will automatically be included in application.css. // You can use Sass (SCSS) here: http://sass-lang.com/ - +/* Makes sure the footer stays at the bottom + Makes sure the container is below the navbar when loaded*/ #contact.row { margin-top: 80px; position: relative; diff --git a/app/assets/stylesheets/profiles.scss b/app/assets/stylesheets/profiles.scss index 4195339836155930d198fcc77de9b0fce868748c..0ae02eea096d2897c9ea3b1300a2c62d76ef51e3 100644 --- a/app/assets/stylesheets/profiles.scss +++ b/app/assets/stylesheets/profiles.scss @@ -3,21 +3,20 @@ // You can use Sass (SCSS) here: http://sass-lang.com/ - /* Moves header below the nav bar */ - + /* Provides room for the list of posts that belong to the user */ .halfpage { min-height:35vh; } - +/* Makes sure the footer stays at the bottom + Makes sure the container is below the navbar when loaded + this is applied to the similar views*/ #profile_show.row { margin-top: 80px; position: relative; padding: 0 30px; height: 45vh; } - - #profile_new.row { margin: 80px 0px; padding: 0 30px; @@ -30,6 +29,7 @@ height: 70vh; } +/* reducing the padding on this hr tag */ hr.divider { margin: 0em; border-width: 2px; diff --git a/app/assets/stylesheets/reviews.scss b/app/assets/stylesheets/reviews.scss index de18d5659fbfcd948ad1b2e08b318f7016cd3946..dbc9eeac004078c4bcb1fdd6f197961fcdf0a8aa 100644 --- a/app/assets/stylesheets/reviews.scss +++ b/app/assets/stylesheets/reviews.scss @@ -2,7 +2,9 @@ // They will automatically be included in application.css. // You can use Sass (SCSS) here: http://sass-lang.com/ - +/* Makes sure the footer stays at the bottom + Makes sure the container is below the navbar when loaded + this is applied to the similar views*/ #reviews_new.row { margin-top: 80px; padding: 0 30px; diff --git a/app/assets/stylesheets/scaffolds.scss b/app/assets/stylesheets/scaffolds.scss index ed7a765d9acc0ccc7bb77dc1176083bc98b64eeb..7ee962a4b0a22cd458f3615dfa2c308d53629bd4 100644 --- a/app/assets/stylesheets/scaffolds.scss +++ b/app/assets/stylesheets/scaffolds.scss @@ -1,3 +1,4 @@ +/* CSS GENERATED BY SCAFFOLD */ body { background-color: #fff; color: #333; diff --git a/app/controllers/reviews_controller.rb b/app/controllers/reviews_controller.rb index 1166f3a6515cfac77d848af350568f4eea270921..45643b1463e2778bcdfd63d3cd9439d067708f10 100644 --- a/app/controllers/reviews_controller.rb +++ b/app/controllers/reviews_controller.rb @@ -7,10 +7,7 @@ class ReviewsController < ApplicationController before_action :same_account, :authenticate_user!, :must_make_account, only: [:new, :edit, :create, :update, :destroy, ] #Finds the currently viewed profile before_action :find_profile - #The index action which displays all the reviews onto a form - def index - @reviews = Review.all - end + #The new action allows the user to create a new review def new @review = Review.new diff --git a/app/models/post.rb b/app/models/post.rb index 1532aa562d1bacd0f05c99cb764bfe8a94415d2f..b258c201ea74280821a5a5dea5649fdaed10d7f5 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -8,10 +8,9 @@ class Post < ActiveRecord::Base validates :title, :description, :price, :address_one, :city, :postal_code, :city, :postal_code, :phone_number, :category_id, :user_id, presence: true #Validates the phone number checking if it has a valid phone number - validates :phone_number, format: { with: /\d{11}/, message: "Enter valid phone number" } + validates :phone_number, format: { with: /\d{11}/} #Validates the postal code checking if it has a valida email - validates :postal_code, format: { with: /([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9][A-Za-z]?))))\s?[0-9][A-Za-z]{2})/, - message: "Enter valid postal code" } + validates :postal_code, format: { with: /([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9][A-Za-z]?))))\s?[0-9][A-Za-z]{2})/} #Sets up paper clip to be used within post has_attached_file :post_image, styles: { post_index: "300x300>", post_show: "300x300>" }, default_url: "/images/:style/missing.png" #validates an image, diff --git a/app/views/posts/_masthead.haml b/app/views/posts/_masthead.haml index 2f84ce73a25122f3ed2459f4cea0928feb0b76d6..1e214a37c7bb451527eff78c409fc6b8ea4795e4 100644 --- a/app/views/posts/_masthead.haml +++ b/app/views/posts/_masthead.haml @@ -28,7 +28,11 @@ %input.form-control{:name => "x", :placeholder => "Search for something", :type => "text"} %span.input-group-btn %button.btn.btn-default{:type => "button"} - %span.glyphicon.glyphicon-search + Search -#SUBHEADING %br %span.subheading Find something in time for christmas + += simple_form_for :search, {url: posts_path} do |f| + = f.input :user_email, :as => :hidden, :input_html => { :value => current_user.email} + = f.input :user_telephone, :as => :hidden, :input_html => { :value => current_user.profile.number} diff --git a/config/locales/en.yml b/config/locales/en.yml index 0018af3fc5f242dd4e47c700b00f40e2592abc08..f8c7fc12a6a993b2d5ea55c5d922b0aba54c72f1 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -24,6 +24,8 @@ en: app_Description: Sell sell sell back: Back additional: Contact Information + model: + phonenumber: Enter a valid phone number devise: passwords: new: diff --git a/test/controllers/reviews_controller_test.rb b/test/controllers/reviews_controller_test.rb index 3eb5cb777fe1af56008c6dbdbc72d01319488bbe..d865c19b0c9111f4347b4f81cde10c9ba343256f 100644 --- a/test/controllers/reviews_controller_test.rb +++ b/test/controllers/reviews_controller_test.rb @@ -20,13 +20,6 @@ class ReviewsControllerTest < ActionController::TestCase # resets the cache Rails.cache.clear end - - test "should get index" do - get :index, profile_id: @profile.id - assert_response :success - assert_not_nil assigns(:reviews) - end - test "should get new" do get :new, profile_id: @profile.id assert_select "h1" , I18n.t('reviews.new.title') diff --git a/test/models/category_test.rb b/test/models/category_test.rb index 7f2c3d40d4db326cd7a08a2b9f459326f0931179..9d806131692fd838a283eb16c4bb0fc0cd1e32fd 100644 --- a/test/models/category_test.rb +++ b/test/models/category_test.rb @@ -8,7 +8,7 @@ class CategoryTest < ActiveSupport::TestCase #Cannot create a category with empty name field - test 'should not save invalid user' do + test 'should not save invalid category' do category = Category.new category.save refute category.valid?