diff --git a/test/fixtures/nodes.yml b/test/fixtures/nodes.yml index db7689481b..ce072e24b0 100644 --- a/test/fixtures/nodes.yml +++ b/test/fixtures/nodes.yml @@ -274,7 +274,8 @@ post_test1: changed: <%= DateTime.new(2018,8,1).to_i %> status: 1 type: "note" - cached_likes: 0 + cached_likes: 8 + views: 6 longitude: 52.0 latitude: 160.0 precision: 1 @@ -289,7 +290,8 @@ post_test2: changed: <%= DateTime.new(2018,8,8).to_i %> status: 1 type: "note" - cached_likes: 0 + cached_likes: 3 + views: 3 longitude: 52.23 latitude: 34.57 precision: 2 @@ -304,7 +306,8 @@ post_test3: changed: <%= DateTime.new(2018,8,15).to_i %> status: 1 type: "note" - cached_likes: 0 + cached_likes: 7 + views: 9 longitude: 52.0 latitude: 12.0 precision: 1 @@ -380,4 +383,4 @@ purple_air_with_hyphen: status: 1 type: "note" cached_likes: 0 - slug: "purple-air-with-hyphen" \ No newline at end of file + slug: "purple-air-with-hyphen" diff --git a/test/functional/tag_controller_test.rb b/test/functional/tag_controller_test.rb index f1ca5cb70f..bb88114d9a 100644 --- a/test/functional/tag_controller_test.rb +++ b/test/functional/tag_controller_test.rb @@ -63,7 +63,7 @@ def setup UserSession.create(users(:bob)) post :create, - params: { + params: { name: 'my invalid tag $_', nid: nodes(:one).nid } @@ -76,7 +76,7 @@ def setup UserSession.create(users(:bob)) post :create, - params: { + params: { name: 'with:bob', nid: nodes(:one).nid # authored by jeff, not bob } @@ -170,12 +170,26 @@ def setup # assert_equal assigns['tags'].length, 1 assert_select '#wiki-content', 1 end - + test 'show page for non-existent tag' do get :show, params: { id: 'nonexistent' } assert :success end + test 'tag show, sort by views DESC' do + get :show, params: { id: tags(:latitude).name, order: 'views' } + views_array = assigns['notes'].map(&:views) + sorted_views_array = views_array.sort.reverse + assert_equal sorted_views_array, views_array + end + + test 'tag show, sort by likes DESC' do + get :show, params: { id: tags(:latitude).name, order: 'likes' } + likes_array = assigns['notes'].map(&:cached_likes) + sorted_likes_array = likes_array.sort.reverse + assert_equal sorted_likes_array, likes_array + end + test 'tag show range' do get :show, params: { id: tags(:spectrometer).name, start: (Time.now - 1.day).strftime('%d-%m-%Y'), @@ -334,7 +348,7 @@ def setup test 'tag contributors' do get :show, - params: { + params: { node_type: 'contributors', id: Tag.last.name } @@ -618,14 +632,14 @@ def setup end assert_not ActionMailer::Base.deliveries.collect(&:subject).include?("#{node.title} (#{tagname})") end - + test 'should render a text/pain when a tag is deleted through post request xhr' do user = UserSession.create(users(:jeff)) node_tag = node_tags(:awesome) post :delete, params: { nid: node_tag.nid, tid: node_tag.tid, uid: node_tag.uid}, xhr: true assert_equal "#{node_tag.tid}", @response.body end - + test 'add_parent method adds a tag parent' do user = UserSession.create(users(:admin)) get :add_parent, params: { name: Tag.last.name, parent: Tag.first.name } @@ -672,4 +686,3 @@ def setup assert_response :success end end -