Updated authors in the views
parent
8c2d966fc8
commit
7db27d031d
|
@ -52,6 +52,11 @@ class ModDecorator < Draper::Decorator
|
|||
h.date_time_tag(last_version.released_at)
|
||||
end
|
||||
|
||||
def author_link
|
||||
return na unless mod.author
|
||||
h.link_to(mod.author.name, mod.author)
|
||||
end
|
||||
|
||||
def authors_links_list
|
||||
return na if mod.authors.empty?
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
= icon 'cog'
|
||||
-# It's here in the middle so we can make some CSS magic
|
||||
= render partial: 'mods/download_button', locals: { mod: mod }
|
||||
%span.mod-info-tag{title: t('.links.authors', count: mod.authors_count)}
|
||||
.mod-info-tag-label
|
||||
= mod.authors_links_list
|
||||
%span.mod-info-tag{title: t('.links.author')}
|
||||
.mod-info-tag-label= mod.author_link
|
||||
= icon 'user'
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
%ul.mod-data
|
||||
%li{class: ('wide' if @mod.authors_count > 2)}
|
||||
%li
|
||||
.data-name= t('.game_version')
|
||||
.data-value= @mod.game_versions_string
|
||||
%li{class: ('wide' if @mod.authors_count > 2)}
|
||||
.data-name= t('.authors', count: @mod.authors_count)
|
||||
.data-value= @mod.authors_links_list
|
||||
%li
|
||||
.data-name= t('.author')
|
||||
.data-value= @mod.author_link
|
||||
- if @mod.additional_contributors.present?
|
||||
%li.wide
|
||||
.data-name= t('.additiona_contributors')
|
||||
|
|
|
@ -4,9 +4,7 @@ en:
|
|||
links:
|
||||
last_version_date: "Date of the latest version of this mod %{date}"
|
||||
game_version: Factorio versions this mod works with
|
||||
authors:
|
||||
one: The awesome person behind this mod
|
||||
other: The awesome people behind this mod
|
||||
author: The awesome person behind this mod
|
||||
|
||||
new:
|
||||
title: Create new mod
|
||||
|
@ -62,9 +60,7 @@ en:
|
|||
|
||||
mod_data_table:
|
||||
game_version: Factorio version
|
||||
authors:
|
||||
one: Author
|
||||
other: Authors
|
||||
author: Author
|
||||
first_version: First version
|
||||
last_version: Last version
|
||||
source: Source
|
||||
|
|
|
@ -3,7 +3,20 @@ describe ModDecorator do
|
|||
create(*args).decorate
|
||||
end
|
||||
|
||||
describe '#author_link' do
|
||||
it 'should return a link to the author page if the mod has an author' do
|
||||
mod = create_decorated :mod, author: (create :author, name: "Au0")
|
||||
expect(mod.author_link).to eq '<a href="/authors/au0">Au0</a>'
|
||||
end
|
||||
|
||||
it 'should return N/A if the mod has no author' do
|
||||
mod = create_decorated :mod, author: nil
|
||||
expect(mod.author_link).to eq 'N/A'
|
||||
end
|
||||
end
|
||||
|
||||
describe '#authors_links_list' do
|
||||
|
||||
it 'should return a comma separated authors list links' do
|
||||
mod = create_decorated :mod, authors: 3.times.map{ |i| create :author, name: "Au#{i}" }
|
||||
expect(mod.authors_links_list).to eq '<a href="/authors/au0">Au0</a>, <a href="/authors/au1">Au1</a>, <a href="/authors/au2">Au2</a>'
|
||||
|
|
|
@ -77,10 +77,10 @@ feature 'Display an index of mods in certain order' do
|
|||
end
|
||||
end
|
||||
|
||||
scenario 'Mod with multiple authors' do
|
||||
authors = 5.times.map{ |i| create :author, name: "Au#{i}" }
|
||||
mod = create :mod, name: 'SuperMod', authors: authors
|
||||
scenario 'Mod with author authors' do
|
||||
author = create :author, name: "rsatrsatrsatheniratshr"
|
||||
mod = create :mod, name: 'SuperMod', author: author
|
||||
visit '/'
|
||||
expect(page.html).to include(mod.decorate.authors_links_list)
|
||||
expect(page.html).to include(mod.decorate.author_link)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
describe "mods/show.html.erb", :type => :view do
|
||||
describe "mods/show.haml", type: :view do
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue