Skip to content

Commit

Permalink
Merge pull request pinballmap#1234 from RyanTG/master
Browse files Browse the repository at this point in the history
reset redo checkbox when form is submitted
  • Loading branch information
scottwainstock committed Feb 24, 2020
2 parents 4aa58ef + eea6783 commit 3859ee3
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 106 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ gem 'sass-rails'
gem 'simple_form'
gem 'simple_token_authentication'
gem 'tunemygc'
gem 'twitter'
gem 'tzinfo-data'
gem 'uglifier'

Expand Down
33 changes: 0 additions & 33 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,6 @@ GEM
aws-eventstream (~> 1.0, >= 1.0.2)
bcrypt (3.1.12)
benchmark-ips (2.7.2)
buftok (0.2.0)
builder (3.2.3)
bullet (5.9.0)
activesupport (>= 3.0.0)
Expand Down Expand Up @@ -816,13 +815,10 @@ GEM
devise (>= 2.1.0)
diff-lcs (1.3)
docile (1.3.1)
domain_name (0.5.20180417)
unf (>= 0.0.5, < 1.0.0)
email_spec (2.2.0)
htmlentities (~> 4.3.3)
launchy (~> 2.1)
mail (~> 2.7)
equalizer (0.0.11)
erubi (1.8.0)
erubis (2.7.0)
exception_notification (4.3.0)
Expand Down Expand Up @@ -867,15 +863,6 @@ GEM
ruby_parser (~> 3.5)
htmlentities (4.3.4)
http-2 (0.10.1)
http (3.3.0)
addressable (~> 2.3)
http-cookie (~> 1.0)
http-form_data (~> 2.0)
http_parser.rb (~> 0.6.0)
http-cookie (1.0.3)
domain_name (~> 0.5)
http-form_data (2.1.1)
http_parser.rb (0.6.0)
i18n (1.6.0)
concurrent-ruby (~> 1.0)
i18n_data (0.8.0)
Expand Down Expand Up @@ -924,8 +911,6 @@ GEM
marcel (0.3.3)
mimemagic (~> 0.3.2)
memcachier (0.0.2)
memoizable (0.4.2)
thread_safe (~> 0.3, >= 0.3.1)
memory_profiler (0.9.12)
method_source (0.9.2)
mime-types (3.2.2)
Expand All @@ -937,8 +922,6 @@ GEM
minitest (5.11.3)
moneta (1.0.0)
multi_json (1.13.1)
multipart-post (2.0.0)
naught (1.1.0)
nested_form (0.3.2)
newrelic_rpm (6.1.0.352)
nio4r (2.3.1)
Expand Down Expand Up @@ -1108,7 +1091,6 @@ GEM
simple_form (4.1.0)
actionpack (>= 5.0)
activemodel (>= 5.0)
simple_oauth (0.3.1)
simple_token_authentication (1.15.1)
actionmailer (>= 3.2.6, < 6)
actionpack (>= 3.2.6, < 6)
Expand Down Expand Up @@ -1141,26 +1123,12 @@ GEM
timecop (0.9.1)
tins (1.20.2)
tunemygc (1.0.71)
twitter (6.2.0)
addressable (~> 2.3)
buftok (~> 0.2.0)
equalizer (~> 0.0.11)
http (~> 3.0)
http-form_data (~> 2.0)
http_parser.rb (~> 0.6.0)
memoizable (~> 0.4.0)
multipart-post (~> 2.0)
naught (~> 1.0)
simple_oauth (~> 0.3.0)
tzinfo (1.2.5)
thread_safe (~> 0.1)
tzinfo-data (1.2018.9)
tzinfo (>= 1.0.0)
uglifier (4.1.20)
execjs (>= 0.3.0, < 3)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.5)
unicode-display_width (1.4.1)
unicode_utils (1.4.0)
uniform_notifier (1.12.1)
Expand Down Expand Up @@ -1244,7 +1212,6 @@ DEPENDENCIES
spork
timecop
tunemygc
twitter
tzinfo-data
uglifier
webdrivers (~> 4.0)
Expand Down
25 changes: 0 additions & 25 deletions app/assets/stylesheets/application.css.scss.erb
Original file line number Diff line number Diff line change
Expand Up @@ -340,31 +340,6 @@ div.stats span.stats_list span.score_score {

/** Home **/

ul.twitter {
list-style-type: none;
padding: 0;
margin-bottom: 0;
}
.twitter li {
padding: 5px 0;
border-bottom: 1px solid #DECEB9;
font-family: $serif;
color: #452809;
font-size: 13px;
}
.twitter li:nth-child(5) {
border: none;
}
.twitter_img img {
@include radius(5px);
margin: 3px 5px 2px 0;
float: left;
}
p.twitter_box {
font-family: $serif;
font-size: 14px;
line-height: 18px;
}
p.notice {
color: $red;
font-size: 18px;
Expand Down
3 changes: 0 additions & 3 deletions app/assets/stylesheets/mobile-application.css.erb
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,6 @@ span.login_list {
.pick_a_map span.pick_a_map {
display: none;
}
.twitter li {
font-size: 16px;
}
div.pick_a_map {
padding-top: 0;
}
Expand Down
25 changes: 8 additions & 17 deletions app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ def map
user = current_user.nil? ? nil : current_user

params[:user_faved] = user.id if user && !params[:user_faved].blank?

@region_list = Region.all
@region_random = @region_list.sample
@random_lat = @region_random.lat
@random_lon = @region_random.lon
end

def region
Expand Down Expand Up @@ -95,7 +100,7 @@ def region
end

def contact_sent
return if params['contact_msg'].nil? || params['contact_msg'].empty?
return if params['contact_msg'].nil? || params['contact_msg'].empty? || params['contact_msg'].match?(/vape/) || params['contact_msg'].match?(/seo/)

user = current_user.nil? ? nil : current_user

Expand Down Expand Up @@ -194,25 +199,11 @@ def flier
end

def home
if ENV['TWITTER_CONSUMER_KEY'] && ENV['TWITTER_CONSUMER_SECRET'] && ENV['TWITTER_OAUTH_TOKEN_SECRET'] && ENV['TWITTER_OAUTH_TOKEN']
begin
client = Twitter::REST::Client.new do |config|
config.consumer_key = ENV['TWITTER_CONSUMER_KEY']
config.consumer_secret = ENV['TWITTER_CONSUMER_SECRET']
config.access_token = ENV['TWITTER_OAUTH_TOKEN']
config.access_token_secret = ENV['TWITTER_OAUTH_TOKEN_SECRET']
end
@tweets = client.user_timeline('pinballmapcom', count: 5)
rescue Twitter::Error
@tweets = []
end
else
@tweets = []
end

@machine_and_location_count_by_region = Region.machine_and_location_count_by_region
@all_regions = Region.order(:state, :full_name)
@region_data = regions_javascript_data(@all_regions, @machine_and_location_count_by_region)

@last_updated_time = Location.maximum(:updated_at)
end

def regions_javascript_data(regions, machine_and_location_count_by_region)
Expand Down
4 changes: 4 additions & 0 deletions app/views/locations/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
$('.location_search').on('submit', function(e) {
$(".mask").hide();
ismap = 0;
if (mapAdjusted = 1) { //reset checkbox
mapAdjusted = 0;
$('#followCheck').prop('checked', false);
}
$('#search_link_wrapper').css('display','block');
e.preventDefault();
search_string = $(this).children(":input").filter(function(index, element) { return $(element).val() != ''; }).serialize();
Expand Down
4 changes: 4 additions & 0 deletions app/views/pages/home.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
=image_tag( 'splash-icon-128.png', :alt => 'splash', :style => 'height:96px;', :class => 'splash')
%p.bold.p3
= link_to 'Explore the Map', map_path
%p
The map was last edited
=distance_of_time_in_words(Time.now, @last_updated_time)
ago.
#div_container_row{:style => 'border-bottom:20px solid #d1dfe8;'}
.div_01b.home_intro
%p.darkb News!
Expand Down
6 changes: 5 additions & 1 deletion app/views/pages/map.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
Redo results when map is moved?

#map
= render :partial => 'locations/map', locals: { lat: 45.512794, lon: -122.679565 }
= render :partial => 'locations/map', locals: { lat: @random_lat, lon: @random_lon }

#lookup.toggle_reg_lookup.map_lookup
#locations
Expand Down Expand Up @@ -72,6 +72,10 @@
:javascript
$('#address_search_form').on('submit', function(e) {
$(".mask").hide();
if (mapAdjusted = 1) { //reset checkbox
mapAdjusted = 0;
$('#followCheck').prop('checked', false);
}
$('#search_link_wrapper').css('display','block');
e.preventDefault();
search_string = $("#address_search_form :input").filter(function(index, element) { return $(element).val() != ''; }).serialize();
Expand Down
32 changes: 6 additions & 26 deletions spec/controllers/pages_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,6 @@
FactoryBot.create(:user, email: 'super_admin@bar.com', region: nil, is_super_admin: 1)
end

describe '#home - twitter' do
it 'should return no tweets without env variables set' do
get 'home'

expect(assigns(:tweets)).to eq([])
end

it 'should error on invalid ENV data' do
stub_const('ENV', 'TWITTER_CONSUMER_KEY' => '1', 'TWITTER_CONSUMER_SECRET' => '1', 'TWITTER_OAUTH_TOKEN_SECRET' => '1', 'TWITTER_OAUTH_TOKEN' => '1')

get 'home'

expect(assigns(:tweets)).to eq([])
end

it 'should return no tweets with env variables set, because i am stubbing things out' do
stub_const('ENV', 'TWITTER_CONSUMER_KEY' => '1', 'TWITTER_CONSUMER_SECRET' => '1', 'TWITTER_OAUTH_TOKEN_SECRET' => '1', 'TWITTER_OAUTH_TOKEN' => '1')
expect(Twitter::REST::Client).to receive(:new).and_return(Twitter::REST::Client)
expect(Twitter::REST::Client).to receive(:user_timeline).and_return('tweet' => 'twoot')

get 'home'

expect(assigns(:tweets)).to eq('tweet' => 'twoot')
end
end

describe '#links' do
it 'should redirect you to the about page' do
get 'links', params: { region: 'portland' }
Expand Down Expand Up @@ -123,6 +97,12 @@

post 'contact_sent', params: { region: 'portland', contact_name: 'foo', contact_email: 'bar', contact_msg: nil }
end

it 'should not send an email if the body contains a spam keyword' do
expect(Pony).to_not receive(:mail)

post 'contact_sent', params: { region: 'portland', contact_name: 'foo', contact_email: 'bar', contact_msg: 'vape' }
end

it 'should flash an error message if captcha fails' do
logout
Expand Down
1 change: 1 addition & 0 deletions spec/features/pages_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
FactoryBot.create(:user_fave_location, location: FactoryBot.create(:location, name: 'Baz'))

visit '/saved'
sleep 1

expect(page.body).to have_content('Foo')
expect(page.body).to have_content('Bar')
Expand Down

0 comments on commit 3859ee3

Please sign in to comment.