Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'bootstrap-sass', '~> 3.3.6'
gem 'sass-rails', '~> 5.0'
gem 'font-awesome-sass', '~> 4.7.0'
# Use Uglifier as compressor for JavaScript assets
Expand Down
4 changes: 0 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ GEM
autoprefixer-rails (>= 6.0.3)
popper_js (>= 1.12.3, < 2)
sass (>= 3.5.2)
bootstrap-sass (3.3.7)
autoprefixer-rails (>= 5.2.1)
sass (>= 3.3.4)
builder (3.2.3)
byebug (9.1.0)
capybara (2.15.4)
Expand Down Expand Up @@ -229,7 +226,6 @@ PLATFORMS
DEPENDENCIES
bcrypt (~> 3.1.7)
bootstrap
bootstrap-sass (~> 3.3.6)
byebug
capybara (~> 2.13)
coffee-rails (~> 4.2)
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
//= require jquery_ujs
//= require turbolinks
//= require jquery
//= require popper
//= require bootstrap-sprockets
//= require_tree .

Expand Down
Empty file.
5 changes: 3 additions & 2 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@

*/
// "bootstrap-sprockets" must be imported before "bootstrap" and "bootstrap/variables"
@import "bootstrap-sprockets";
@import "bootstrap";
@import "font-awesome-sprockets";
@import "font-awesome";
@import "submit_events";
@import "submit_events";
@import "admin";
@import "login";


