Skip to content

Commit

Permalink
fix tests after changing category of skill
Browse files Browse the repository at this point in the history
  • Loading branch information
Vakmeth committed Feb 27, 2024
1 parent 08c3ff9 commit f0abffc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
25 changes: 9 additions & 16 deletions spec/controllers/api/skills_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
describe 'SkillsController as admin' do
before { load_pictures }

before(:each) do
allow_any_instance_of(SkillsController).to receive(:admin_flag?).and_return(true)
end

let(:bob) { people(:bob) }

describe 'GET index' do
Expand Down Expand Up @@ -57,13 +53,13 @@
get :index, params: { category: parent_category.id }

skills = json['data']
expect(skills.count).to eq(3)
expect(skills.count).to eq(4)
cunit_attrs = skills.first['attributes']
junit_attrs = skills.second['attributes']
rails_attrs = skills.third['attributes']
ember_attrs = skills.second['attributes']
junit_attrs = skills.third['attributes']
expect(cunit_attrs['title']).to eq ('cunit')
expect(ember_attrs['title']).to eq ('ember')
expect(junit_attrs['title']).to eq ('JUnit')
expect(rails_attrs['title']).to eq ('Rails')
end

it 'returns skills with parent category software-engineering and defaultSet true' do
Expand Down Expand Up @@ -104,13 +100,10 @@
end
end
end

describe 'SkillsController as normal user' do
before { load_pictures }

before(:each) do
allow_any_instance_of(SkillsController).to receive(:admin_flag?).and_return(false)
end

let(:bob) { people(:bob) }

describe 'GET index' do
Expand Down Expand Up @@ -160,13 +153,13 @@
get :index, params: { category: parent_category.id }

skills = json['data']
expect(skills.count).to eq(3)
expect(skills.count).to eq(4)
cunit_attrs = skills.first['attributes']
junit_attrs = skills.second['attributes']
rails_attrs = skills.third['attributes']
ember_attrs = skills.second['attributes']
junit_attrs = skills.third['attributes']
expect(cunit_attrs['title']).to eq ('cunit')
expect(ember_attrs['title']).to eq ('ember')
expect(junit_attrs['title']).to eq ('JUnit')
expect(rails_attrs['title']).to eq ('Rails')
end

it 'returns skills with parent category software-engineering and defaultSet true' do
Expand Down
3 changes: 2 additions & 1 deletion spec/domain/skills_filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
filter = SkillsFilter.new(Skill.all, 458108788, nil, nil)
filteredSkills = filter.scope

expect(filteredSkills.count).to eq(3)
expect(filteredSkills.count).to eq(4)
expect(filteredSkills[0].title).to eq('Rails')
expect(filteredSkills[1].title).to eq('JUnit')
expect(filteredSkills[2].title).to eq('cunit')
expect(filteredSkills[3].title).to eq('ember')
end

it 'filters skills by title' do
Expand Down
2 changes: 1 addition & 1 deletion spec/exporters/csv/skillset_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
it 'exports' do
csv = Csv::Skillset.new(Skill.all).export
csv = csv.split("\n")
expect(csv.length).to eq(5)
expect(csv.length).to eq(6)
expect(csv.first.split(",").length).to eq(7)
rails = csv.select { |s| s.include?('Rails') && s.include?('5') }.first
expect(rails).not_to eq (nil)
Expand Down

0 comments on commit f0abffc

Please sign in to comment.