Skip to content

Commit

Permalink
Now made quick-post look a bit better
Browse files Browse the repository at this point in the history
  • Loading branch information
wahl77 committed Sep 2, 2013
1 parent d885afb commit 8823b0c
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 13 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ group :test, :development do
gem 'guard-rspec'
gem 'guard-livereload'
gem 'guard-bundler'
gem 'guard-zeus'
gem 'capybara'
gem 'selenium-webdriver'
gem 'database_cleaner'
Expand Down
6 changes: 6 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ GEM
guard-rspec (3.0.2)
guard (>= 1.8)
rspec (~> 2.13)
guard-zeus (0.0.1)
guard
zeus
haml (4.0.3)
tilt
haml-rails (0.4)
Expand Down Expand Up @@ -277,6 +280,8 @@ GEM
websocket (1.0.7)
xpath (2.0.0)
nokogiri (~> 1.3)
zeus (0.13.3)
method_source (>= 0.6.7)

PLATFORMS
ruby
Expand All @@ -297,6 +302,7 @@ DEPENDENCIES
guard-bundler
guard-livereload
guard-rspec
guard-zeus
haml-rails
jbuilder (~> 1.2)
jquery-rails
Expand Down
1 change: 1 addition & 0 deletions Guardfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ guard 'bundler' do
# Uncomment next line if Gemfile contain `gemspec' command
# watch(/^.+\.gemspec/)
end

3 changes: 2 additions & 1 deletion app/assets/javascripts/static_pages.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,10 @@ jQuery ->
$('form#search_address').on("submit", find_address_location)

# The following is for displaying quick form in posting
$('#item_name').on("focus",
$('#post_item').on("focus",
(event) ->
$('#spread_post_d').addClass("open")
$('#item_name').focus()
)
$('.close_drop_down').on('click'
(event) ->
Expand Down
12 changes: 12 additions & 0 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@
#spread_post_dropdown{
padding: 10px;
padding-top: 5px;
width: 105%;
top: -61px;
left: -1px;
}
@media screen and (max-width: 768px) {
#spread_post_dropdown{
padding: 10px;
padding-top: 5px;
top: -70px;
width: 102%;
left: -10px
}
}

#query_nav, #location_query_nav{
Expand Down
9 changes: 7 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ class ApplicationController < ActionController::Base
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception

before_action :require_login
before_action :require_login, :create_menu_variables

rescue_from CanCan::AccessDenied do |exception|
redirect_to user_path(current_user), alert: "Message: #{exception.message}"
end


def create_menu_variables
@form_item = Item.new
@form_address = @form_item.build_address
@form_image = @form_item.images.build
end

protected
def not_authenticated
redirect_to root_path, :alert => "Please login first."
Expand All @@ -30,6 +36,5 @@ def user_current_location
end

return address

end
end
16 changes: 10 additions & 6 deletions app/views/layouts/_nav.haml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,19 @@
.container
.col-lg-4
- if current_user
- @form_item = Item.new
- @form_address = @form_item.build_address
%form.navbar.navbar-form
= text_field_tag "OK", nil, placeholder: "Spread Post", class:"form-control", id:"post_item"
= form_for @form_item, html:{class:"navbar-form form-inline"} do |f|
= f.label :name, nil, class:"sr-only"
= f.text_field :name, class: "form-control", placeholder: "Post Title"
.dropdown#spread_post_d
.dropdown-menu#spread_post_dropdown{"aria-labelledby" => "dropdownMenu1", :role => "menu", style:"width: 100%"}
.dropdown-menu#spread_post_dropdown{"aria-labelledby" => "dropdownMenu1", :role => "menu"}
.close_drop_down.pull-right{style: "font-size: 26px; display: block"}= link_to "×", "#"
%br
.field
.row
.col-lg-10
= f.label :name, nil, class:"label-control"
.col-lg-2
= f.text_field :name, class: "form-control", placeholder: "Spread Post"

.field
= f.label :description, nil, class:"label-control"
Expand Down Expand Up @@ -69,7 +73,7 @@
.field
= f.label :address_id, nil, class:"control-label"
= f.select :address_id, options_for_select(current_user.addresses.map{|x| [x.name, x.id]}), {}, class: "form-control"
= f.fields_for @form_item.images.build do |form|
= f.fields_for :images do |form|
.field
= form.label :url, "Add Picture", class:"label-control"
= form.file_field :url, class:"form-control"
Expand Down
1 change: 0 additions & 1 deletion spec/features/items_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

it "can be edited only if I own it" do
visit item_path(@item)
sleep 5
expect(page).to have_link "Edit"
expect(page).to have_content @item.name
click_link "Edit"
Expand Down
39 changes: 36 additions & 3 deletions spec/features/static_pages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,27 @@
login(@user)
end

it "loads a blank page" do
it "loads a blank page" do
visit logout_path
visit root_path
expect(page).to have_content "A great place"
end

it "can log in/out" do
it "can sign up" do
visit logout_path
visit root_path
click_link "Login"
click_link "Signup"
within("form#new_user") do
fill_in "Email", with: "[email protected]"
fill_in "Password", with: "ba$8903<#"
fill_in "Password Confirmation", with: "ba$8903<#"
end
click_button "Signup"
expect(page).to have_content "User was successfully created."
end

it "can log in/out" do
visit logout_path
expect(page).to have_content "Logged Out"
visit root_path
Expand All @@ -23,10 +37,29 @@
@user.password = "a"
@user.save
fill_in "password", with: "a"
within("#login_modal") do
within("#login_modal") do
click_button "Login"
end
expect(page).to have_content "Logged in successfully!"
end

describe "Check only authorized pages if not logged in" do
before do
visit logout_path
@login_first = "Please login first"
end
it "cannot create new item" do
visit new_item_path
expect(page).to have_content @login_first
end

it "can view an item but not post a comment" do
item = FactoryGirl.create(:item)
visit item_path(item)
expect(page).to have_content item.name
visit edit_item_path(item)
expect(page).to have_content @login_first
end
end

end
4 changes: 4 additions & 0 deletions spec/support/env.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome)
end
#Capybara.javascript_driver = :chrome

0 comments on commit 8823b0c

Please sign in to comment.