Skip to content

Commit

Permalink
various tests and fixes publiclab#753, fixes publiclab#947, fixes pub…
Browse files Browse the repository at this point in the history
  • Loading branch information
jywarren authored Nov 2, 2016
1 parent c0d6205 commit 3477ee7
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Some key features include:

## Contributing

We welcome contributions, and are especially interested in welcoming [first time contributors](#first-time). Read more about [how to contribute](#developers) below!
We welcome contributions, and are especially interested in welcoming [first time contributors](#first-time). Read more about [how to contribute](#developers) below! We especially welcome contributions from people from groups underrepresented in free and open source software!

### Code of Conduct

Expand Down
2 changes: 1 addition & 1 deletion app/models/drupal_node_community_tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def author
end

def user
DrupalUsers.find(self.uid).user
DrupalUsers.find_by_uid(self.uid).try(:user)
end

def drupal_user
Expand Down
2 changes: 1 addition & 1 deletion app/views/map/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

<hr />

<% unless @node.map.notes.empty? %>
<% unless @node.map.notes.nil? %>
<h3>Notes</h3>
<p><%= raw RDiscount.new(auto_link(@node.map.notes, :sanitize => false)).to_html %></p>

Expand Down
2 changes: 1 addition & 1 deletion app/views/tag/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<li<% if @node_type == "questions" %> class="active"<% end %>><a href="/questions/tag/<%= params[:id] %>"><i class="fa fa-question-circle"></i> <%= t('tag.show.questions') %></a></li>
<li<% if @node_type == "wiki" %> class="active"<% end %>><a href="/wiki/tag/<%= params[:id] %>"><i class="fa fa-book"></i> <%= raw t('tag.show.wiki_pages') %></a></li>
<li<% if @node_type == "maps" %> class="active"<% end %>><a href="/maps/tag/<%= params[:id] %>"><i class="fa fa-map-marker"></i> <%= t('tag.show.maps') %></a></li>
<li<% if @node_type == "contributors" %> class="active"<% end %>><li><a href="/contributors/<%= params[:id] %>"><i class="fa fa-user"></i> <%= raw t('tag.show.contributors') %></a></li>
<li<% if @node_type == "contributors" %> class="active"<% end %>><a href="/contributors/<%= params[:id] %>"><i class="fa fa-user"></i> <%= raw t('tag.show.contributors') %></a></li>
</ul>

<br />
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/profile.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
<li><a href="#questions" data-toggle="tab"><i class="fa fa-comments"></i><span class="hidden-sm hidden-xs"> <%= t('users.profile.questions') %> (<%= DrupalNode.questions.where(status: 1, uid: @user.id).count %>)</span></a></li>
<li><a href="#comments" id="comments-tab" data-toggle="tab"><i class="fa fa-comment"></i><span class="hidden-sm hidden-xs"> <%= t('users.profile.comments') %></span></a></li>
<li><a href="/profile/<%= @user.username %>/likes"><i class="fa fa-star"></i><span class="hidden-sm hidden-xs"> <%= t('users.profile.liked') %></span> (<%= @user.like_count %>)</a></li>
<li><a href="#barnstars" data-toggle="tab"><i class="fa fa-certificate"></i><span class="hidden-sm hidden-xs"> <%= t('users.profile.barnstars') %></span> (<%= @user.user.barnstars.length %>)</a></li>
<li><a href="#barnstars" data-toggle="tab"><i class="fa fa-certificate"></i><span class="hidden-sm hidden-xs"> <%= t('users.profile.barnstars') %></span> (<%= @user.user.try(:barnstars).try(:length) %>)</a></li>
</ul>

<br />
Expand Down
6 changes: 6 additions & 0 deletions test/fixtures/users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,9 @@ test_user:
name: testuser
status: 1
mail: [email protected]

legacy_user:
uid: 11
name: legacy
status: 1
mail: [email protected]
1 change: 1 addition & 0 deletions test/functional/map_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ class MapControllerTest < ActionController::TestCase
date: map.created_at.strftime("%m-%d-%Y")
assert_response :success
end

end
5 changes: 5 additions & 0 deletions test/functional/users_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -260,4 +260,9 @@ def setup
assert_not_nil assigns(:comments)
assert_template partial: 'comments/_comments'
end

test "profiles for legacy users" do
user = users(:legacy_user)
assert_response :success
end
end
10 changes: 10 additions & 0 deletions test/unit/drupal_tag_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ class DrupalTagTest < ActiveSupport::TestCase
assert (subscribers.to_a.collect(&:last).map { |o| o[:user]}).include?(tag_selection(:awesome).user)
end

test "creating a tag with a bad uid" do
community_tag = DrupalNodeCommunityTag.new({
uid: 1343151513,
tid: tags(:awesome).tid,
nid: node(:one).nid
})
assert community_tag.save!
assert_nil community_tag.author
end

test "tag weekly tallies" do
tag = tags(:awesome)
tallies = tag.weekly_tallies
Expand Down
7 changes: 7 additions & 0 deletions test/unit/drupal_user_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,11 @@ class DrupalUserTest < ActiveSupport::TestCase
assert users(:lurker).first_time_poster
end

test "user.barnstars" do
user = users(:bob)
assert_equal 0, user.user.barnstars.length
user = users(:legacy_user)
assert_nil user.user
end

end

0 comments on commit 3477ee7

Please sign in to comment.