Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Bella8/betsy
Browse files Browse the repository at this point in the history
  • Loading branch information
guineveresaenger committed Oct 28, 2016
2 parents 0f09844 + 7f6607c commit b13f664
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 59 deletions.
Binary file added app/assets/images/robits_logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 33 additions & 2 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,38 @@
*/

body {
background-image: url(cute_robots.jpg);
h1, .title-area, .name {
margin: 0 0;
background-color: rgb(245,242,225)
}

.name {
list-style: none;
}

a {
color: #e6e6e6;
}

a:hover {
color: #cacaca;
}

.top-bar, .top-bar ul {
background-color: rgb(136,149,194);
padding: 0;
}

.dropdown.menu.medium-horizontal > li.is-dropdown-submenu-parent > a::after {
border-top-color: #e6e6e6;
}

.logo-name {
position: absolute;
left: 8.5rem;
top: 2rem;
color: rgb(136, 149, 194);
text-shadow: 2px 2px 3px rgb(82, 82, 142);
font-family: 'Chelsea Market', cursive;

}
44 changes: 44 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,48 @@
module ApplicationHelper
def user_name
begin
user = Merchant.find(session[:merchant_id])
if user.user_name
return user.user_name
elsif user.email
return user.email
else
return "#{user.provider} user #{user.uid}"
end
rescue ActiveRecord::RecordNotFound
return "ERROR: user not in database"
end
end

def login_status
if session[:merchant_id].nil?
sign_up_button
else
"Logged in as #{user_name}"
end
end

def login_button(**kwargs)
if session[:merchant_id].nil?
text = "Log In"
path = "/auth/github"
method = :get
else
text = "Log Out"
path = sessions_path
method = :delete
end
link_to text, path, method: method, **kwargs
end

def sign_up_button(**kwargs)
if session[:merchant_id].nil?
text = "Sign Up with Github"
path = "https://github.com/join?source=header-home"
method = :get
end
link_to text, path, method: method, **kwargs
end

def render_date(date)
("<span class='date'>" + date.strftime("%A, %b %d %Y") + "</span>").html_safe
Expand Down
91 changes: 45 additions & 46 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,46 +1,42 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<title><%= content_for?(:title) ? yield(:title) : "Untitled" %></title>
<title><%= content_for?(:title) ? yield(:title) : "Untitled" %></title>

<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application", 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application", 'data-turbolinks-track' => true %>

<body>
<header>
<h3><%= link_to "ROBITS", root_path %></h3>
<!-- ROBITS cute font -->
<link href="https://fonts.googleapis.com/css?family=Chelsea+Market" rel="stylesheet">
<%= csrf_meta_tags %>
</head>

<!-- Navigation row for top Menu -->
<nav class="row">

<!-- log in stuff -->
<section>

<% if session[:merchant_id] %>
Login Successful! Welcome <%= "#{current_merchant.user_name}" %>!
<%= button_to "Log out", sessions_path, method: :delete %>
<%= button_to "Merchant Control", sessions_merchant_login_path, method: :get %>
<% else %>
<% if flash[:error] %>
<%= flash[:error] %>
<% end %>
<%= button_to "Log In", "/auth/github", method: :get %>
<%= button_to "Sign Up", "https://github.com/join?source=header-home", method: :get %>
<% end %>
</section>
<body>
<header>

<!-- Navigation row for top Menu -->
<nav class="row top-bar">
<section class="small-12 column">
<ul class="title-area row">
<li class="name centered column">
<h1><%= image_tag("robits_logo") %> <%= link_to "ROBITS", root_path, class: "logo-name" %></h1>
</li>
</ul>
</section>

<section class="small-12 columns">
<!-- Make this unordered list horizontal at medium and larger screens & verticle on small ones -->
<div class="lower-link-area">
<section class="small-12 columns top-bar-left">
<!-- Make this unordered list horizontal at medium and larger screens & verticle on small ones -->
<ul class="vertical menu medium-horizontal" data-responsive-menu="accordion medium-dropdown">
<li>
<%= link_to 'SHOP ALL', products_path %>
</li>

<li>
CATEGORIES
<%= link_to 'CATEGORIES', categories_path %>
<!-- Submenu of Categories -->
<ul class="menu vertical">
<% category.each do |f| %>
Expand All @@ -50,8 +46,9 @@
<% end %>
</ul>
</li>

<li>
MERCHANTS
<%= link_to 'MERCHANTS', merchants_path %>
<!-- Submenu of Merchants -->
<ul class="menu vertical">
<% merchant.each do |f| %>
Expand All @@ -62,18 +59,20 @@

</ul>
</li>
<li><%= link_to "Google", "https://www.google.com" %>
<ul class="menu">
<li><%= link_to "Google Drive", "https://drive.google.com" %></li>
</ul>
</li>
<li><%= link_to "Facebook", "https://www.facebook.com" %></li>
<li><%= link_to "Log in via Github", "auth/github" %></li>
</ul>
</section>
</nav>
</section>

<section>

<ul class="menu top-bar-right">
<li><%= login_status %></li>
<li><%= login_button %></li>
</ul>
</section>
</div>

</nav>

<%= yield %>
<%= yield %>

</body>
</html>
</body>
</html>
30 changes: 20 additions & 10 deletions test/controllers/categories_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,9 @@ def login_a_user
get :create, { provider: "github" }
end

test "should get the new form when creating a new category" do
# This is working
# session[:merchant_id] = merchants(:one).id

# This is not working
# login_a_user
# session[:merchant_id]
test "should get the new form when a logged-in User create a new category" do
session[:merchant_id] = merchants(:one).id
get :new

assert_response :success
assert_template :new

Expand All @@ -38,7 +32,23 @@ def login_a_user
assert_nil category.name
end

test "should create a new Category after a logged-in User fill in the form and submit" do
session[:merchant_id] = merchants(:one).id
assert_difference('Category.count', 1) do
post_params = { category: { name: "Phone"}}
post :create, post_params
end
assert_redirected_to categories_path
assert_response :redirect
end



test "cannot create an new Category without valid inputs and will render the new form" do
session[:merchant_id] = merchants(:one).id
assert_no_difference('Category.count') do
post_params = { category: { name: nil }}
post :create, post_params
end
assert_template :new
assert_response :success
end
end
2 changes: 1 addition & 1 deletion test/controllers/sessions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def login_a_user

test "a logged-out Merchant user will get redirected to Homepage" do
login_a_user
delete :destroy, id: session[:merchant_id]
delete :destroy
assert_response :redirect
assert_redirected_to sessions_log_out_path
assert_nil session[:merchant_id]
Expand Down

0 comments on commit b13f664

Please sign in to comment.