.stats{
Expand Down
3 changes: 2 additions & 1 deletion app/assets/stylesheets/login.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
border: 0.1px solid gray;
padding: 1px;
border-radius: 5px;
display:none;
display: none;
clear: both;

p {
margin: 1px;
Expand Down
22 changes: 22 additions & 0 deletions app/controllers/admin/dashboard_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class Admin::DashboardController < ApplicationController
before_action :require_admin_login, only: :index

def index
@user = User.find(current_user)

@events = [
{
id: 1,
fb_id: '4f3817489',
created_at: Time.now,
updated_at: Time.now,
},
{
id: 2,
fb_id: 'fajsdklfas',
created_at: 1.day.ago,
updated_at: 1.day.ago,
}
]
end
end
13 changes: 7 additions & 6 deletions app/controllers/admin/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
class Admin::SessionsController < ApplicationController
before_action :require_admin_login, only: :index
before_action :redirect_if_logged_in, except: :index
before_action :require_admin_login, only: [:index, :destroy]
before_action :redirect_if_logged_in, except: [:index, :destroy]

def new; end

def index
render plain: "Hello World!"
end

def create
user = User.find_by(email: params[:email])

Expand All @@ -18,4 +14,9 @@ def create
render_login_error
end
end

def destroy
session[:user_id] = nil
redirect_to root_path
end
end
9 changes: 9 additions & 0 deletions app/services/get_fb_event_object_from_fb_id_service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class GetFbEventObjectFromFbIdService
def initialize(params)
@fb_id = params[:fb_id]
end

def fetch
@fb_id
end
end
43 changes: 43 additions & 0 deletions app/views/admin/dashboard/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<div id="admin-page">
<div class="flex-row d-flex justify-content-center" id="welcome">
<div class="col-md-8">
<div>
<%= "Logged in as #{@user.email}." %>
<%= link_to 'Log Out', admin_logout_path, method: :post %>
</div>
</div>
</div>
<div class="flex-row my-2 d-flex justify-content-center" id="view-delete-events">
<div class="col-md-8">
<%= link_to "View Deleted Events", '#' %>
</div>
</div>
<div class="flex-row my-4 d-flex justify-content-center">
<div class="col-md-8">
<h1>Moderate Suggested Events</h1>
</div>
</div>
<div id="events_panel">
<% @events.each do |event| %>
<div class="flex-row my-2 d-flex justify-content-center" id="an_event">
<div class="col-md-2" id="date">
<span>Jan</span>
<div class="w-30"></div>
<spam>29</span>
</div>
<div class="col-md-4" id="event-details">
<span>Title</span>
<div class="w-100"></div>
<span>Day and Time</span>
<div class="w-100"></div>
<span>Location</span>
</div>
<div class="col-md-2" id="event-controls">
<button class="btn" id="accept">Accept</button>
<div class="my-2 w-30"></div>
<button class="btn" id="not_accept">Delete</button>
</div>
</div>
<% end %>
</div>
</div>
30 changes: 15 additions & 15 deletions app/views/layouts/_navbar.html.erb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<div class="navigation">
<%= image_tag("logo.jpg", :alt => "SLLA Logo", :class => "logo") %>
<div class="links">
<ul style="font-family: 'Oswald', sans-serif;">
<a href="calendar">Calendar</a>
<a href="submit">Submit</a>
<%= link_to('Join', 'https://www.facebook.com/groups/1203067669814957/?ref=br_tf&qsefr=1', target: '_blank') %>
</ul>
</div>
<div class="social">
<ul>
<%= link_to image_tag('github.png'), 'https://github.com/seport/SLLA', target: '_blank' %>
<%= link_to image_tag('twitter.png'),'https://twitter.com/StayLoudLA', target: '_blank' %>
<%= link_to image_tag('facebook.png'), 'https://www.facebook.com/groups/1203067669814957/?ref=br_tf&qsefr=1', target: '_blank' %>
</ul>
</div>
<%= image_tag("logo.jpg", :alt => "SLLA Logo", :class => "logo") %>
<div class="links">
<ul style="font-family: 'Oswald', sans-serif;">
<a href="calendar">Calendar</a>
<a href="submit">Submit</a>
<%= link_to('Join', 'https://www.facebook.com/groups/1203067669814957/?ref=br_tf&qsefr=1', target: '_blank') %>
</ul>
</div>
<div class="social">
<ul>
<%= link_to image_tag('github.png'), 'https://github.com/seport/SLLA', target: '_blank' %>
<%= link_to image_tag('twitter.png'),'https://twitter.com/StayLoudLA', target: '_blank' %>
<%= link_to image_tag('facebook.png'), 'https://www.facebook.com/groups/1203067669814957/?ref=br_tf&qsefr=1', target: '_blank' %>
</ul>
</div>
</div>
5 changes: 4 additions & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
<%= stylesheet_link_tag "https://fonts.googleapis.com/css?family=Oswald" %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>

</head>

<body>
<%= render 'layouts/navbar' %>
<%= yield %>
<div class="container">
<%= yield %>
</div>
</body>
</html>
3 changes: 2 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
root 'welcome#index'

namespace :admin do
get '/', to: 'sessions#index'
get '/', to: 'dashboard#index'
get 'login', to: 'sessions#new'
post 'login', to: 'sessions#create'
post 'logout', to: 'sessions#destroy'
end

get '/submit' => 'submit_events#index'
Expand Down
5 changes: 5 additions & 0 deletions spec/controllers/admin/dashboard_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'rails_helper'

RSpec.describe Admin::DashboardController, type: :controller do

end
16 changes: 16 additions & 0 deletions spec/controllers/admin/sessions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,20 @@
end
end
end

describe "POST destroy" do
before do
admin = User.create(email: 'example@example.com', password: 'password', admin: true)
session[:user_id] = admin.id
post :destroy
end

it "sets session id to nil" do
expect(session[:user_id]).to_not be
end

it "redirects to home page" do
expect(response).to redirect_to(root_path)
end
end
end
17 changes: 10 additions & 7 deletions spec/features/user_log_in_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

feature "User Log In" do
scenario "with correct credentials" do
User.create(email: 'example@example.com', password: 'password', admin: true)
visit admin_login_path
expect(page).to have_text "Log In"
fill_in "email", with: 'example@example.com'
fill_in "password", with: 'password'
click_button "Log in"
expect(page).to have_text "Welcome to Stayloud LA!"
admin_log_in
expect(page).to have_text "Moderate Suggested Events"
end

scenario "with icorrect credentials", js: true do
user = User.create(email: "example@example.com", password: "password")
user.password = "12345"
admin_log_in(user)
save_and_open_page
expect(page).to have_text "No such user found."
end
end
9 changes: 9 additions & 0 deletions spec/features/user_log_out_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require "rails_helper"

feature "User Log Out" do
scenario "with correct credentials" do
admin_log_in
click_link "Log Out"
expect(page).to have_text "Find A Protest Near You"
end
end
2 changes: 2 additions & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }

config.include FeatureMacros, type: :feature
# RSpec Rails can automatically mix in different behaviours to your tests
# based on their file location, for example enabling you to call `get` and
# `post` in specs under `spec/controllers`.
Expand Down
6 changes: 6 additions & 0 deletions spec/services/get_fb_event_object_from_fb_id_service_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
describe GetFbEventObjectFromFbIdService do
context ".fetch" do
it "returns a facebook event" do
end
end
end
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# it.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
Capybara.javascript_driver = :webkit
RSpec.configure do |config|
# rspec-expectations config goes here. You can use an alternate
# assertion/expectation library such as wrong or the stdlib/minitest
Expand Down
10 changes: 10 additions & 0 deletions spec/support/feature_macros.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module FeatureMacros
def admin_log_in(user = nil)
user ||= User.create(email: 'example@example.com', password: 'password', admin: true)
visit admin_login_path
expect(page).to have_text "Log In"
fill_in "email", with: user.email
fill_in "password", with: user.password
click_button "Log in"
end
end